Rust-analyzer failed to load workspace: Failed to find sysroot for Cargo.toml file

I have switched from Vim to Atom now to program in Rust, just for a while. In Atom I have installed the ide-rust-plugin. But I keep getting this error:

rust-analyzer failed to load workspace: Failed to find sysroot for Cargo.toml file /Users/niel/Sites/kaddo/Cargo.toml. Is rust-src installed?: could not find libcore in sysroot path /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/

Rust (rust-analyzer) /Users/niel/Sites/kaddo/

I have rust-src installed by running the following commands:

rustup update
rustup component add rust-src
rustup component add rust-src --toolchain nightly

But the error keeps existing after restarting Atom.

/Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/ contains a folder called llvm-project.

/Users/niel/.rustup/toolchains contains:

1.41.0-x86_64-apple-darwin	stable-x86_64-apple-darwin

1.41.0... does contain some files with the name rustc in it. Maybe I have to switch to that version somehow?

I was able to switch toolchains doing the following:

rustup default nightly-x86_64-apple-darwin

However, I cant switch versions because than my project and it's libraries won't compile.

Atom's ide-rust plugin sets the RUST_SRC_PATH environment variable to a now wrong value. There's a PR to fix this, but it seems it hasn't been merged yet. The directory the error is complaining about is IIRC the wrong one. But current versions of rust-analyzer ignore the RUST_SRC_PATH variable when it doesn't point to a valid sysroot. What version of rust-analyzer do you have installed? (Running rust-analyzer --version should tell you.) Does /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library exist and contain something?

My version is rust-analyzer 0d03fe6 and the folder contains:

alloc				rustc-std-workspace-alloc
backtrace			rustc-std-workspace-core
core				rustc-std-workspace-std
panic_abort			std
panic_unwind			stdarch
proc_macro			term
profiler_builtins		test
rtstartup			unwind

That version is from 13 September 2020:

Try updating it.

I did the following:

$ git clone && cd rust-analyzer
$ cargo xtask install --server

and moved it to /Users/niel/.local/bin.

Version is now rust-analyzer 286d90d. Still get the same error when I restart Atom though.

I think I'm going to switch to Sublime Text. Atom and it's Rust-plugins are not cutting it anymore...

I do:

#[derive(Serialize, Deserialize)]
    #[serde(rename_all = "camelCase")]
    struct Link {
        href: String,
        r#type: String,

r# to escape the type-keyword and my whole code coloring goes blank.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.