I was attempting to update my npm on a Raspbian Buster installation. The version provided by the package manager was not sufficient.
First I followed some of the suggestions in this thread and then tried upgrading to Bullseye using these instructions.
I'm not entirely sure if this started before or after attempting to upgrade to Bullseye, but now whenever I run sudo apt install <anything> it tells me that it cannot install any of the dependencies. When I try to reinstall an already installed package I get the error that it cannot download the package. Here are two examples:
% sudo apt install nodejs Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: nodejs : Depends: libnode72 (= 12.22.12~dfsg-1~deb11u4) but it is not going to be installed E: Unable to correct problems, you have held broken packages. % sudo apt reinstall vim Reading package lists... Done Building dependency tree Reading state information... Done Reinstallation of vim is not possible, it cannot be downloaded. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. The system is fully updated and upgraded (as far as I can tell):
% sudo apt update && sudo apt full-upgrade && sudo apt dist-upgrade Hit:1 http://raspbian.raspberrypi.org/raspbian bullseye InRelease Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date. Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. No packages appear to be on hold:
% sudo apt-mark showhold % I tried various fixes suggested on the internet:
% sudo apt --fix-broken install % and
% sudo dpkg --configure -a % No results. I also renamed some *.list files to *.list.bak in /etc/apt/sources.list.d, but I believe I did that only after the issue started in an attempt to resolve it.
How do I recover my package manager to make it useable again?
Edits:
Output of apt policy nodejs
% sudo apt policy nodejs nodejs: Installed: (none) Candidate: 12.22.12~dfsg-1~deb11u4 Version table: 12.22.12~dfsg-1~deb11u4 50 50 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages Contents of /etc/apt/sources.list
% 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/ buster main contrib non-free rpi Output of uname -m
% uname -m armv7l Output of lsb_release -a:
% lsb_release -a No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 10 (buster) Release: 10 Codename: buster Noteworthy: it still lists as buster, not bullseye.
Progress Edit: So, I mentioned above that I followed these instructions to try to upgrade my npm. I believe this to have added an entry in sources.list.d, which I had disabled again. Enabling this entry again allowed me to run apt install nodejs. I tried installing some other packages, e.g. sudo apt install cowsay which succeeded. I then proceeded to try to run reinstall for those new packages sudo apt reinstall cowsay which also succeeded. Trying to reinstall packages that had been installed before continued to fail with a message that the package cannot be downloaded. When I manually uninstall and reinstall the package however, it succeeded: sudo apt remove nano && sudo apt install nano. Reinstalling after a manual uninstall and install succeeds now: sudo apt reinstall nano.
However, trying to install other packages continues to fail. E.g. installing npm fails with a long list of node-* dependencies (including nodejs which I just manually installed). Also, trying to install e.g. aptitude (which was recommended in some sources as being potentially able to recover a borked apt system) fails:
% sudo apt install aptitude Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: aptitude : Depends: libapt-pkg6.0 (>= 1.9.0) but it is not going to be installed Depends: libstdc++6 (>= 9) but 8.3.0-6+rpi1 is to be installed Depends: libxapian30 (>= 1.4.17~) but it is not going to be installed E: Unable to correct problems, you have held broken packages. So while there was some progress (being able to install nodejs) it seams I'm still not out of the woodwork.
apt policy nodejsto your question./etc/apt/sources.list; my best bet is that there's a subtle typo in there or something. Please edit your question to contain the contents of that file :)