0

Apologies up front if I'm asking a stupid question, I'm still pretty green when it comes to Linux. I am running Ubuntu Server 20.04 and trying to use sudo apt upgrade to update my system, but I get an unmet dependency error when I use the following commands:

$ sudo apt update
Hit:1 http://us.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 https://download.docker.com/linux/ubuntu focal InRelease
Get:3 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:6 https://repo.jellyfin.org/ubuntu focal InRelease [6636 B]
Fetched 343 kB in 1s (266 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
43 packages can be upgraded. Run 'apt list --upgradable' to see them.

Error when trying to upgrade:

$ sudo apt upgrade -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 libnss-systemd : Depends: systemd (= 245.4-4ubuntu3.17) but 245.4-4ubuntu3.16 is installed
 mysql-server-8.0 : Depends: mysql-server-core-8.0 (= 8.0.28-0ubuntu0.20.04.3) but 8.0.29-0ubuntu0.20.04.3 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

As best as I can tell, it looks like libnss needs a newer version of 245.4-4ubuntu installed, and for mysql it looks like I have something installed that is too new for it to be compatible with. But when I try to run the suggested fix command I get this:

$ sudo apt --fix-broken install -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  libpam-systemd libsystemd0 mysql-server-8.0 systemd systemd-sysv systemd-timesyncd
Suggested packages:
  mailx tinyca systemd-container
The following packages will be upgraded:
  libpam-systemd libsystemd0 mysql-server-8.0 systemd systemd-sysv systemd-timesyncd
6 upgraded, 0 newly installed, 0 to remove and 37 not upgraded.
28 not fully installed or removed.
Need to get 0 B/5573 kB of archives.
After this operation, 9216 B of additional disk space will be used.
Preconfiguring packages ...
(Reading database ... 158770 files and directories currently installed.)
Preparing to unpack .../mysql-server-8.0_8.0.29-0ubuntu0.20.04.3_amd64.deb ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: warning: old mysql-server-8.0 package pre-removal script subprocess returned error exit status 1
dpkg: trying script from the new package instead ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: error processing archive /var/cache/apt/archives/mysql-server-8.0_8.0.29-0ubuntu0.20.04.3_amd64.deb (--unpack):
 new mysql-server-8.0 package pre-removal script subprocess returned error exit status 1
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
Failed to preset unit: File mysql.service: Link has been severed
/usr/bin/deb-systemd-helper: error: systemctl preset failed on mysql.service: No such file or directory
Failed to start mysql.service: Unit mysql.service not found.
invoke-rc.d: initscript mysql, action "start" failed.
Unit mysql.service could not be found.
dpkg: error while cleaning up:
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/mysql-server-8.0_8.0.29-0ubuntu0.20.04.3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Any help would be greatly appreciated!

  • Tip for new users: Get out of the habit of using the -y flag with apt. That flag disables an important protection -- your ability to read, understand, and agree with (or abort) changes. Having used Debian-based systems for nearly 20 years, I never use -y outside of scripts, I always read the output before agreeing to the change...and doing so has saved me a couple times from a horrible fate. – user535733 May 28 '22 at 11:30
  • Did you install MariaDB before removing MySQL? If so, you may get name conflicts that cause MySQL installl/uninstall scripts to fail. See https://stackoverflow.com/questions/65949014/cannot-uninstall-mysql-server-8-0. Their answer is to completely uninstall BOTH to eliminate the conflict, then reinstall the one you really want. – user535733 May 28 '22 at 11:39

0 Answers0