How can I use snap when I don't use /home/$USER?

I think the reason is that snap-confine contains hard-coded logic that bind mounts /home into the execution environment. We could take the more generalized @{HOMEDIRS}/ rule but we would not automatically bind mount, for example /foo/bar.

Right, I forgot about that aspect of this and you and @jamesh are right. I did this successfully on a system, but that system happened to have a symlink from /home to /other/location, so it (accidentally) worked with my suggested changes. I think the logic that would detect if we should modify @{HOMEDIRS} would also need to flag snap-confine to mount that alternate directory.

At this point, the only course of action would be to bind mount /foo/bar on /home, as @zyga-snapd suggested elsewhere.

2 Likes

I tried the bind mount approach as suggested, and it worked fine as expected.

I’ll try out for a while to see if my existing settings don’t break too bad.

Thanks!

1 Like

Would someone be able to summarize what to do exactly? I am having the same issue, followed @jdstrand’s steps but I am still having the same problem.

@hideo67 Did you successfully fix the problem?

Thanks!

The idea suggested is to bind mount the home directory currently elsewhere under /home so that snaps can find it in the usual place.

We can eventually support other home locations, but that’s not a high priority at the moment since it’s infrequently necessary and easy to workaround with a bind mount.

Hi,

I used a bind mount, and changed /etc/passwd to relocate my home directory to its usual place.

It was easy to make snap work, the cost I had to pay was reconfigure a bunch of CMake C++ projects source directories that were inside my home directory. It took a couple of hours, but was bearable for me.

This worked for me.

snap 2.32.9+18.04
snapd 2.32.9+18.04
series 16
ubuntu 18.04
kernel 4.15.0-22-generic

App: Mattermost and onlyofficedesktopeditors

Thanks.

@hideo67 please explain clearly. Stucked with same issue. It will be helpful for me. Thanks in advance

Hi there,

I tried all this, but Snap is still telling

cannot create user data directory: /media/daten/home/robert/snap/spotify/16: Permission denied

What to do know?

 snap --version
snap    2.34.3
snapd   2.34.3
series  16
ubuntu  18.04
kernel  4.15.0-32-generic

Hi. Here is what you need to do.

Your home directory must actually be /home/$USER
You need to do whatever necessary to make your home directory located in that place.

I used to have my home directory on a place /data1/home/hideo.
I done that to use a second SSD drive with bigger free space.
I made that directory look like /home/hideo to the operating system.

Here is what I did:

Step 1. I added the following line on /etc/fstab

/data1/home /home none bind

This will cause a “bind mount”.

After a reboot, my home directory is visible in 2 locations, the original /data1/home/hideo and /home/hideo

Now, I need to actually make my home directory to be /home/hideo.

Step 2. For that, I edited /etc/passwd and searched for my entry, changed the home directory location from /data1/home/hideo to /home/hideo

Then, logout and login again. Now my home directory is /home/hideo.

And snap works.

I had a bunch of files in my home directory that contained absolute path names within that home directory.
I deleted them all and recreated them.

To conclude, as far as I know, you cannot keep your home directory at someplace other than /home/$USER. You have to actually move your home directory location to the standard place.

Hope this is clear enough.

Cheers.

I attempted to work around this issue as suggested with a bind mount line in /etc/fstab linking /home/user to a directory on a separate ext4 partition that is itself mounted at /mnt/files:

Here are lines from fstab:

UUID=465bfd74-ce84-4fbe-9af4-8b2d88768352 /mnt/files ext4 defaults
/mnt/files/bionic/home/user /home/user none bind

I discovered that this stops Gnome trash from being able to move any files to trash in directories on /mnt/files (Ubuntu 18.04). It will present a dialog saying the file cannot be put in the rubbish bin, and instead must be deleted immediately.

Testing with gio shows why:

gio trash /mnt/files/testfile
gio: file:///mnt/files/testfile: Unable to delete file /mnt/files/testfile across filesystem boundaries

Any ideas on how to fix?

