$SNAP_USER_COMMON empty when getent cannot be found in $PATH
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
snapd |
Fix Committed
|
Undecided
|
Unassigned | ||
snapd (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Focal |
Fix Released
|
Undecided
|
Unassigned | ||
Jammy |
Fix Released
|
Undecided
|
Unassigned | ||
Noble |
Fix Released
|
Undecided
|
Unassigned | ||
Oracular |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
[SRU] 2.67.1: https:/
[ Impact ] (Snapd snap only)
* Only affects Snapd snap 2.66.1, that looks up getent from PATH
* Results in failed user lookup, not populating SNAP_USER_COMMON and not creating user home directory
* It is however not a good idea to modify PATH before calling snap, this was encountered in LXD related test case, but less likely in the wild
[ Test Plan ]
One way to reproduce the problem:
1. Use environment using Snapd 2.66.1 snap (to demonstrate issue) and Snapd 2.67.1 snap (in beta) (to demonstrate fix)
2. sudo snap install --classic charmcraft --channel=
3. echo '$SNAP/bin/python -c "from charmcraft import env;
4. print(env.
Before fix: `cmd_run.go:1276: WARNING: cannot create user data directory: cannot get the current user: getent could not be executed: exec: "getent": executable file not found in $PATH`...`
See https:/
After fix: No error
Test Snapd snap only.
---original---
This seems to be a regression when changing how user data directories are built, as it works on Jammy (snapd 2.63+22.
If getent can't be found in $PATH when running a snap, snapd will output a warning:
2024/12/03 15:17:52.136805 cmd_run.go:1276: WARNING: cannot create user data directory: cannot get the current user: getent could not be executed: exec: "getent": executable file not found in $PATH
and then set the SNAP_USER_COMMON environment variable to be empty (or maybe not set it?)
This means that an app that depends on $SNAP_USER_COMMON (e.g. charmcraft: https:/
To reproduce:
sudo snap install --classic charmcraft --channel=
echo '$SNAP/bin/python -c "from charmcraft import env; print(env.
Expected behaviour occurs on jammy: https:/
Actual behaviour on noble: https:/
description: | updated |
summary: |
- $SNAP_USER_COMMON incorrect when getent cannot be found in $PATH + $SNAP_USER_COMMON empty when getent cannot be found in $PATH |
Changed in snapd: | |
milestone: | 2.68 → 2.67.1 |
description: | updated |
description: | updated |
description: | updated |
tags: |
added: verification-done-focal verification-done-jammy verification-done-noble verification-done-oracular removed: verification-needed-focal verification-needed-jammy verification-needed-noble verification-needed-oracular |
This does not appear to break on 25.04 with snapd 2.66.1+25.04:
$ echo '$SNAP/bin/python -c "from charmcraft import env; print(env. get_host_ shared_ cache_path( ))"' | PATH=/snap/bin /usr/bin/snap run --shell charmcraft_2 snap/charmcraft _2/common/ cache/charmcraf t
/home/lengau/