nix-community / nixvim

Configure Neovim with Nix! [maintainers=@GaetanLepage, @traxys, @mattsturgeon, @khaneliman]
https://nix-community.github.io/nixvim
MIT License
1.75k stars 266 forks source link

[BUG] Rustacean no longer works - rustanalyizer can't find dynamically linked cargo #2172

Open clotodex opened 2 months ago

clotodex commented 2 months ago
Field Description
Plugin rustacean
Nixpkgs unstable
Home Manager unstable

Description

Since a month or so Rustacean does not start the rust-analyzer anymore. Looking into the logs this is a linking issue.

Caused by:
    0: Failed to query rust toolchain version at /home/<user>/projects/<project>, is your toolchain setup correctly?
    1: cd "<path>" && RUSTUP_TOOLCHAIN="/nix/store/3dpmxz017c7w9rjqicymjk4az220d78n-rust-mixed" "/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

While the error is obvious, I am curious why that started happening out of the blue? And since this makes rustacean not work out of the box anymore I am raising this issue. Anyone has a nicer workaround than force-linking a version of cargo?

Minimal, Reproducible Example (MRE)

Open any rust file with an installed rust-analyzer. (Tried NixOS, devenv and fenix)

programs.nixvim = {
      plugins = {
        rustaceanvim = {
        enable = true;
        settings = {
          server.default_settings.files.excludeDirs = [".direnv"];
          dap.autoloadConfigurations = true;
        };
      };
    }:
}
traxys commented 2 months ago

I personally install cargo/rustc through nix using https://github.com/nix-community/fenix or https://github.com/oxalica/rust-overlay to avoid those kinds of issues

clotodex commented 2 months ago

I am using fenix as well. However it seems to be not limited to rust analyzer but all cargo linked commands.

clotodex commented 2 months ago

https://github.com/cachix/devenv/issues/1419 Investigating if this might be a devenv issue. I am now very sure this is not unique to nixvim - I just noticed it here first - so happy with closing. The issue is not yet resolved but I am trying to figure out if it is generally bricked in nixpkgs, a nixos issue or a devenv specific issue. I will update my findings in the linked issue.