Skip to content
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

"Shared cache miss" error while building project on different filesystem to my home directory, using developer preview #10974

Open
gridbugs opened this issue Sep 30, 2024 · 3 comments

Comments

@gridbugs
Copy link
Collaborator

While building the simple project described in the package management tutorial I get the following errors:

$ dune build
Shared cache miss [ade1dd90443baf5da8fdfbfdbb361da2] (_build/_fetch/checksum/sha256=79f2a1a5044a91350a0eb6ce12e261a72a2855c094c425cddf3860e58c486678/file): error: Unix.Unix_error(Unix.EXDEV, "link", "_build/_fetch/checksum/sha256=79f2a1a5044a91350a0eb6ce12e261a72a2855c094c425cddf3860e58c486678/file")
Shared cache miss [5d92998893da295b6f15bd934562286c] (_build/_fetch/checksum/sha256=48554abfd530fcdaa08f23f801b699e4f74c320ddf7d0bd56b0e8c24e55fc911/dir): error: Unix.Unix_error(Unix.EXDEV, "link", "_build/_fetch/checksum/sha256=48554abfd530fcdaa08f23f801b699e4f74c320ddf7d0bd56b0e8c24e55fc911/dir/.depend")
Shared cache miss [58d11cdd53fe9843bb800519a28cebb7] (_build/_private/default/.pkg/ocaml-base-compiler/source): error: Unix.Unix_error(Unix.EXDEV, "link", "_build/_private/default/.pkg/ocaml-base-compiler/source/.depend")
 Downloading ocaml-base-compiler.5.2.0
    Building ocaml-base-compiler.5.2.0
Shared cache miss [ede1c66e2f3dfb926f5192964f292058] (_build/_fetch/checksum/sha256=a9ad8d84a08961159653a978db92d10f694510182b206cacb96d5c9f63b5121e/file): error: Unix.Unix_error(Unix.EXDEV, "link", "_build/_fetch/checksum/sha256=a9ad8d84a08961159653a978db92d10f694510182b206cacb96d5c9f63b5121e/file")
Shared cache miss [a0373f043fbd093a22168f4ce761b26d] (_build/_fetch/checksum/sha256=6e4fd93f4cce6bad0ed3c08afd0248dbe7d7817109281de6294e5b5ef5597051/file): error: Unix.Unix_error(Unix.EXDEV, "link", "_build/_fetch/checksum/sha256=6e4fd93f4cce6bad0ed3c08afd0248dbe7d7817109281de6294e5b5ef5597051/file")
    Building ocaml-config.3

Despite these errors the build completed successfully, so I guess it failed to use the cached files and just downloaded and built them again.

This was when building a project inside /tmp, which is a different filesystem to my home directory (where the dune cache is stored). I don't get this error when building a project inside my home directory so I suspect the way that dune symlinks cache entries into projects doesn't work across filesystem boundaries.

My dune is:

 $ dune --version
"Dune Developer Preview: build 2024-09-30T01:30:29+00:00, git revision
9f3cda70d29982105171e1435bf4caafce07866d"

I'm on nixos.

@nojb
Copy link
Collaborator

nojb commented Sep 30, 2024

The shared dune cache uses hard links by default, which do not work across file systems. You can use file copies instead (less performant) by setting (cache-storage-mode copy) in your Dune config file.

@gridbugs
Copy link
Collaborator Author

Good to know. I wonder how hard it would be for dune to detect when the project and cache are on different filesystems and adjust its behaviour accordingly, or at least not attempt to use the cache (or print a more meaningful error message).

@Leonidas-from-XIV
Copy link
Collaborator

I think the only good way is to attempt to create a hardlink and see if it fails:

$ ln dune.exe /tmp/dune.exe
ln: failed to create hard link '/tmp/dune.exe' => 'dune.exe': Invalid cross-device link

Which I guess is exactly the Unix.Unix_error(Unix.EXDEV, "link", ...) error from the report. Maybe the cache should then just transparently switch to copying?

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

No branches or pull requests

3 participants