Skip to content

Toolchain cache: use DUNE_CACHE_ROOT instead of XDG_CACHE_HOME #11612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ElectreAAS
Copy link
Collaborator

Fixes #11584 and should ease the pain of #11585.

The cache is set up to be at $DUNE_CACHE_ROOT, which itself will default on $XDG_CACHE_HOME if not present. Two places skipped one step and use the XDG directly: the toolchain cache and the rev-store cache. This PR fixes both of these.

@ElectreAAS ElectreAAS requested review from gridbugs and emillon April 7, 2025 12:36
@@ -21,7 +21,7 @@ val is_compiler_and_toolchains_enabled : Package.Name.t -> bool

(** Returns the path to the directory containing the given package within the
toolchain directory. This will be something like
$XDG_CACHE_DIR/dune/toolchains/ocaml-base-compiler.5.2.1.XXXXXXXX where
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this was a typo, it's XDG_CACHE_HOME, not DIR

(Path.of_string (Xdg.cache_dir (Lazy.force Dune_util.xdg)))
[ "dune"; "git-repo" ]
in
let dir = Path.L.relative Dune_cache_storage.Layout.root_dir [ "dune"; "git-repo" ] in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Dune_cache_storage.Layout.root_dir return the contents of $XDG_CACHE_HOME (or similar) if $DUNE_CACHE_ROOT is not set?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it calls Xdg.cache_dir which is set from the env var

Copy link
Collaborator

@Leonidas-from-XIV Leonidas-from-XIV Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not adding one layer of dune too much? I would expect it to return ~/.cache/dune if the directory was not set thus it would be ~/.cache/dune/dune/git-repo in the case where DUNE_CACHE_ROOT is not set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Toolchains cache does not follow DUNE_CACHE_ROOT
4 participants