Summary: environment-generators inherit environment that /sbin/init
started with, but no other systemd defaults. Therefore, there is no
easy way to append to an environment variable that is not set as snapd
was hoping to do. The only solution currently is to copy the expected
"default path" into the snapd environment-generator.
Long winded comment following.
I've attached an example environment-generator above, and then with it
installed and a 'print-path.service', we can see that the proposed solution in https://github.com/snapcore/snapd/pull/5808 does not work.
Summary: environment- generators inherit environment that /sbin/init generator.
started with, but no other systemd defaults. Therefore, there is no
easy way to append to an environment variable that is not set as snapd
was hoping to do. The only solution currently is to copy the expected
"default path" into the snapd environment-
Long winded comment following.
I've attached an example environment- generator above, and then with it path.service' , we can see that the proposed solution in /github. com/snapcore/ snapd/pull/ 5808 does not work.
installed and a 'print-
https:/
To quote xnox from https:/ /bugs.launchpad .net/cloud- init/+bug/ 1771382
"Systemd by default executes things, with execv, not execve. Hence the default environment is not available."
Here is some output collected from the 4 MODE values in a container, followed by in a kvm guest booted with an initramfs.
In both cases there are no other environment generators enabled.
The inherited PATH is as follows: /usr/sbin: /bin:/usr/ bin:/snapd/ bin
initramfs boot: PATH=/sbin:
lxd container: PATH=None # not present
----- container -----
$ lxc exec c3 -- cat /run/path- generator- test.log PATH:/snapd/ bin' /snapd/ bin
current PATH=None
mode=append-ref
writing 'PATH=$
=== printing ===
found PATH=$PATH:
$ lxc exec c3 -- cat /run/path- generator- test.log
current PATH=None
mode=append-full
writing 'PATH=:/snapd/bin'
=== printing ===
found PATH=:/snapd/bin
$ lxc exec c3 -- cat /run/path- generator- test.log local/sbin: /usr/local/ bin:/usr/ sbin:/usr/ bin:/sbin: /bin
current PATH=None
mode=none
writing ''
=== printing ===
found PATH=/usr/
$ lxc exec c3 -- cat /run/path- generator- test.log
current PATH=None
mode=snapd-only
writing 'PATH=/snap/bin'
=== printing ===
found PATH=/snap/bin
------ kvm guest ----- generator- test.log /usr/sbin: /bin:/usr/ bin PATH:/snapd/ bin' /snapd/ bin
$ cat /run/path-
current PATH=/sbin:
mode=append-ref
writing 'PATH=$
=== printing ===
found PATH=$PATH:
$ cat /run/path- generator- test.log /usr/sbin: /bin:/usr/ bin sbin:/usr/ sbin:/bin: /usr/bin: /snapd/ bin' /usr/sbin: /bin:/usr/ bin:/snapd/ bin
current PATH=/sbin:
mode=append-full
writing 'PATH=/
=== printing ===
found PATH=/sbin:
$ cat /run/path- generator- test.log /usr/sbin: /bin:/usr/ bin
current PATH=/sbin:
mode=snapd-only
writing 'PATH=/snap/bin'
=== printing ===
found PATH=/snap/bin
$ cat /run/path- generator- test.log /usr/sbin: /bin:/usr/ bin
current PATH=/sbin:
mode=snapd-only
writing 'PATH=/snap/bin'
=== printing ===
found PATH=/snap/bin