Somehow two packages (that I don't want anymore) got corrupted after a file system check and are now missing files.
I installed and initialized debsums
and when I run it it gives a load of missing files (and only missing files).
I tried these commands (found all over the place):
sudo apt upgrade
sudo apt autoremove
sudo apt install brscan4
sudo apt remove brscan4
sudo dpkg --configure -a
sudo apt install --reinstall brscan4
sudo apt install -f --reinstall brscan4
sudo apt-get -f install
(without package name)sudo dpkg --remove --force-remove-reinstreq brscan4
sudo apt-get purge --remove brscan4
- [added]
dpkg -P brscan4
Notably, dpkg --configure -a
seems to be recommended everywhere as if it's the final last-resort solution that's supposed to fix it.
They all give the exact same error:
Removing brscan4 (0.4.4-3) ...
/var/lib/dpkg/info/brscan4.prerm: 3: /var/lib/dpkg/info/brscan4.prerm: /opt/brother/scanner/brscan4/setupSaneScan4: not found
dpkg: error processing package brscan4 (--remove): installed brscan4 package pre-removal script subprocess returned error exit status 127
These commands do nothing to the corrupted packages:
sudo apt update
sudo apt update --fix-missing
How can I fix this short of reinstalling Ubuntu from scratch? (his final solution, see chat)
When prerm/postrm/postinst are failing, you need to remove the package with more low-level tools, as apt will stop on this error.
The first try is to use
dpkg -P brscan4
and when it works install brscan4 again using apt.If still nothing works, edit the paths like
/var/lib/dpkg/info/brscan4.prerm
and insertexit 0
as second line. The script will not run and not produce an error. After that, reinstalling will probably fix the errors and the re-installed script hopefully runs without problems.