← 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
Updated
Closed

Current evaluation

Charmcraft snap uses unwritable /cache as XDG_CACHE_HOME when snapd fails to set SNAP_USER_COMMON. Listed as a known issue in 3.4 release notes, still unfixed in current code, blocked by upstream snapd bug.

Suggested action: keep open

Reason: The issue is explicitly listed in the 3.4 release notes as a known issue 'scheduled to be fixed in upcoming patch releases', confirming maintainer awareness. The root cause is an upstream snapd bug (LP#2090938) that prevents SNAP_USER_COMMON from being set, and the snapcraft.yaml still contains the unguarded $SNAP_USER_COMMON/cache reference. It should remain open until either snapd is fixed or charmcraft adds a fallback.

Impact: 55 Quick Win: 33.0 Staleness: 60 Complexity: 40 Confidence: 75 Support Request: 5

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

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 55
Quick Win: 33.0
Staleness: 60
Complexity: 40
Confidence: 75
Support Request: 5
keep open Charmcraft snap uses unwritable /cache as XDG_CACHE_HOME when snapd fails to set SNAP_USER_COMMON. Listed as a known issue in 3.4 release notes, still unfixed in current code, blocked by upstream snapd bug.
qwen/qwen3.6-35b-a3b
Staleness: 90
Complexity: 40
Confidence: 75
Support Request: 5
close stale Charmcraft snap defaults to unwritable /cache for XDG_CACHE_HOME when snapd fails to set SNAP_USER_COMMON. Open for ~1.6 years with no maintainer comments or labels.
qwen3.6-35b-a3b-mtp-q6
Staleness: 90
Complexity: 30
Confidence: 80
Support Request: 10
close stale Charmcraft snap defaults to /cache as XDG_CACHE_HOME when snapd omits SNAP_USER_COMMON. Unlabeled, zero comments, inactive for over a year.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 30
Confidence: 75
Support Request: 10
needs triage Charmcraft snap falls back to unwritable /cache for XDG_CACHE_HOME when snapd omits SNAP_USER_COMMON. Unlabelled, no maintainer comments, open for over 1.5 years.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 35
Confidence: 75
Support Request: 10
close stale Charmcraft snap falls back to the unwritable /cache directory for XDG_CACHE_HOME when snapd omits SNAP_USER_COMMON. The issue is open, untriaged, and inactive for over 300 days, awaiting assignment and resolution.

Update history

No update history recorded yet.

Related work

  • Blocked By: snapd#2090938 (confidence 85%)

    Root cause is snapd failing to set SNAP_USER_COMMON in the environment, tracked as LP bug 2090938.

Related issues

No related issues found above the similarity threshold.