Skip to content

Git dependency with parent file dependency #473

@endocrimes

Description

@endocrimes

👋

I'm trying to build a project that depends on generated bindings for a WIT world (https://github.com/fermyon/spin/blob/main/crates/world/src/lib.rs).

When building with cargo build, things work as expected and everything compiles correctly

When building with crane in a nix-flake however, the build fails with:

error: failed to read file "/nix/store/hivcpp5isdhmzzgj0q7920axnq7fq3xq-vendor-carg....
       Caused by:
           No such file or directory (os error 2)
  --> /nix/store/hivcpp5isdhmzzgj0q7920axnq7fq....
    |
3  | / wasmtime::component::bindgen!({
4  | |     inline: r#"
5  | |     package fermyon:runtime
6  | |     world host {
...  |
12 | |     async: true
13 | | });
   | |__^
   |
   = note: this error originates in the macro `wasmtime::component::bindgen` (in Nightly builds, run with -Z macro-backtrace for more info)

Although you can apply a custom source filter to your own packages, i.e:

    witFilter = path: _type: builtins.match ".*wit$" path != null;
    witOrCargo = path: type:
      (witFilter path type) || (craneLib.filterCargoSources path type);

    commonArgs = {
      src = pkgs.lib.cleanSourceWith {
        src = craneLib.path ./.;
        filter = witOrCargo;
      };

I haven't been able to find an (obvious) way to apply custom source filtering to the git dependency (and I'm not really a rustacean, so I'm unsure if there's something I'm missing that could be passed to cargo to ensure this works consistently).

I'd appreciate any pointers 😅

Reproduction example: https://github.com/endocrimes/crane-build-error-example

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions