Unable to run snap, because of home directory


So I have a setup where my home directory is not in /home, but there’s a symlink from /home to it. This naturally clashes with snap. I tried binding the directory to /home, but because there’s a symlink already, I went with /home/username.bind, and set $HOME and $XAUTHORITY accordingly.

However, when trying to run the app, it’s still trying to use my home directory. Where’s that coming from?

cannot create user data directory: /home/r/snap/visualboyadvance-m/2: Not a directory

I also added the actual path to apparmor’s tunables’ home paths, and snap-confine, and ran apparmor_parser, but that didn’t seem to help.

How can I resolve the situation? Does it work if I change the bind mount to /home/r instead of /home/r.bind?

The apparmor rules explicitly use the home directory as provided by /etc/passwd. As you’ve discovered it cannot follow symlinks. You either need to mount your home folder directly to the path as provided in /etc/passwd, or ensure to bind mount it to that location if it’s mounted elsewhere.

There’s also a tunable parameter for accounting for obscure home folder locations, because the default rules expect the home folders to live under /home. I forget the name of it right now, but maybe a snapd person can pop in and remind me. The usual use for that tunable is to account for network mounted home folders that include a domain name, e.g. /home/domain.example.com/username.

this is described at the wiki (and actually older than snaps or snapd)

but it wont change the bit about symlinks … you still need bind mounts over symlinks in either case …

Okay, thanks. Using a bind mount helps. The application runs, but then it crashes because it can’t find GPU drivers. Seems like a fun way to distribute stuff, this snap…

Also be sure your snap have access to something else than /home
by connecting them to the removable-media interface.

You wouldn’t need to face those AppArmor things and limitations about symlinks if you only moved the /home/$USER/{usual_folders} to another location ( instead of moving the whole /home or /home/$USER folder )

See Symlinked $HOME break snaps Ubuntu 20.04 (Solved) as an example.

@lucyllewy and @ogra : I don’t understand why you advice such complicated things when there are easier and simpler ways to achieve a good result without modifying the root tree of system ?
Just keep /home/$USER at its usual place in the / tree, but move parts of its content elsewhere and symlink or bind those. Or is this something that may get impossible to do later ?

$ snap info visualboyadvance-m
name:      visualboyadvance-m
summary:   VisualBoyAdvance-M - Game Boy Advance Emulator.
publisher: Zach Bacon (wowzaman12)
store-url: https://snapcraft.io/visualboyadvance-m
contact:   zachbacon@vba-m.com
license:   GPL-2.0+
description: |
  Our goal is to improve upon VisualBoyAdvance by integrating the best features from the various
  builds floating around.
snap-id: F2IxIH5kpnrGg9hMq4eFeT0CcESOs6CS
  latest/stable:    –                                     
  latest/candidate: –                                     
  latest/beta:      2.1.4           2019-12-18   (2) 70MB -
  latest/edge:      2.1.4-ge55ed5c0 2021-02-27 (280) 75MB -

You get what you ask for… seems this snap has not yet had a stable release …

as you can see above there is a contact: field to contact the packager …

If you’ve moved your home folder and replaced it with a symlink then I’d argue that the things we’ve indicated are no more complicated than you’ve already imposed upon yourself by doing non-standard things.

1 Like

Yep. It was trying to access /snap/visualboyadvance-m/2/gnome-platform/usr/lib/x86_64-linux-gnu/dri, but gnome-platform is empty. So I unsquashed the snap, edited the desktop-launch file, replacing $SNAP_DESKTOP_RUNTIME with $SNAP, re-squashed it and now it has GPU driver access. :stuck_out_tongue: That did introduce some error messages about locales, but those aren’t critical, so…

1 Like

this is pretty creative … but you should really tell the developer about it so it can be fixed for everyone :slight_smile:

I did not move my /home folder - that’s precisely the point.

My root / tree is absolutely standard including /home and each /home/$USER - that’s precisely the point and why snaps are happy in the systems and offices I manage.

Only visible and personally created data have been moved elsewhere {Desktop, Documents, Downloads, Pictures, Public, Templates, Videos} except for the {snap} folder which stays at its expected place under each /home/$USER

Then no need to taint any AppArmor config’ - just be sure your snap have been connected to removable-media interface ( which tends to be the default for many of them ).

And it’s precisely because of snap I ended up organizing data this way in many places since snap, well, follows standards by expecting /home/$USER in / which is clean. In the long run it’s much easier to manage than a whole /home folder outside of /.

Plus the benefit of having all personally created ( human ) data out of system because those are the most valuable data : most of the time a system can be fixed or at worst re-installed, loss of « personal » data can’t be.

So what’s more or less standard ?

And yes « If you’ve [already ] moved your home folder and replaced it with a symlink » then setting AppArmor accordingly is probably easier than re-organizing your whole data.
But first thing first : just don’t move the whole /home folder. Just move some of the data from /home/$USER/… and you’ll be safer.

I didn’t say you did. You came into another person’s thread and started complaining that what we were telling the other person was “complicated”. I argued that they’ve made it complicated because of the way they’ve set up their system. None of this was pointed at you, because this isn’t your thread.

Not my thread and hence fwiw the piece of advice while using snap : first, don’t move the whole /home folder… to avoid dealing with AppArmor and keeping things as close as possible to defaults / standard situation.

I am suggesting another « approach ». And asking if that « approach » is future-proof. That’s all. If you read that as a complain, it’s sad but not my fault.

but now the whole home folder is moved already and we were helping with exactly this setup.

it is nice that you point out that it might have been easier with a different setup in the first place but that does not change the fact that this specific setup is different and it is possible to make it work for the user without changing the whole system design …

the question was simply not “how do i set up my home anew” but “how do i get snaps working with my existing setup” … and this is solved above …

… feel free to write a tutorial for the other question

More or less done in the provided link above ( but that’s certainly not the best place nor the best « shape » for a tuto ).

Yes and yes ! I’m sorry you read all that as me saying you did not help. You both did help !
I was only surprised you did not mention maybe an alternative method, or something like a « note for your next installation ». Questions about snap and separate or alternative /home are quite common, because many users go out of expected « standards » regarding /home, knowingly or not.