ocaml / ocaml/dune

Cache doesn't work on `opam install`

Open
#6,162 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

shared-cache
Dominant language
OCaml
Stars
1.9k
Forks
500
Avg merge
15h 21m
Merged PRs (30d)
277

Description

Expected Behavior

Enabling the dune cache would allow speedup for (re)building packages when (re)installing them via OPAM.

Actual Behavior

The cache folders are created, but no files are getting cached.

Reproduction

  1. export DUNE_CACHE=enabled
  2. export XDG_CACHE_HOME=$(pwd)/dune-cache
  3. opam install some_packages that_use_dune
  4. tree $XDG_CACHE_HOME
  5. Note that the folders were created but no files

As we debugged with @emillon this is due to the OPAM sandbox bind-mounting the cache folder inside the sandbox, so even on the same file system the cache files can't be hardlinked.

A possible workaround is export DUNE_CACHE_STORAGE_MODE=copy and it does populate the cache with files, but it could be useful to detect this case and find a solution for it.

Specifications

  • Version of dune (output of dune --version): 3.4.1
  • Version of ocaml (output of ocamlc --version) 4.14.0
  • Operating system (distribution and version): Fedora Linux 36

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with DUNE_CACHE enabled, XDG_CACHE_HOME set, and an opam install, then inspect how Dune handles the cache when the OPAM sandbox bind-mounts it. Compare the default hardlink behavior with DUNE_CACHE_STORAGE_MODE=copy; done means cache files are stored successfully during opam installs without requiring the workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.