Rust Analyzer emits errors in the log file while I'm browsing the standard library source code
⚓ Rust 📅 2025-07-27 👤 surdeus 👁️ 11Hello,
I happen to browse the source code of the standard library in Rust while working on my projects. It helps to understand how to use it more efficient. However, if I jump to some structure or function from the standard library, I see some errors in the log file of Rust Analyzer. It seems keeping well, though. I think so because all the intellisense functions work fine. By the "intellisense functions" I mean: completion, go to definition, find references, rename symbol etc. The PID of the process remains the same, so I the process doesn't crash.
2025-07-27T21:05:03.257493Z ERROR FetchWorkspaceError: rust-analyzer failed to load workspace: Failed to load the project at /home/oldhome/laladrik/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/Cargo.toml: Failed to read Cargo metadata from Cargo.toml file /home/oldhome/laladrik/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/Cargo.toml, Some(Version { major: 1, minor: 82, patch: 0 }): Failed to run `cd "/home/oldhome/laladrik/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc" && RUSTUP_TOOLCHAIN="/home/oldhome/laladrik/.rustup/toolchains/stable-x86_64-unknown-linux-gnu" "/home/laladrik/.cargo/bin/cargo" "metadata" "--format-version" "1" "--manifest-path" "/home/oldhome/laladrik/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/Cargo.toml" "--filter-platform" "x86_64-unknown-linux-gnu"`: `cargo metadata` exited with an error: error: failed to load manifest for workspace member `/home/oldhome/laladrik/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std`
referenced by workspace at `/home/oldhome/laladrik/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/Cargo.toml`
Caused by:
failed to parse manifest at `/home/oldhome/laladrik/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/Cargo.toml`
Caused by:
the cargo feature `public-dependency` requires a nightly version of Cargo, but this is the `stable` channel
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
See https://doc.rust-lang.org/cargo/reference/unstable.html#public-dependency for more information about using this feature.
Let me emphasize that Rust Analyzer does seem working. However, I have a feeling that some misconfiguration causes the error. This error does not affect my work now, but I had it before. At that moment Rust Analyzer failed to work in the dependencies of my projects. I couldn't fix that on that computer and I just worked without intellisense. I'm just afraid that it might happen again.
The text of the error
the cargo feature `public-dependency` requires a nightly version of Cargo
I struggle to understand the text for a couple of reasons:
- I don't use the nightly version of the compiler. In fact, I can't switch to it either. How do I switch to night version of Cargo?
- Cargo complains about
public-dependency. It's triggered by the line from the rustc. This line appeared 2 years ago, but I started getting the error about two weeks ago. I didn't change my dev Rust environment either. - The line from p. 2. remains in the
masterbranch. Therefore, Rust analyzer would fail even with the updated version of Rust toolchain.
Observations
- The error emitted by
cargo metadata. From the log it can be seen that Rust Analyzer calls it. Given that, I assume that the error is expected from Cargo for projects with the feature. Therefore, I guess that Rust Analyzer is not supposed to runcargo metadatafor the folder with the source code of the standard library. - The parent folders of
rustupand Cargo are different. Could it affect the work of Rust Analyzer?
Configuration
I don't configure anything regarding the Rust toolchain in Rust Analyzer. The configuration of Rust Analyzer is here, though:
{
"checkOnSave": true,
"check":{
"extraArgs":["--no-deps"],
"command":"clippy"
}
}
The environment I work in
- OS: Fedora Linux 41
- rust-analyzer 0.0.0 (08c7bbc2db 2024-09-06)
- rustc 1.82.0 (f6e511eec 2024-10-15)
- cargo 1.82.0 (8f40fc59f 2024-08-21)
- Neovim v0.10.4 with the plugin rustaceanvim
One more thing on the versions:
The latest version of Rust Analyzer doesn't emit the error. However, it says that it can't obtain the package "compiler_builtins", because it needs "edition 2024". I guess it means that I have to switch my cargo project to "edition 2024". Transition to the change would require some extra work, which can't be taken for the moment.
I appreciate anyone who knows what's the error about or even knows how to fix it
1 post - 1 participant
🏷️ Rust_feed