Skip to content

[BUG] Rust toolchain linking broken - CARGO_HOME not set #1419

Closed
@clotodex

Description

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

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions