How do I remove an incomplete or broken snap installation of nextcloud on a Raspberry Pi?

64,091

Solution 1

The snap command is actually made up of two components, server and client. You're interacting with the client. When you cancelled the install operation on the client side that's the only place you cancelled it-- the client. So it stopped showing you that it was installing, but it was still installing (this is a bug). (Update: This bug was fixed in snapd v2.20.1.)

On the server side, all of this stuff is happening in "changes." You can read more about them here, but for your purposes, you want to just abort this specific change. To do that, run:

$ snap changes
<snip>
203  Doing   2016-06-24T12:17:45Z  -  Install "nextcloud" snap

Note the ID, 203, and the fact that it's "Doing" it right now. To abort that operation, you use the change ID:

$ sudo snap abort 203

And the change should stop. However, I must say that the fact that the change froze partway through does not bode well for your ability to abort it. If it doesn't work, perhaps try rebooting. If that still doesn't seem to have fixed it and you're okay losing all your snaps and their data, you can completely reset the snapd state with this script.

Solution 2

When you see an erroneous snap install and you did not install the app, run the command

sudo snap changes

and look for the ID of the installed app.
After that, run the command

sudo snap remove app_name 

and return to

sudo snap install app
Share:
64,091

Related videos on Youtube

Dennis
Author by

Dennis

Just a typical computer user that gets to bang on the keyboard most of the day. Primarily data collection in a CAD environment. Since I like to poke around and read up on things that interest me I end up getting most of the support calls in the friends and family circle. Windows at work, Ubuntu at home (main accomplishment has been switching wife and several kids, friends, boss to full time open source use), Python for fun and work with it embedded in our CAD system. Wish I had grown up to be a developer since "garbage collection" in my first programing environment meant picking up your punch cards if you weren't careful.

Updated on September 18, 2022

Comments

  • Dennis
    Dennis over 1 year

    First the caveat: I understand that this question involves Mate and a Raspberry Pi so if you consider it outside the realm of this forum just ignore it. But on the chance that it may be helpful or typical of something involving snaps or that platform, here goes.

    I decided to try and install the nextcloud snap. It threw a ton of errors and seemed to freeze in the middle of the process (for over an hour). I killed it and just decided to try and remove it. The install looked like....

    $ sudo snap install nextcloud
    2016-06-24T08:48:29-04:00 ERROR cannot setup apparmor for snap "nextcloud": cannot load apparmor profile "snap.nextcloud.apache": cannot load apparmor profile: exit status 1
    apparmor_parser output:
    Cache read/write disabled: interface file missing. (Kernel needs AppArmor 2.4 compatibility patch.)
    Warning: unable to find a suitable fs in /proc/mounts, is it mounted?
    Use --subdomainfs to override.
    
    2016-06-24T08:53:29-04:00 ERROR cannot setup apparmor for snap "nextcloud": cannot load apparmor profile "snap.nextcloud.apache": cannot load apparmor profile: exit status 1
    apparmor_parser output:
    Cache read/write disabled: interface file missing. (Kernel needs AppArmor 2.4 compatibility patch.)
    Warning: unable to find a suitable fs in /proc/mounts, is it mounted?
    Use --subdomainfs to override.
    
    [|] Setup snap "nextcloud" security profiles
    

    When I try snap remove nextcloud I get

    error: cannot remove "nextcloud": snap "nextcloud" has changes in progress

    What I would primarily like to do is properly remove the snap and recover the space from the partition it created. If partition is the correct term??

    $ lsblk
    NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
    loop0         7:0    0  46.6M  0 loop /snap/ubuntu-core/120
    loop1         7:1    0 113.9M  0 loop /snap/nextcloud/12
    mmcblk0     179:0    0  14.9G  0 disk
    ├─mmcblk0p1 179:1    0    64M  0 part /boot
    └─mmcblk0p2 179:2    0  14.8G  0 part /
    

    I tried

    snap abort nextcloud

    and got

    error: cannot find change with id "nextcloud"

    I should also note that it doesn't show up as installed as I get only the following

    $ snap list
    Name Version Rev Developer Notes
    ubuntu-core 16.04+20160531.12-01 120 canonical -

    Though it does show up in....

    $ snap interfaces
    :network nextcloud
    :network-bind nextcloud

    I tried

    $ snap changes
    ID   Status  Spawn                 Ready  Summary
    1    Doing   2016-06-24T12:39:20Z  -      Install "nextcloud" snap
    
    $ sudo snap abort 1
    
    $ snap changes
    ID   Status  Spawn                 Ready  Summary
    1    Abort   2016-06-24T12:39:20Z  -      Install "nextcloud" snap
    

    But the partition is still there.

    ** Update, I ran the entire process again for debugging purposes and just let it sit after the "snap abort 1" command. At some point something seems to have completed in the background because lsblk shows nothing and the snap interfaces query shows nothing.

  • Dennis
    Dennis almost 8 years
    Going to upvote for now because the script does indeed get rid of the partition and that was stated as my primary goal. I did that and then went back through the entire process to collect error messages and updated the question to reflect that information as well as the fact that as you stated the freezing indicated that the abort and removal would not work. I'll give it a day to see if there is a cleaner way to just get rid of nextcloud and if not will accept this because of the efficacy of the script. Thanks
  • kyrofa
    kyrofa almost 8 years
    I'm a little confused regarding the "partition" to which you refer. Snapd doesn't partition anything. To what exactly are you referring?
  • Dennis
    Dennis almost 8 years
    Side note, I see from your blog that you are apparently "the man" on this topic. If there is anything I can provide that would be useful re: why this didn't work in the first place please let me know.
  • kyrofa
    kyrofa almost 8 years
    Haha, oh hardly, I just write sometimes. Snaps are simply squashfs images which are then mounted into place in /snap, which is what you're seeing there. Regarding the failure, it looks like some kernel issues on armhf for MATE. Would you mind logging a bug with this information so we can properly investigate?
  • Bangash
    Bangash about 5 years
    It was helpful, thank you!