The shared cache misses when the build directory is named by its absolute path
Nobody has claimed this yet.
- #16074 by @copilot-swe-agent — closed without merging
- Dominant language
- OCaml
- Stars
- 1.9k
- Forks
- 500
- Avg merge
- 15h 21m
- Merged PRs (30d)
- 277
Description
Expected Behavior
_build and $PWD/_build name the same directory, so an entry the shared cache stored under one spelling is restored under the other.
Actual Behavior
The action runs again: the two spellings key the same workspace twice and get separate cache namespaces.
Reproduction
mkdir -p /tmp/dune-bd && cd /tmp/dune-bd
export DUNE_CACHE=enabled DUNE_CACHE_ROOT=/tmp/dune-bd-cache
echo '(lang dune 3.24)' > dune-project
printf '(rule (deps source) (targets target)\n (action (system "cat source > target")))\n' > dune
echo hello > source
dune build --display=short target # runs the action: "sh target"
rm -rf _build
dune build --display=short target # cache hit: prints nothing
rm -rf _build
DUNE_BUILD_DIR=$PWD/_build dune build --display=short target # prints "sh target" again
The third command should print nothing, like the second one. --build-dir=$PWD/_build behaves the same as DUNE_BUILD_DIR.
Specifications
- Version of
dune: 3.24.2-1011-g7b0f4fb (mainat 7b0f4fbd98, bootstrapped) - Version of
ocaml: 5.4.1 - Operating system: macOS 27.0, arm64
Additional information
The build directory is recorded exactly as named (Path.Build.set_build_dir in bin/common.ml:1252), and every rule renders its targets and dependencies from it, so the spelling reaches the rule digest (the sandbox path under --verbose differs between the two spellings). Recording a build directory that sits directly under the workspace root by its relative name turns the third command into a cache hit; I have that patch and a blackbox test and can open a PR.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Path.Build.set_build_dir in bin/common.ml:1252 and trace how the build-directory spelling reaches rule digests and cache keys. Use the reproduction to compare relative and absolute build-directory forms, then add or run the blackbox test mentioned in the issue. Done means the absolute-path command restores the existing shared-cache entry without rerunning the action.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100