I recently ran into some dpkg errors will running sudo apt full-upgrade on my VM (I ran update beforehand). I don't have the error message handy, but I remember it saying dpkg returned an error code of 1. I noticed from some of the output that apt/dpkg looked like it was removing packages that were dependencies of other packages, and it said "but removing anyway as you requested". Afterwards, nothing worked. dpkg threw more errors when I tried to run a command, Firefox crashed, the VM wouldn't shutdown. Luckily I take backups before I do upgrades. My questions came up when I was researching how to fix this.
- What is the difference between sudo apt full-upgrade and sudo apt upgrade? I read the man pages and understand the conceptual difference. What I don't get is when you'd use one over the other. What are the consequences of removing old packages like full-upgrade does, or not removing them like upgrade does? I assume everything broke because thefull-upgrade removed packages that were still being used.
- Whats the difference between -fix--missing and -fix--broken? Again, I read the man pages, but I don't get when you use one over the other, or what the consequences of each are. I couldn't find a lot online about the difference between a broken or a missing package.
- How does using -f with apt install differ from using it with apt update? I think I know what will happen, but I don't understand it.
Finally, most guides for fixing packages issues with apt contained some version of the following:
- Open the terminal and enter: sudo apt --fix-missing update
- Update your system's package list from the available sources: sudo apt update
- Now, force the installation of the broken packages using the -f flag. APT will automatically search for broken packages on your system and reinstall them from the official repository: sudo apt install -f.
If the aforementioned steps do not work for you, you can try to solve the issue using dpkg.
- Force dpkg to reconfigure all the pending packages that are already unpacked but need to undergo configuration. The -a flag in the following command stands for All*: sudo dpkg --configure -a*
- Pipe grep with dpkg to get a list of all the packages marked as Required*: sudo dpkg -l | grep ^..r*
- Use the --remove flag to delete all the broken packages: sudo dpkg --remove --force-remove-reinstreq
- Clean up the package cache and install scripts using apt clean*: sudo apt clean*
- Now, update your system's package lists using the following command: sudo apt update
I couldn't find many guides that fully explained why you run each step. I sort of get the picture, but I think I need someone to tie it together for me. I feel like whenever I get errors from apt/dpkg I sort of freak out and ignore them, or frantically copy and paste random commands I find after googling the problem hoping something works. I'm trying to be more intelligent about solving it this time.