Permission denied error when running apps installed as snap packages - Ubuntu 17.04

62,555

Solution 1

Same happens in Ubuntu 18.04.

If the user home directory is not under the /home (or /) mount, it not possible to work with snap. My HOMEDIR was on another local SSD disk, but since it was not mounted under /home, every package installed by snap was failing.

Since Canonical is moving to support snap, you will have to loose this kind of nice things, such as HOMEDIRs on other file systems, mounted by NFS, etc.

Maybe snap will be more flexible inthe future, but it is not a priority: https://forum.snapcraft.io/t/how-can-i-use-snap-when-i-dont-use-home-user/3352/6

The workaround right now is to remove snap and install things from *.tar.gz or from *.deb packages.

Solution 2

I ran into this because my home directory is symlinked from /home/$USER to another mount point. I fixed it with the suggestion from when /home is somewhere else, snaps don't work.

In short, you need to add your non-standard home directory to apparmor's HOMEDIRS variable:

$ sudo dpkg-reconfigure apparmor

or: create a file in /etc/apparmor.d/tunables/home.d/ that points to your home directory's mount point:

@{HOMEDIRS}+=/mnt/hdd/.home/

Then, just for good measure, you should delete apparmor's cache and reboot:

$ sudo rm -f /etc/apparmor.d/cache/* /var/cache/apparmor/snap.*
$ sudo reboot

Solution 3

You can set the permissions of the Snap Application from the Software Store.

The following steps are tested on Ubuntu 20.04 LTS:

  • Open Software
  • Select the Installed tab. A list of installed software will appear.
  • Select the snap package which needs elevated permissions.
  • On the detailed view, click the 'Permissions' button.
  • Click on the toggle next to 'Read/write files on removable storage devices'.

This method works for mounted harddisks.

References:

Solution 4

Snap apps are confined to a sandbox by default, for security. If you want snap applications to be able to read/write data in your home directory, you should install them in classic mode. Try:

rclone install --classic vlc

This should work for you.

If application sandboxing is a concern, then you might want to look into firejail.

Share:
62,555

Related videos on Youtube

Tom Cumming
Author by

Tom Cumming

Updated on September 18, 2022

Comments

  • Tom Cumming
    Tom Cumming over 1 year

    I get Permission denied error when running a snap application, where my home directory is mounted on an nfs mount point that does not allow root-write. This is not an unusual configuration, so I consider this a bug.

    The error message:

    cannot create user data directory: /home/tcumming/snap/vlc/4: Permission denied
    

    Also had the same problem with ubuntu 16.

    Some more info as requested:

    Using the ubuntu, "Ubuntu Software" I install a snap application (for example, vlc). When I attempt to run it (from the command line), I get the, "Permission denied" message above.

    I had just reinstalled Ubuntu on the machine, so there has been no messing around with the OS. I did preserve my uid:gid so I could mount my prior nfs share.

    This is not a problem with the mount point, or nfs. Our mount point is not root-writeable for security reasons.

    I guess the question is, should I file a bug report? What are my next steps?

  • Ligemer
    Ligemer about 6 years
    So far snap = worst idea ever. Too soon :-p
  • Sebastian Stark
    Sebastian Stark almost 6 years
    This is really sad and close to a showstopper, especially for huge deployments where $HOME resides on NFS or CIFS shares mounted via autofs-ldap.
  • Dean
    Dean almost 6 years
    "Since Canonical is moving to support snap, you will have to loose this kind of nice things, such as HOMEDIRs on other file systems, mounted by NFS, etc." I don't think canonical is going to convince people running Ubuntu in commercial/business environments to stop using centralised network mounted home directories in favor of local ones just so they can use "snap packages"...
  • SYK
    SYK over 5 years
    SSD/HD PCs are all too common nowadays. Many (but not all!) of my /snap/bin/ commands would fail with the misleading "permission denied" error with the input files and the problem could not be resolved by messing with file permissions but by removing the /snap/ package and re-installing them with apt! (Ubuntu 18.04)
  • SeveQ
    SeveQ over 5 years
    This question, or its cause, is totally underrated in my book. It can't be low priority that things don't work for a major part of the userbase.
  • Kevin Bowen
    Kevin Bowen over 5 years
    Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
  • Anton Zaviyalov
    Anton Zaviyalov about 4 years
    Also works for non-standard home locations (w/o symlinks) like /home/DOMAIN/user
  • polynomial_donut
    polynomial_donut about 4 years
    didn't work for me...
  • Anthon
    Anthon over 3 years
    I am here Sep 2020, after installing the youtube-dl snap on Ubuntu Budgie 20.04. The youtube-dl .deb was out of date to start with and snap still refuses to write on the data directory (not under /home) I worked around this with a function for now, but I will change to a virtualenv and pip install with a regular update on the first sign of further problems (or revert to Solus which has an up-to-date youtube-dl package).