25

I have recently upgraded my OS to Ubuntu 18.04 (fresh install via boot device). However, when trying the command:

sudo apt-get upgrade

It works fine until ~75% when it stops and says:

snapd.snap-repair.service is a disabled or a static unit, not starting it.

I'm not quite sure what this means and if I Crtl-Z to get out of it, any time I try to install anything I get:

E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

and have to restart my computer to install anything.

pomsky
  • 68,507
  • 2
    With CTRL-Z you just suspend (pause) the apt-get program but it still holds a lock in /var/lib/dpkg/lock which prevents you from starting it a 2nd time. Hit CTRL-C instead of Z to actually stop and end the apt-get process. – PerlDuck May 17 '18 at 14:35
  • 1
    Also, snapd.snap-repair.service is a disabled or a static unit, not starting it. doesn't look like an error, but it seems to be just an info message. I'd recommend waiting for the process to end, and if it doesn't, please add the full log output of the apt command. – Dan May 17 '18 at 14:38
  • @Dan So I run: $sudo apt-get upgrade$

    I get: E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem. So then i try that command to get the error I was previously referring to in my original post. If I ctrl-C to try to quit at that point, I get a bunch of stuff that won't fit in this comment and this error at the end: Errors were encountered while processing: snapd

    – Permittivity May 17 '18 at 17:50
  • @JustinRoberts There are issues with your packages, unfortunately, we can't help out if we can't get more details about the error :(. Can you please [edit] your post to include the output of the command? You can use https://paste.ubuntu.com/ if the log is very large. – Dan May 21 '18 at 10:27
  • Upgrade was stuck at this message for me too. I waited ~10 minutes and it continued without any intervention. – user1768761 Oct 18 '22 at 16:26

5 Answers5

36

I also had the same problem and I solved it like this:

sudo fuser -vki /var/lib/dpkg/lock
sudo apt purge snapd
sudo dpkg --configure -a
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
sudo apt install snapd
Thomas
  • 6,223
  • 1
    This should be the accepted solution. First line could also be replaced by sudo pkill snapd.postinstall but yours is more general. – rosch Jun 26 '18 at 12:41
  • 1
    Thanks, worked for me Ubuntu 18.04. – Darkmoor Jul 28 '18 at 09:12
  • It also works on Ubuntu 19.04. Thank you. – jplandrain Aug 10 '19 at 14:18
  • 2
    It worked for my on Ubuntu 18.04LTS. However, the third command 'dkpg ...' got stuck with the initial problem again ("snapd.snap-repair.service is a disabled or ..."). So, I aborted it with 'Ctrl+C', re-ran the second command, and then the third one again. The rest worked like a charm. – UBod Sep 12 '19 at 09:48
  • Didn't work same error as OP after doing it. – Michael Rogers Feb 21 '21 at 00:07
11

Workaround for Ubuntu 18.10:

sudo dpkg -r snapd gnome-software-plugin-snap
sudo apt update
sudo apt full-upgrade
3

I ended up with this issue on the ubunt 20.04 pre-release.

For me, sudo service snapd stop made apt able to finish the upgrade. Might not work on other releases though...

Mikael
  • 31
1

I just noticed the same thing. Fresh install.

And as I'm writing this, the installation just continued after about 10 minutes.

I don't know what the update process was waiting for, but patience resolved the issue.

SDsolar
  • 3,169
  • I don't think that's the best option, but it can be a temporary one. On Ubuntu 18.10 this doesn't seem to work. – rosch Jun 26 '18 at 12:35
0

I had the same issue and didn't want to force stop on apt-get upgrade that causes dpkg lock error.

I opened another terminal and used: ps -aux | grep snapd to identify and kill process that stuck upgrade. For my case it was snapd.postinst.

Then upgrade progressed and ended with error Sub-process /usr/bin/dpkg returned an error code (1).

Then I tried Andrea Draghetti's answer without the first command but again snapd was stuck at installation! So I had to sudo apt purge snapd and live without it from now on.

Eliah Kagan
  • 117,780