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

How to use it ? i get the error cargo: command not found #52

Closed
pinage404 opened this issue Dec 30, 2021 · 15 comments
Closed

How to use it ? i get the error cargo: command not found #52

pinage404 opened this issue Dec 30, 2021 · 15 comments
Labels
bug Something isn't working

Comments

@pinage404
Copy link

pinage404 commented Dec 30, 2021

Hello,

i'm trying to use this projet but i have this issue

/nix/store/lwcfw5vyjlzrs35k1hanv21j1q2s5c5w-stdenv-linux/setup: line 1364: cargo: command not found

What am i doing wrong ? How to use it ?

i tryied with a fresh crate using this script

#!/usr/bin/env sh
cd /tmp

rm -rf nix-cargo-integration-test
mkdir nix-cargo-integration-test
cd nix-cargo-integration-test

nix --version

nix_flake="nix --experimental-features 'nix-command flakes'"

nix-shell --pure --packages \
    cargo \
    nixUnstable \
    curl \
    cacert \
    git \
    --command "
cargo init
cargo run

echo '[package.metadata.nix]' >> Cargo.toml
echo 'build = true' >> Cargo.toml
echo 'app = true' >> Cargo.toml

${nix_flake} --version
${nix_flake} run github:yusdacra/nix-cargo-integration -- run

curl -sSL https://github.com/yusdacra/nix-cargo-integration/raw/66a357f6b17dd22f216dfd4373678deddbfe03fc/docs/example_flake.nix >flake.nix
git init
git config user.name name
git config user.email email@domain.tld
git add .
git commit --allow-empty-message --no-edit
${nix_flake} run
"

i get this output

bash nix-cargo-integration-test.sh
nix (Nix) 2.3.16
     Created binary (application) package
   Compiling nix-cargo-integration-test v0.1.0 (/tmp/nix-cargo-integration-test)
    Finished dev [unoptimized + debuginfo] target(s) in 0.52s
     Running `target/debug/nix-cargo-integration-test`
Hello, world!
nix (Nix) 2.5.0pre20211206_d1aaa7e
building '/nix/store/3rwmkjl42bab1jzdzgga5aw5lm6vdpic-nci-cli-0.1.0.drv'...
builder for '/nix/store/3rwmkjl42bab1jzdzgga5aw5lm6vdpic-nci-cli-0.1.0.drv' failed with exit code 1; last 6 log lines:
  unpacking sources
  unpacking source archive /nix/store/ayqnydsis8n1cx4mwc3b469qyy9wdfq7-source
  source root is source
  patching sources
  configuring
  /nix/store/lwcfw5vyjlzrs35k1hanv21j1q2s5c5w-stdenv-linux/setup: line 1364: cargo: command not found
error: build of '/nix/store/3rwmkjl42bab1jzdzgga5aw5lm6vdpic-nci-cli-0.1.0.drv' failed
Reinitialized existing Git repository in /tmp/nix-cargo-integration-test/.git/
[main (root-commit) bca910b] 
 5 files changed, 157 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 Cargo.lock
 create mode 100644 Cargo.toml
 create mode 100644 flake.nix
 create mode 100644 src/main.rs
warning: creating lock file '/tmp/nix-cargo-integration-test/flake.lock'
warning: Git tree '/tmp/nix-cargo-integration-test' is dirty
building '/nix/store/rhqnmzdjgr394s78l2y0d4831wnvsl7p-nix-cargo-integration-test-0.1.0.drv'...
builder for '/nix/store/rhqnmzdjgr394s78l2y0d4831wnvsl7p-nix-cargo-integration-test-0.1.0.drv' failed with exit code 1; last 6 log lines:
  unpacking sources
  unpacking source archive /nix/store/yhq9ahw7zx7l34c8crd0h2g89zdbc9jz-source
  source root is source
  patching sources
  configuring
  /nix/store/lwcfw5vyjlzrs35k1hanv21j1q2s5c5w-stdenv-linux/setup: line 1364: cargo: command not found
error: build of '/nix/store/rhqnmzdjgr394s78l2y0d4831wnvsl7p-nix-cargo-integration-test-0.1.0.drv' failed
@yusdacra
Copy link
Owner

Can you try using https://github.com/yusdacra/rust-nix-templater instead?

@pinage404
Copy link
Author

Thanks, i didn't know the existence of the templater

May i suggest to link to the templater or examples using the templater in the Usage section and in the manual ?


i adapted the script that test in with a fresh crate, but i get the same error

What did I do wrong?

#!/usr/bin/env sh
cd /tmp

rm -rf nix-cargo-integration-test
mkdir nix-cargo-integration-test
cd nix-cargo-integration-test

nix --version

nix_flake="nix --experimental-features 'nix-command flakes'"

nix-shell --pure --packages \
    cargo \
    nixUnstable \
    curl \
    cacert \
    git \
    --command "
cargo init
cargo run

${nix_flake} --version
${nix_flake} run github:yusdacra/rust-nix-templater

git init
git config user.name name
git config user.email email@domain.tld
git add .
git commit --allow-empty-message --no-edit

