6

Trying to use any snap package, I run into following issue:

$ gimp
cannot create user data directory: /local/home/user/snap/gimp/40: Read-only file system

(Gimp is just an example).

I have my $HOME in /local/home/$USER/ (I cannot change this!) and found that people have the same issue on the snap-store forum: https://forum.snapcraft.io/t/how-can-i-use-snap-when-i-dont-use-home-user/3352 and https://bugs.launchpad.net/snapcraft/+bug/1620771

In this thread, people say /home is hard-coded in snap and they suggest to use a bind-mount to solve this.

What I tried:

$ sudo mount --bind $HOME /home/$USER

ls correctly lists the content of my $HOME

$ ls /home/$USER

I also added the additional home dir to /etc/apparmor.d/tunables/home.d/my-homes:

$ cat /etc/apparmor.d/tunables/home.d/my-homes
@{HOMEDIRS}+=/local/home/

and to /var/lib/snapd/apparmor/snap-confine/my-homes:

$ cat /var/lib/snapd/apparmor/snap-confine/my-homes
mount options=(rw rbind) @{HOMEDIRS}/ -> /tmp/snap.rootfs_*/home/,

Running the snap again with bind-mount AND as well as OR changing files, the same error occurs as before.
How can I solve this ?


$ snap list gimp
Name  Version  Rev  Tracking  Developer     Notes
gimp  2.10.0   40   stable    snapcrafters  -

$ snap --version
snap    2.32.9
snapd   2.32.9
series  16
ubuntu  16.04
kernel  4.4.0-127-generic
pLumo
  • 27,991

2 Answers2

1

Snapd from 2.59 onward has a homedirs system option to deal with this issue. To upgrade to a working version you can use command:

snap refresh --channel=latest/edge snapd

I don't even have to set homedirs afterward, but just in case you can use:

snap set system homedirs=/local/home/

nakis
  • 31
-2

snapd developer here

I'm sorry that this is a problem for you, because you didn't give details about the version of snapd you are using (tip, run snap version and paste that here) or the detailed arrangement of what your real home directory is on (it sadly also matters).

I haven't personally tried this myself but you should be good enough with a bind mount like this:

sudo mount --bind /some/random/place/home/zyga /home/zyga

You can make this permanent if you add it to your /etc/fstab file. After this you must also change your home directory to really be in /home/zyga and not in the original location.

If this fails please snap install hello-world and add the output of the following commands:

SNAP_CONFINE_DEBUG=yes hello-world dmesg | grep DENIED

Zygmunt Krynicki
  • 7,599
  • 1
  • 13
  • 8