[BUG] Rust toolchain bricked - probably CARGO_INSTALL_ROOT not respected
Describe the bug All cargo subcommands are broken for me. For example:
$ cargo sqlx prepare
Could not start dynamically linked executable: /home/user/.cargo/bin/cargo-sqlx
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:
https://nix.dev/permalink/stub-ld
This also goes for anything else, including rust analyzer, breaking most IDEs.
To reproduce
cargo new project
cd project
devenv init
# edit the devenv.nix to enable rust (does not matter how, fenix also does not work
Now run for example:
rust-analyzer analysis-stats .
And you will get:
Error: Failed to load the project at /tmp/project/./Cargo.toml
Caused by:
0: Failed to query rust toolchain version at /tmp/project, is your toolchain setup correctly?
1: cd "/tmp/nix-build-test" && RUSTUP_TOOLCHAIN="/nix/store/v00vzaszpvi6wrm213dgislmpr05gcfp-rustc-1.76.0" "/home/user/.cargo/bin/cargo" "--version" failed, exit status: 127
stderr:
Could not start dynamically linked executable: /home/user/.cargo/bin/cargo
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:
https://nix.dev/permalink/stub-ld
Version
devenv 1.0.8 (x86_64-linux)
Extra info
I am on NixOS, so nothing "local" is helping me resolve this. I can work around it (but not in IDEs) with using steam-run
This seems to be a devenv issue (i think).
When I use this repo: https://github.com/cpu/rust-flake, add sqlx-cli to the runtimeDeps and then run cargo sqlx prepare it works.
So something is going wrong in the devenv is my current assumption.
Also the local example https://github.com/cachix/devenv/tree/main/examples/rust does not work. Cd into there, run devenv shell and then run rust-analyzer analysis-stats . - same error
What is interesting though is that it is independent of the devenv.lock - so also old rust installs dont work anymore. Either this is something internal then or still correlated with NixOS, just in a weird way that only breaks devenv...
Happy for any support, willing to PR, but I dont know what is wrong yet.
bump... - this is breaking my setup fully. Can anyone reproduce this?
I'm seeing this issue, might or might not be related:
==> phoenix_ecto
Compiling 7 files (.ex)
Generated phoenix_ecto app
Compiling proc-macro2 v1.0.9
Compiling unicode-xid v0.2.0
Compiling syn v1.0.16
Compiling libc v0.2.67
Compiling slab v0.4.2
Compiling memchr v2.3.3
error[E0463]: can't find crate for `std`
|
= note: the `x86_64-unknown-linux-musl` target may not be installed
= help: consider downloading the target with `rustup target add x86_64-unknown-linux-musl`
error: cannot find macro `unreachable` in this scope
--> /home/self/.cargo/registry/src/index.crates.io-6f17d22bba15001f/slab-0.4.2/src/lib.rs:895:18
Same build and devenv works fine on aarch64-darwin.
Hm not sure if this is the same issue. Depending on what you are doing this might also just be missing some cross-compilation setup (using fenix with the musl toolchain).
Testing devenv 1.2 it did not change anything and commands like cargo sqlx prepare are still broken
I don't know much about Rust, but I'm not attempting a cross-compilation...
I finally gave it another debug and found the culprit. CARGO_HOME is not set when using rust with devenv, no matter if fenix or vanilla. Maybe #1500 can/will change things.
The / directory of the cargo package does not allow .package-cache This breaks rust-analyzer still.
nevermind. Uff, this is my bad Something actually installed a cargo into ~/.cargo/bin This made all programs fall back to this and could not make any kind of setup work.