Charmcraft snap thinks `/cache` is the cache directory if snapd doesn't set `SNAP_USER_COMMON`
Metadata
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.