How can I customize snapd

Hi. I am facing a problem that seems to require some customization of snapd.

I am using a non standard home directory path, and I know snap does not work with it.

I looked for documentation on snapd customization, but I couldn’t find any.
All I found was docs for the snap command.

There is some mention on the environment variable which points to the writable directory for snap under the users home directory, but I understand that that variable is set by snap for snap applications to read from, rather than the user to inform snap where the writable directory is.

Where, if any, are docs for snapd?

Hello!

There are some options on how one can work with non-default home directories.

  1. You can use bind-mounts to use any location appear in the standard /home/user directory. This is the easiest and quickest way to get things to work. You can edit your /etc/fstab to create the bind mount automatically. See man page for mount(8) and fstab(5) for details.

  2. You can customize your site apparmor configuration to tell apparmor about additional home directory paths. This is a required but not sufficient step if you choose not to use the bind mount. On ubuntu you should look at /etc/apparmor.d/tunables/home which has instructions to follow. After making any changes restart your machine (there are other ways but this is the simplest) to see them take effect.

As for your original question, snapd is not that easy to customize because it is centrally delivered from the core snap. Your best bet is to work upstream to support wider variety of home directory locations and then track the edge channel of the core snap to see those changes in action.

1 Like

Thanks for the tip!

I tried using a bind mount as you suggested.
My home directory can now be seen as /home/$USER.
However, snap does not seem to be looking at that mounted directory.
Instead it still complains as follows:

% snap install hello
hello 2.10 from 'canonical' installed
% snap run hello
cannot create user data directory: /data1/home/hideo-t/snap/hello/20: Read-only file system

I think I need to somehow tell snap to look at my mounted directory as home.

Any suggestions would be appreciated!

Having done the bind mount you need to edit your user profile to restore the regular location of your home directory. You can edit /etc/passwd or use one of the various graphical tools for doing that. Log out and log in and you should be good.

Okay, I expect that would work since it would relocate my home directory by all means.

But that would impact existing settings on config files for various apps I already have, so I’d like to find a way where I don’t have to relocate my home directory.

Thank you anyway!

This is also being discussed here: How can I use snap when I don't use /home/$USER?