@zyga-snapd, with all the recent changes for snap-confine and snap-update-ns, can you think of a path forward for this long-standing issue? It would be great if an admin could say something like “I have user directories in /home, /foo and /mnt/bar”. AppArmor supports this fine; we just need to not hardcode snap-confine. Thoughts?

1 Like

Any update on plans to resolve this?

I’ve been transitioning from Windows to Linux for years. I was really excited to learn about Snap. It sounds like a great solution to make programs more universally available. I installed it today so that I could try one of my favourite Windows editors on Linux; Notepad-plus-plus.

Imagine my disappointment when it didn’t work! Due to some issues with my motherboard not being able to boot from my big Samsung 1TB SSD, I’ve got a little bitty 128gb SSD where I installed Linux Mint. I use Dropbox to store/backup all my programs and media files. It’s huge and it wants to keep the local folder in my home folder. No space for that! no problem, I moved home to /mnt/SSD1TB/home/jgold.

It seems that snap needs the home directory to be in /home/jgold before it will work. This means that Snap doesn’t work for me at all. The solution according to this thread is to make sure your home directory is \home\jgold.

No can do!

I understand that this is a bug and it will be fixed. There are limited resources and you’re volunteers. (I appreciate all the time put into this by the way, It looks like a GREAT idea!). I’m hoping to move the priority to fix this up a little.

There are two reasons I think this should have a higher priority;

  1. Requiring the home directory to be in a specific place is very un-linuxy. It’s looks like someone missed something really basic. It makes Snap look bad.
  2. When someone runs into this issue, they’re basically unable to use Snap at all without making some difficult changes to their system. This is especially difficult for new users or old ignorant users such as myself.

To summarize: I really like the idea of Snap. I’d like to use it. I can’t without a whole lot of extra work that I really don’t want to do. Fixing this issue will make Snap work and look better.

Thanks!

Not with that attitude you can’t! :smiley:

Technically you likely can have /home/jgold just fine, and have it mounting some space on /mnt/SSD1TB but you chose to actually change the path to your home as well as the storage location? I appreciate that it is indeed still somewhat of an oversight / bug that we still rely on $HOME being /home/$USER but in your particular case it is actually possible to do what you’ve done and still comply with the requirements for snaps.

1 Like

You are correct. Or you guys could just fix it so that it works correctly so that new users don’t have to waste a bunch of time figuring out why it doesn’t work when everything else on their system works fine. I wonder which option would be better? :slight_smile:

Thank you for your reply.

5 Likes

Hello. I maintain I fairly large network of Linux machines here at University of Helsinki. I have here more than a thousand users, of whom have multiple different networks shared home directories, which are chosen on login time. Some times the home directory is a also a local home directory instead of a network share. It is really up to the users to decide and not to me. The solution so far has to be to make /home/luser a symlink to where the real home is and this has been fine since symlinks were invented (after all, this is the reason they were invented). And the users need to do their jobs and shouldn’t need to care about paltry problems like this. Now, there is now software which isn’t available on deb packages anymore (heroku) and the only way this is fixable by next week is that I package heroku myself. I need to get this done by this week, so tweaking a University wide system is out of the question. This shouldn’t be something on a wishlist, this is a major showstopper.

3 Likes

Oops. It turns out that heroku has a perfectly adequate deb repository. Its location is just hidden inside a shell script. So, no need to build anything myself and no need make snap work for just this software. Sorry about the rant, but snaps still won’t work in this environment.

This problem is evident when using snap installed lxd on a jenkins box since jenkins home is /var/lib/jenkins by default.

As a workaround for those hitting this with Jenkins, setting JENKINS_HOME to /home/jenkins and adding an entry in fstab to mount /var/lib/jenkins to /home/jenkins did the trick.

3 Likes

Hey guys, do we have a timeline regarding this problem? I’ve stumbled on it, CentOS 7 (corporate environment) and can’t really apply the workaround mentioned here. I’d really like to see it solved.

1 Like