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

cargo doesn't know which to use because multiple target files found #768

Closed
dj95 opened this issue Dec 20, 2024 · 2 comments · Fixed by #770
Closed

cargo doesn't know which to use because multiple target files found #768

dj95 opened this issue Dec 20, 2024 · 2 comments · Fixed by #770
Labels
bug Something isn't working

Comments

@dj95
Copy link

dj95 commented Dec 20, 2024

First of all thanks for providing the flake! It's really awesome and simplifies packaging rust projects for nix.

Describe the bug

Starting with commit 62e5013, I cannot build my projects anymore, that only contain binaries within the src/bin/ directory.

I'm using this flake in https://github.com/dj95/zjstatus to package the project. Simplified, the project setup is

src/bin/zjstatus.rs
src/bin/zjframes.rs
src/lib.rs
flake.nix

When building the flake of zjstatus with nix flake check . when using a commit newer than 62e5013, the build will fail with the following error:

       > Running phase: configurePhase
       > will append /private/tmp/nix-build-zjstatus-deps-0.19.1.drv-0/source/.cargo-home/config.toml with contents of /nix/store/8fyaknmzzlgzmfxzn0my7fjwrcm3sykb-vendor-cargo-deps/config.toml
       > default configurePhase, nothing to do
       > Running phase: buildPhase
       > ++ command cargo --version
       > cargo 1.83.0 (5ffbef321 2024-10-29)
       > ++ command cargo check --release --target wasm32-wasip1
       > error: failed to parse manifest at `/private/tmp/nix-build-zjstatus-deps-0.19.1.drv-0/source/Cargo.toml`
       >
       > Caused by:
       >   cannot infer path for `zjstatus` bin
       >   Cargo doesn't know which to use because multiple target files found at `src/main.rs` and `src/bin/zjstatus.rs`.
       For full logs, run 'nix log /nix/store/vmc65y5xzzpiv36gbb6qz4b0fix9dsvx-zjstatus-deps-0.19.1.drv'.

When using a commit before the specific one, everything works fine.

This also occurs in different other projects I maintain.

Reproduction

  • git clone https://github.com/dj95/zjstatus
  • Apply the following patch with git apply PATCH_FILE_NAME
diff --git a/flake.lock b/flake.lock
index 5185d1b..a27e0ec 100644
--- a/flake.lock
+++ b/flake.lock
@@ -2,17 +2,17 @@
   "nodes": {
     "crane": {
       "locked": {
-        "lastModified": 1733286231,
-        "narHash": "sha256-mlIDSv1/jqWnH8JTiOV7GMUNPCXL25+6jmD+7hdxx5o=",
+        "lastModified": 1733418579,
+        "narHash": "sha256-0fJaoI4B9Nn67E1P44usZhZHkSSyWdAI23HU+X+HJCQ=",
         "owner": "ipetkov",
         "repo": "crane",
-        "rev": "af1556ecda8bcf305820f68ec2f9d77b41d9cc80",
+        "rev": "62e50137688d953557f156f01e2ad2a25b22d66c",
         "type": "github"
       },
       "original": {
         "owner": "ipetkov",
         "repo": "crane",
-        "rev": "af1556ecda8bcf305820f68ec2f9d77b41d9cc80",
+        "rev": "62e50137688d953557f156f01e2ad2a25b22d66c",
         "type": "github"
       }
     },
diff --git a/flake.nix b/flake.nix
index e96747d..b834e7a 100644
--- a/flake.nix
+++ b/flake.nix
@@ -5,7 +5,7 @@
     nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
 
     crane = {
-      url = "github:ipetkov/crane/af1556ecda8bcf305820f68ec2f9d77b41d9cc80";
+      url = "github:ipetkov/crane/62e50137688d953557f156f01e2ad2a25b22d66c";
     };
 
     flake-utils.url = "github:numtide/flake-utils";
  • Run nix flake check . within the patched repository

Feel free to message me in case you need more information.

@dj95 dj95 added the bug Something isn't working label Dec 20, 2024
@ipetkov
Copy link
Owner

ipetkov commented Dec 21, 2024

Hi @dj95 thanks for the report and the reproduction! This should be fixed with #770

@dj95
Copy link
Author

dj95 commented Dec 21, 2024

Works like a charm. Thanks a lot for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants