PATH should be adjusted for the snap when using `snap run --shell`
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
snapd |
Triaged
|
Low
|
Unassigned |
Bug Description
It's difficult to debug snaps if the $PATH doesn't adjust to what I would expect for the purposes of running binaries in the snap. For example, when debugging the MAAS snap:
$ sudo snap run --shell maas
# maas-region --help
bash: maas-region: command not found
# /snap/maas/
/usr/bin/env: 'python3': No such file or directory
It's pretty clear that the main reason for this is the $PATH isn't
updated to include bin/ directories internal to the snap (though shared
library paths may be incorrect too); when I use `snap run --shell` I
don't see any directories such as the following included:
/snap/
I'm testing this on my old Xenial machine, so I'm not sure if it's
something that has been fixed in a more recent version of snapd.
$ snap --version
snap 2.33.1
snapd 2.33.1
series 16
ubuntu 16.04
kernel 4.4.0-128-generic
The problem with this is snapd makes no assumptions about paths in the snaps, snaps can have arbitrary structure of the filesystem; apps in the snaps work by providing exact paths to their binaries in the apps definitions (or having a wrapper script inside the snap). We could maybe blindly add bin and sbin of the snap to the PATH, but that's probably it, so I'm not sure it's of much value (and with whatever we do wrt `snap run`, snap-confine would need to be taught to accept).