/etc/environment does not include /snap/bin in $PATH

Bug #1660273 reported by Nobuto Murata
46
This bug affects 7 people
Affects Status Importance Assigned to Milestone
Canonical Juju
Incomplete
Low
Unassigned
Snap Layer
Fix Released
Critical
Unassigned
cloud-images
Invalid
Undecided
Unassigned
snapd
Confirmed
Undecided
Unassigned

Bug Description

/snap/bin is not in the system default path, and is only added to the path for interactive shells.

This means that snaps are not drop in replacements to Debian packages. All references to snapped executables not in interactive shells need to be updated to specify the full /snap/bin PATH, including but not limited to crontabs, systemd service definitions, Juju hook environments, and all applications running under one of these contexts.

A work around is to manually hack /etc/environment , but this is poor as the goal is to get snaps working out of the box.

Changed in juju:
status: New → Triaged
importance: Undecided → High
milestone: none → 2.2.0
Revision history for this message
Tim Penhey (thumper) wrote :

Juju does not alter the PATH of the host except to add the tools directory for unit hook executions.

Changed in juju:
milestone: 2.2.0 → none
status: Triaged → Invalid
Revision history for this message
Anastasia (anastasia-macmood) wrote :

From IRC:

[11:59:52] <stokachu> so xenial server contains /snap/bin in $PATH but the cloud images do not

Revision history for this message
Adam Stokes (adam-stokes) wrote :

Yea it may be worthwhile talking to CPC team about getting that into the image builds

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Yes, we discovered this today the hard way. It was really weird having to set path.

Revision history for this message
Stuart Bishop (stub) wrote :

The snap layer has a workaround for reactive charms (it adjusts the path), leaving just traditional non-reactive actions affected.

Juju will need to adjust the PATH if CPC don't take on this bug, so I'd argue it should not be off the radar with an 'invalid' status.

Changed in layer-snap:
status: New → Fix Released
importance: Undecided → Critical
Revision history for this message
Dan Watkins (oddbloke) wrote :

I've looked at a GCE instance and a LXD container; both of these had /snap/bin in the path. This is configured by /etc/profile.d/apps-bin-path.sh, which is also in the downloadable images for xenial.

I'm not convinced that this is an issue in cloud-images, but I'm happy to be convinced so I'm going to mark this as Incomplete.

(I'll reopen the juju task so that this doesn't get lost.)

Changed in juju:
status: Invalid → New
Changed in cloud-images:
status: New → Incomplete
Revision history for this message
Nobuto Murata (nobuto) wrote :

Just to clarify, I used MAAS provider at that time. It might be MAAS image specific, but I don't have handy MAAS env to confirm atm.

Revision history for this message
Stuart Bishop (stub) wrote :

/etc/profile is for login shells, which explains how jujud and thus the hook environment fails to pick it up.

From what I can tell, /snap/bin needs to be added to the PATH in /etc/environment on all Ubuntu images.

This will also fix similar bugs with cron and other daemons, which also won't have /snap/bin in their PATH.

Changed in cloud-images:
status: Incomplete → New
Revision history for this message
Dan Watkins (oddbloke) wrote :

Looking at a xenial server and a zesty desktop/server, I don't think /etc/environment contains /snap/bin anywhere.

I'm running an ISO install now to confirm.

Revision history for this message
Dan Watkins (oddbloke) wrote :

After installing from mini.iso:

$ cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

so I don't think this is an issue specific to the cloud images; once a fix is introduced to packages in the archive, we should pick it up automatically.

Changed in cloud-images:
status: New → Invalid
summary: - `juju run` does not include /snap/bin in $PATH
+ /etc/environment does not include /snap/bin in $PATH
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

After speaking with the snappy team on IRC, asking for a change to /etc/environment is a big ask, and the idea of modifying it for existing installs also seems haphazard. It seems like sourcing /etc/profile or manually setting PATH is the next best thing, and is a workaround for the time being.

It's recommended to get insight from the Foundations team about other options, if any, that may allow solving this. Do note that /etc/profile is a bashism, as is the fact bash is treating login and non-login shells differently.

Changed in juju:
status: New → Incomplete
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

I'm marking the snapd task as invalid as we have no way to influence the global environment this way. There is a systemd feature that is not universally available yet that might allows us to do this but I also believe that the current approach of /etc/profile.d is as good as we can do it from the POV of our package.

Changed in snapd:
status: New → Invalid
Revision history for this message
Stuart Bishop (stub) wrote :
Revision history for this message
Stuart Bishop (stub) wrote :

Foundations has not responded. How do we target this bug?

Revision history for this message
Stuart Bishop (stub) wrote :

Reopening this for snapd, as the problem still exists. snapd packages can do the hazardous /etc/environment modification, or can coordinate with foundations for next Ubuntu release and backports.

description: updated
Changed in snapd:
status: Invalid → Confirmed
Stuart Bishop (stub)
tags: added: canonical-is
Revision history for this message
Marco Sulla (xdq4gh24rq) wrote :

You can add it in `/etc/profile.d`.

Revision history for this message
Canonical Juju QA Bot (juju-qa-bot) wrote :

This bug has not been updated in 2 years, so we're marking it Low importance. If you believe this is incorrect, please update the importance.

Changed in juju:
importance: High → Low
tags: added: expirebugs-bot
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.