${nix_flake} run
"
bash nix-cargo-integration-test.sh
nix (Nix) 2.3.16
     Created binary (application) package
   Compiling nix-cargo-integration-test v0.1.0 (/tmp/nix-cargo-integration-test)
    Finished dev [unoptimized + debuginfo] target(s) in 0.42s
     Running `target/debug/nix-cargo-integration-test`
Hello, world!
nix (Nix) 2.5.0pre20211206_d1aaa7e
- Existing Cargo project detected.
💾 Writing files...
  - Formatting files...
  - Format successful: used `/nix/store/pqq7djf2gzzkn386cih6jvmkr6xf2l35-nixpkgs-fmt-1.2.0/bin/nixpkgs-fmt`
🎉 Finished!
Reinitialized existing Git repository in /tmp/nix-cargo-integration-test/.git/
[main (root-commit) a92a80b] 
 8 files changed, 180 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 Cargo.lock
 create mode 100644 Cargo.toml
 create mode 100644 compat.nix
 create mode 100644 default.nix
 create mode 100644 flake.nix
 create mode 100644 shell.nix
 create mode 100644 src/main.rs
warning: creating lock file '/tmp/nix-cargo-integration-test/flake.lock'
warning: Git tree '/tmp/nix-cargo-integration-test' is dirty
building '/nix/store/lhbpaxy47rjnhsb5274868rqikmfip7p-nix-cargo-integration-test-0.1.0.drv'...
builder for '/nix/store/lhbpaxy47rjnhsb5274868rqikmfip7p-nix-cargo-integration-test-0.1.0.drv' failed with exit code 1; last 6 log lines:
  unpacking sources
  unpacking source archive /nix/store/0gj7v7sbbbj21lm71c69g0i0awjs4kcl-source
  source root is source
  patching sources
  configuring
  /nix/store/lwcfw5vyjlzrs35k1hanv21j1q2s5c5w-stdenv-linux/setup: line 1364: cargo: command not found
error: build of '/nix/store/lhbpaxy47rjnhsb5274868rqikmfip7p-nix-cargo-integration-test-0.1.0.drv' failed

@yusdacra
Copy link
Owner

Interesting... Can you upload the not working example to a repository on github and link it here? I should be able to test the script later, but I also need to look at the broken files.

@yusdacra yusdacra added the bug Something isn't working label Dec 31, 2021
@pinage404
Copy link
Author

@yusdacra
Copy link
Owner

Can you change the buildPlatform to crate2nix and try again? It seems naersk platform is broken for some reason...

@pinage404
Copy link
Author

it seems to work on the fresh repository !

thanks ! =D

i will try with my real project

@pinage404
Copy link
Author

it works on my project, thanks

@kkharji
Copy link

kkharji commented Feb 15, 2022

I'm having the same issue without using rust-nix-templater.

with create2nix: I got error with gcc not executing correctly.
with buildRustPackage: I got

error: hash mismatch in fixed-output derivation '/nix/store/kknb9fgw51jjawbg7i2zl0kc0mgfb8r0-rust_module-0.0.0-vendor.tar.gz.drv':
         specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
            got:    sha256-tqSdmpi/lFpMvg1ygWf3zx0zUhbqDHyyWP7Nkp9O1m8=

@kkharji
Copy link

kkharji commented Feb 15, 2022

okay managed to make it work after updating the hash manually in build.cargoVendorHash.

@yusdacra
Copy link
Owner

The PR #56 should fix that issue, as it will stop using naersk / buildRustPackage or crate2nix directly but rather just use dream2nix, which abstracts away most of the work for us. So it would be appreciated if you could try that PR's branch 🙂

@a-kenji
Copy link

a-kenji commented Mar 7, 2022

I think I have a similar problem:

/nix/store/h6bva8mkj6xfp7za4v3jpp59i58wqs9f-stdenv-linux/setup: line 1357: cargo: command not found

Here is my attempt: https://github.com/a-kenji/zellij/blob/nci-example/nix/default.nix

@yusdacra
Copy link
Owner

yusdacra commented Mar 7, 2022

I think I have a similar problem:

/nix/store/h6bva8mkj6xfp7za4v3jpp59i58wqs9f-stdenv-linux/setup: line 1357: cargo: command not found

Here is my attempt: https://github.com/a-kenji/zellij/blob/nci-example/nix/default.nix

I fixed this just now by merging #62. It fails somewhere else now, I'm looking into that issue. It would be appreciated if you could try it and make an issue for it so we can investigate it.

@yusdacra
Copy link
Owner

yusdacra commented Mar 7, 2022

BTW I can reproduce your issue with just dream2nix, so I'll move the discussion there.

@a-kenji
Copy link

a-kenji commented Mar 7, 2022

BTW I can reproduce your issue with just dream2nix, so I'll move the discussion there.

Oh yeah, that is a good idea.
I could reproduce it with just dream2nix as well.

And I tried the new fix and it is still happening.
Thanks for all the help so far!

@yusdacra
Copy link
Owner

yusdacra commented Mar 7, 2022

Made issue on dream2nix nix-community/dream2nix#98 here.

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

No branches or pull requests

4 participants