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

Most upvoted comments

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 src directory is now named library.

I ran rustup update so the info below is with rustc 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:

~/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src

But the actual path that exists is:

~/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library

If anyone else is looking to temporarily work around the solution just to get their setup working again, you can use:

ln -s ~/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library ~/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src

Simply renaming the directory to src will 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_SRC RUST_SRC_PATH environment variable?