rust-analyzer: rust-analyzer failed to load workspace again
Sorry to reopen this issue #4172 but the issue is still running and is not due to local toolchain installation.
It is more the difference of folders of rust-src between stable and nightly.
I have both stable and nightly and both have rust-src component installed but the folder inside rust-src is not the same for both toolchains.
In stable, rust-src contains an src folder and the requested libcore folder inside to load the workspace.
In nightly, rust-src contains only library and so rust-analyzer still tries to load src/libcore in nightly active toolchain.
And so the following still error occurs:
rust-analyzer failed to load workspace: Failed to find sysroot for Cargo.toml file /Users/.../workspace/.../Cargo.toml. Is rust-src installed?:
could not find libcore in sysroot path `/Users/.../.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src`
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 23 (9 by maintainers)
Commits related to this issue
- zsh: Remove now-unnecessary RUST_SRC_PATH See https://github.com/rust-analyzer/rust-analyzer/issues/6020#issuecomment-694255495 — committed to svenstaro/dotfiles by svenstaro 4 years ago
- RUST_SRC_PATH no longer needed https://github.com/rust-analyzer/rust-analyzer/issues/6020 — committed to JP-Ellis/dotfiles by JP-Ellis 4 years ago
Try unsetting those.
It works without those environment variable. Thank you! ๐ I thought it was mandatory to specify those. I donโt really remember why I needed to set
RUST_SRC_PATH, maybe for RLS and Racer.It looks like this issue is being caused by the recent reorg of the rust-lang/rust repo. As mentioned in the original issue, the
srcdirectory is now namedlibrary.I ran
rustup updateso the info below is withrustc 1.48.0-nightly (6af1bdda5 2020-09-15) (from rustc 1.48.0-nightly (a1947b3f9 2020-09-10)).rust-analyzer is trying to find the path:
But the actual path that exists is:
If anyone else is looking to temporarily work around the solution just to get their setup working again, you can use:
Simply renaming the directory to
srcwill probably work too, though I havenโt tried that.Ah! Yup. I had that variable too. It used to be mandatory for RLS. Thanks @lnicola! ๐
Same for me! Issue resolved ๐ Thanks @lnicola
This should have been fixed in https://github.com/rust-analyzer/rust-analyzer/pull/5586. Do you have a
RUST_SRCRUST_SRC_PATHenvironment variable?