crane icon indicating copy to clipboard operation
crane copied to clipboard

`buildDepsOnly` fails when crate has no main.rs / lib.rs

Open OliverNChalk opened this issue 9 months ago • 1 comments

Describe the bug

I'm setting up a flake.nix to build a workspace which contains many crates, some of which only contain tests/ and no main.rs or lib.rs. It appears makeDummySrc fails to copy tests/*.rs across. I do see some reference to tests in makeDummySrc:

        ${safeStubList "test" "tests"}

Reproduction

If you would expect this use case to work (tests/*.rs) copied to buildDepsOnly's dummySrc directory, then I can amend this issue with a minimal repro in ~10 hours (my morning). Else if this is known to be an unsupported use case, let me know if you recommend:

  • Opening a PR against crane.
  • Working around with extraDummyScript.
  • Something else.

OliverNChalk avatar Mar 20 '25 21:03 OliverNChalk

Hi @OliverNChalk thanks for the report!

This looks like a gap in our implementation: tests (and examples and benches) are detected if they are declared in Cargo.toml but we're missing the equivalent logic to auto-discover existing ones

I'll try to find the time to implement a fix for it, but feel free to take a shot at it if you'd like

ipetkov avatar Apr 04 '25 02:04 ipetkov