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

candle-kernels fails to build in Nix due to read-only sources #2453

Open
gmacon opened this issue Aug 28, 2024 · 2 comments
Open

candle-kernels fails to build in Nix due to read-only sources #2453

gmacon opened this issue Aug 28, 2024 · 2 comments

Comments

@gmacon
Copy link

gmacon commented Aug 28, 2024

In Nix, builds are isolated and have limited network access. The built artifacts are written into a read-only location known as the "store". It's common to build Rust applications using Crane which invokes cargo build with a cargo cache directory filled with symlinks into the store. This means that when the build script is run, the sources are read-only. The current build.rs in candle-kernels specifies that src/lib.rs, which is read-only in my application, be overwritten by bindgen_cuda. This behavior is discouraged by the Cargo book. They instead recommend a pattern where the generated code is written to the build script output directory ($OUT_DIR) and then include!d into the library. I think you should implement this pattern.

I also opened Narsil/bindgen_cuda#10 requesting that bindgen_cuda change their documentation to avoid having future consumers fall into this same anti-pattern.

@ahirner
Copy link

ahirner commented Sep 14, 2024

Can you share your (crane) nix expression?

@gmacon
Copy link
Author

gmacon commented Sep 16, 2024

This isn't necessarily the smallest possible reproducer, but it's a reasonably small diff of non-generated files from the Crane quick-start-simple template: https://github.com/gmacon/candle-build-failure-reproducer.

To reproduce: nix build. The failing derivation is /nix/store/hccbv08gly4xpc00a0fbkwx98yqm8ygs-quick-start-simple-deps-0.1.0.drv.

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

No branches or pull requests

2 participants