ラズパイでapt-getができなくなった話

ラズパイが壊れてオーバーヒート気味になり、UIにつながらなくなってしまった。再度ラズパイを購入し、いろいろいじって遊んでいきます。
そんな中、いろいろパッケージ入れたいものの、うまくいかず途方に暮れかけた話です。

スペック
Raspberry Pi4 ModelB 4GB
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye
こんな感じです。新しいOSはpiユーザーがなくなっちゃったらしいです。
しばらく触らないうちに色々変わってそうだと先行きが不安。

事象
apt-get install XXXでソフトをインストールしていきたかったのですが、
何をインストールしようともこんな感じでうまくいかない。

raspi@raspberrypi:~ $ sudo apt-get install vim
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了
状態情報を読み取っています... 完了
パッケージ vim は使用できませんが、別のパッケージから参照されます。
これは、パッケージが欠落しているか、廃止されたか、または別のソース
からのみ利用可能であることを意味します。

E: パッケージ 'vim' にはインストール候補がありません

さあ困った。
ざっと調べてみてapt-get updateやらapt-get upgradeやら--fullupgradeやらapt --fix-broken installやら実行してみたものの、一向に事象が解決しない。
特にエラーなども発生しない。
少しupdateの出力が短いな?本当にちゃんと動いてんのか?とは思ったが。。。
OSのバージョンも特段古いなどではないようだ。

これはリポジトリの問題だろうと思って確認してみた。

raspi@raspberrypi:~ $ cat /etc/apt/sources.list
deb http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-fre                                   e rpi

特に古いわけではなさそう。
リポジトリの場所が変わったなどでもなさそう?

ともあれリポジトリが怪しいのではとあたりをつけ、調べていると事象やエラーは異なるが他にもapt-getの調子が悪い人が結構いた。
下記リンク参考にリポジトリを書き換える。
https://qiita.com/dekuo-03/items/82c435790fcb70747933
https://wakky.tech/raspberry-pi-4-repository-error/

## 変更前 ##
raspi@raspberrypi:~ $ cat /etc/apt/sources.list.org
deb http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi

## 変更後##
raspi@raspberrypi:~ $ cat /etc/apt/sources.list
deb http://ftp.jaist.ac.jp/raspbian/ bullseye main contrib non-free rpideb http://ftp.jaist.ac.jp/raspbian/ bullseye main contrib non-free rpi
deb http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian/ bullseye main contrib non-free rpi
#deb http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi

デフォルトのリポジトリはコメントアウトし、日本国内のミラーサーバを追加した。

これで、apt-get update後、無事にapt-get installを実行することができた。
インストールやアップデートが遅いので国内ミラーサーバに書き換えなどの対応が多いようだ。今回調べた中では私のようなエラーパターンの解決記事が見当たらなかったため、備忘録とする。


この記事が気に入ったらサポートをしてみませんか?