rustlings
rustlings copied to clipboard
`nix develop` is returning a Cargo.lock error during installation
I'm kind of a nix newbie so I could be doing something wrong, but I'm running into an issue while following the install instructions in the readme for rustlings via nix.
The version of rustlings I checked out from github is 5.4.1. I am on MacOS 13.1 (22C65), Apple M2 Chip.
nix --version returns:
nix (Nix) 2.13.0
nix develop returns:
error: builder for '/nix/store/77n03jiaaxk100dgc5880iq56alwzb80-rustlings.drv' failed with exit code 101;
last 10 log lines:
> Executing cargoSetupPostPatchHook
> Validating consistency between /private/tmp/nix-build-rustlings.drv-0/source/Cargo.lock and /private/tmp/nix-build-rustlings.drv-0/cargo-vendor-dir/Cargo.lock
> Finished cargoSetupPostPatchHook
> updateAutotoolsGnuConfigScriptsPhase
> configuring
> building
> Executing cargoBuildHook
> ++ env CC_aarch64-apple-darwin=/nix/store/a79iskrr56f0dbggj1gs819y3g3vs37k-clang-wrapper-11.1.0/bin/cc CXX_aarch64-apple-darwin=/nix/store/a79iskrr56f0dbggj1gs819y3g3vs37k-clang-wrapper-11.1.0/bin/c++ CC_aarch64-apple-darwin=/nix/store/a79iskrr56f0dbggj1gs819y3g3vs37k-clang-wrapper-11.1.0/bin/cc CXX_aarch64-apple-darwin=/nix/store/a79iskrr56f0dbggj1gs819y3g3vs37k-clang-wrapper-11.1.0/bin/c++ cargo build -j 8 --target aarch64-apple-darwin --frozen --release
> error: the lock file /private/tmp/nix-build-rustlings.drv-0/source/Cargo.lock needs to be updated but --frozen was passed to prevent this
> If you want to try to generate the lock file without accessing the network, remove the --frozen flag and use --offline instead.
For full logs, run 'nix log /nix/store/77n03jiaaxk100dgc5880iq56alwzb80-rustlings.drv'.
error: 1 dependencies of derivation '/nix/store/5rq3x7c1mrsppa3w9cgfpijsavzqck2f-nix-shell-env.drv' failed to build
ls -la returns:
total 576
drwxr-xr-x 26 pooralaska staff 832 Mar 16 23:16 .
drwxr-xr-x 23 pooralaska staff 736 Mar 16 23:16 ..
-rw-r--r-- 1 pooralaska staff 51285 Mar 16 23:16 .all-contributorsrc
drwxr-xr-x 4 pooralaska staff 128 Mar 16 23:16 .devcontainer
-rw-r--r-- 1 pooralaska staff 102 Mar 16 23:16 .editorconfig
drwxr-xr-x 13 pooralaska staff 416 Mar 16 23:34 .git
drwxr-xr-x 3 pooralaska staff 96 Mar 16 23:16 .github
-rw-r--r-- 1 pooralaska staff 166 Mar 16 23:16 .gitignore
-rw-r--r-- 1 pooralaska staff 162 Mar 16 23:16 .gitpod.yml
drwxr-xr-x 3 pooralaska staff 96 Mar 16 23:16 .vscode
-rw-r--r-- 1 pooralaska staff 68782 Mar 16 23:16 AUTHORS.md
-rw-r--r-- 1 pooralaska staff 44847 Mar 16 23:16 CHANGELOG.md
-rw-r--r-- 1 pooralaska staff 4171 Mar 16 23:16 CONTRIBUTING.md
-rw-r--r-- 1 pooralaska staff 16506 Mar 16 23:16 Cargo.lock
-rw-r--r-- 1 pooralaska staff 504 Mar 16 23:16 Cargo.toml
-rw-r--r-- 1 pooralaska staff 1095 Mar 16 23:16 LICENSE
-rw-r--r-- 1 pooralaska staff 6491 Mar 16 23:16 README.md
drwxr-xr-x 30 pooralaska staff 960 Mar 16 23:16 exercises
-rw-r--r-- 1 pooralaska staff 1512 Mar 16 23:16 flake.lock
-rw-r--r-- 1 pooralaska staff 1968 Mar 16 23:16 flake.nix
-rw-r--r-- 1 pooralaska staff 41537 Mar 16 23:16 info.toml
-rw-r--r-- 1 pooralaska staff 3022 Mar 16 23:16 install.ps1
-rwxr-xr-x 1 pooralaska staff 4662 Mar 16 23:16 install.sh
-rw-r--r-- 1 pooralaska staff 278 Mar 16 23:16 shell.nix
drwxr-xr-x 8 pooralaska staff 256 Mar 16 23:16 src
drwxr-xr-x 4 pooralaska staff 128 Mar 16 23:16 tests
Any help would be appreciated.
I had the exact same issue too on MacOS 13.2.1, M1 Pro chip.
I ended up solving this by commenting out the rustlings package in flake.nix so that nix develop could properly complete without the project package, running cargo update, and then uncommenting everything again. In the end this changed flake.lock and Cargo.lock. This should hopefully work for you too. I can also submit a PR if that would be accepted. Not sure if that would have effects on other setups though.
Seems like there's a lot of incompatibilities between "standard" Nix setups and how things are handled on MacOS? I'd rather have a one-works-for-all kind of solution, instead of something that may work for MacOS users but breaks for, say, Linux users... but I don't know how difficult that'd be.
I'm running nix develop on pop_os, I get the same error
error: builder for '/nix/store/d6z2g77dcn18kc7d5p7wa3igmqh2f7ln-rustlings.drv' failed with exit code 101;
last 10 log lines:
> patching sources
> Executing cargoSetupPostPatchHook
> Validating consistency between /build/source/Cargo.lock and /build/cargo-vendor-dir/Cargo.lock
> Finished cargoSetupPostPatchHook
> configuring
> building
> Executing cargoBuildHook
> ++ env CC_x86_64-unknown-linux-gnu=/nix/store/0vln6gxc9b2wr9yhbn0aspy6badlj638-gcc-wrapper-11.3.0/bin/cc CXX_x86_64-unknown-linux-gnu=/nix/store/0vln6gxc9b2wr9yhbn0aspy6badlj638-gcc-wrapper-11.3.0/bin/c++ CC_x86_64-unknown-linux-gnu=/nix/store/0vln6gxc9b2wr9yhbn0aspy6badlj638-gcc-wrapper-11.3.0/bin/cc CXX_x86_64-unknown-linux-gnu=/nix/store/0vln6gxc9b2wr9yhbn0aspy6badlj638-gcc-wrapper-11.3.0/bin/c++ cargo build -j 4 --target x86_64-unknown-linux-gnu --frozen --release
> error: the lock file /build/source/Cargo.lock needs to be updated but --frozen was passed to prevent this
> If you want to try to generate the lock file without accessing the network, remove the --frozen flag and use --offline instead.
For full logs, run 'nix log /nix/store/d6z2g77dcn18kc7d5p7wa3igmqh2f7ln-rustlings.drv'.
error: 1 dependencies of derivation '/nix/store/ph04hk7gahpjb77r6i7rwc3nhy26ax8r-nix-shell-env.drv' failed to build
I have another flake I use to instantiate a nix shell with the rust toolchain and had to run cargo update with that flake first before being able to use the rustlings supplied flake.
Seems like there's a lot of incompatibilities between "standard" Nix setups and how things are handled on MacOS? I'd rather have a one-works-for-all kind of solution, instead of something that may work for MacOS users but breaks for, say, Linux users... but I don't know how difficult that'd be.
I'm seeing this error on Manjaro and Nixos 22.11. So, I don't think this is an OS specific issue. #1430 Fixes it for me on both systems.
I just tried nix on wsl2 and had the same issue (running on v5.4.1 )
The above workaround fixed the problem but if it's hard to keep the lock file up to date it might be better to document this workaround in the Readme.md
I ended up solving this by commenting out the
rustlingspackage inflake.nixso thatnix developcould properly complete without the project package, runningcargo update, and then uncommenting everything again.
Not sure if that would have effects on other setups though.
Seems pretty universal, this worked for me on NixOS.
Why is this issue closed?
I just had this issue as well.
l'll reopen the issue, but updating our Cargo.lock every so and so often can't be the solution to this. I know next to no Nix, but isn't there a way to fix our flake implementation to avoid this issue?
You basically need to bump the Cargo.lock everytime you change the Version in the Cargo.toml, as the version of the package self is part of the lock.
Running cargo build right after bumping the version in the Cargo.toml and then commiting both files should suffice.
#1550 adds a CI step which fails if Cargo.lock is not in sync with Cargo.toml; this should help prevent this issue from occurring in the future.
Closing because seems to be resolved by https://github.com/rust-lang/rustlings/pull/1550 (see https://github.com/rust-lang/rustlings/issues/1430#issuecomment-1593748563)
I am getting this error again on the latest fresh install of NixOS on my new Ryzen laptop. With the additional output of;
[daxsudo@nixos:~/Code/Rust/Learn/rustlings]$ nix develop
error: builder for '/nix/store/i7808n8fdzzc5xnqvlzhz86mi99k18a3-rustlings.drv' failed with exit code 101;
last 10 log lines:
> Finished cargoSetupPostPatchHook
> updateAutotoolsGnuConfigScriptsPhase
> configuring
> building
> Executing cargoBuildHook
> ++ env CC_x86_64-unknown-linux-gnu=/nix/store/v1wa8ysdv5lc516fbh25m8ysigwv1k20-gcc-wrapper-12.3.0/bin/cc CXX_x86_64-unknown-linux-gnu=/nix/store/v1wa8ysdv5lc516fbh25m8ysigwv1k20-gcc-wrapper-12.3.0/bin/c++ CC_x86_64-unknown-linux-gnu=/nix/store/v1wa8ysdv5lc516fbh25m8ysigwv1k20-gcc-wrapper-12.3.0/bin/cc CXX_x86_64-unknown-linux-gnu=/nix/store/v1wa8ysdv5lc516fbh25m8ysigwv1k20-gcc-wrapper-12.3.0/bin/c++ cargo build -j 8 --target x86_64-unknown-linux-gnu --frozen --release
> error: package `clap_derive v4.5.4` cannot be built because it requires rustc 1.74 or newer, while the currently active rustc version is 1.72.0
> Either upgrade to rustc 1.74 or newer, or use
> cargo update -p [email protected] --precise ver
> where `ver` is the latest version of `clap_derive` supporting rustc 1.72.0
For full logs, run 'nix log /nix/store/i7808n8fdzzc5xnqvlzhz86mi99k18a3-rustlings.drv'.
error: 1 dependencies of derivation '/nix/store/24gzdlc778nhvwf8ky9kj3qf9ng7cglj-nix-shell-env.drv' failed to build
Belay my last. This was fixed with the nix flake update command.
Skill Issue on my part new to Nix.