Skip to content

Commit

Permalink
fix: use the same cache directory in providers (#2046)
Browse files Browse the repository at this point in the history
Without this, the snap's XDG_CACHE_DIR environment variable will override the use of /root/.cache for caching in a provider. Work around this by just making them the same directory.

Fixes #1993

CRAFT-3698
  • Loading branch information
lengau authored Dec 17, 2024
1 parent 7fa2064 commit 73a7996
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions charmcraft/services/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ def instance(
**kwargs, # type: ignore[arg-type]
) as instance:
try:
# Use /root/.cache even if we're in the snap.
instance.execute_run(
["rm", "-rf", "/root/snap/charmcraft/common/cache"]
)
instance.execute_run(
["ln", "-s", "/root/.cache", "/root/snap/charmcraft/common/cache"]
)
yield instance
finally:
if fcntl is not None and self._lock:
Expand Down

0 comments on commit 73a7996

Please sign in to comment.