← Back to issue list

Charmcraft snap thinks `/cache` is the cache directory if snapd doesn't set `SNAP_USER_COMMON`

View original Github issue

Metadata

Project
charmcraft
Number
#2012
Type
issue
State
open
Author
lengau
Labels
Created
2024-12-03 16:20:48+00:00
Updated
2025-08-15 15:18:03+00:00
Closed

Current evaluation

No evaluation has been recorded for this issue yet.

Issue body

### Bug Description If snapd [fails to set `$SNAP_USER_COMMON](https://bugs.launchpad.net/snapd/+bug/2090938) in the environment, charmcraft gets `/cache` as its [`$XDG_CACHE_HOME`](https://github.com/canonical/charmcraft/blob/c13f20ae65b6a4d3657dcdd30b2f606ccae86163/snap/snapcraft.yaml#L63), which is generally not writable. Related: - https://bugs.launchpad.net/snapd/+bug/2090938 - https://github.com/canonical/operator-workflows/issues/496 ### To Reproduce With snapd 2.66.1: ``` 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 ``` ### Environment ``` $ snap version snap 2.66.1+25.04 snapd 2.66.1+25.04 series 16 ubuntu 25.04 kernel 6.11.0-9-generic ``` ### charmcraft.yaml ```yaml n/a ``` ### Relevant log output ```shell See: https://github.com/canonical/k8s-operator/actions/runs/12143320826/job/33859924966 ```

Evaluation history

No evaluation history available.