Do rustup installed components such as rls supposed to be usable on NixOS?

I think I had rls functional at some point after installed via:

rustup component add rls rust-analysis rust-src

Today when I wanted to test my LSP client with it, I got the os error -2 error:

zsh: no such file or directory: /home/doron/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rls

Thankfully, nixos.rls is usable so I’m using it at the moment.

You might have to run rustup update if you changed your NixOS. Some of
the patches libraries might no longer be available.

No, didn’t help:

$ ls -l $(where rls)
lrwxrwxrwx 1 root root 65 Jan  1  1970 /run/current-system/sw/bin/rls -> /nix/store/2syaznc6mbxyfhdds8fdq8svjwp8mx7z-rustup-1.21.1/bin/rls
$ rls
error: command failed: 'rls'
error: caused by: No such file or directory (os error 2)
$ rustup component add rls rust-analysis rust-src
info: component 'rls' for target 'x86_64-unknown-linux-gnu' is up to date
info: component 'rust-analysis' for target 'x86_64-unknown-linux-gnu' is up to date
info: component 'rust-src' is up to date
$ rustup update
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'

  stable-x86_64-unknown-linux-gnu unchanged - (error reading rustc version)

info: cleaning up downloads & tmp directories

That message saying “error reading rustc version” is suspicious but I don’t know what to do with it…

rustup update solved this for me

1 Like

rustup toolchain uninstall stable && rustup toolchain install stable solved for me. Seems to be some unmatching after an update or something.

Yeah, rustup does binary patching exactly once at install time. When the linker used for that patching vanishes, the rustup managed binaries will also stop working.

A workflow that is slightly more prefered and still considers your tool-chain.toml is described by @viperML in this blogpost:

4 Likes

I should dig more in the docs to help improving that eventually. thanks for the heads up

Sidenote: Is there a reason to use RLS over Rust Analyzer? I thought RLS was deprecated and actually removed from current rust versions now

The original post was from 2020 when rust-analyzer was not the official language server

This post is around 1 year old.