rust-analyzer: Rust-analyzer error on pre-release branch of vscode extension
rust-analyzer version: rust-analyzer 2022-02-14 (installed via pacman)
rustc version: rustc 1.58.1 (db9d1b20b 2022-01-20) (installed via rustup and branch is stable)
Hello! I am taking this error on vscode.
rust-analyzer failed to load workspace: "cargo" "--version" failed, exit status: 1
stderr:
error: no override and no default toolchain set
I am using pre-release of vscode extension, that’s why i open a issue despite your info about it.
I tried adding CARGO path but it didn’t work.
I hope it’ll be helpful bug report for you!
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 49 (21 by maintainers)
Maybe you also need
RUSTUP_HOME?Works. Thank you so much for your help, let’s go back to work.
Anyways symlink is working too! I don’t know why did it give error when my first try, but it worked! That was related to alternative paths.
It looks like your rustup installation doesn’t have a default toolchain configured. Try running
rustup default stableto use stable rustc as default.I had this issue - it was because I’m using WSL to run an Ubuntu command line in Windows and VS Code in Windows itself (doh).
Yeah that is the answer to that error normally but then I still don’t get it.
I fully understand what you mean, it’s not a big issue, I just put stuff in opt because my home. I was expecting the symlink to work.
I tried to remove the json config and set the CARGO env var in /etc/environment.d/90cargo-path.conf which seems fine but no luck neither. Other processes have also those var.
I’m not sure, then. I would check that
CARGO_HOMEis set for Code. You can figure out it’s PID (look in the tree view ofps auwxforhtop) and check usingsudo cat /proc/$PID/env | tr '\0' '\n'.Nevermind.
Yes it was great with alternate parhs but it suddenly stopped working.
What do you mean by “they”?
Anyway, rust-analyzer appears to work when using alternate paths, but only if you configure them properly. If you only set those environment variables for the shell, rust-analyzer has no way of knowing about them.
In your setup? I don’t know.
If you want to make environment variables visible to Code, you can set them in a
.desktopfile, in/etc/environment, in~/.pam_environment(which is deprecated AFAIK) or in~/.config/environment.d(which works at least in GNOME and/orsystemd).Okay, you should have mentioned that in the original post. I’ll update the issue template to ask for customizations like this.
Did you try to run Code from the terminal? If you’re using a DE and you’re setting
RUSTUP_HOMEand/orCARGO_HOMEin your shell’s config, Code is not going to pick them up and rust-analyzer might become confused.In any case, I don’t think we’ve tested this configuration. There is some auto-detection for
~/.cargo/bin/cargo, but only that.You misundestood. I dualboot Debian & Arch. In Debian I installed rustup via rust’s site. In Arch I installed from pacman.
cargo --versiongivescargo 1.58.0 (f01b232bc 2022-01-19)restarting editor doesn’t fix 😦