rust-analyzer: rust-analyzer fails to load workspace with rustc-dev dependency when toolchain is on read-only file system
I am running vscode in a sandbox which leads to `~/.rustup/toolchains’ being read-only from the POV of vscode and RA. This usually works fine, except when I open the Miri workspace; then I get the following error:
rust-analyzer failed to load workspace: Failed to read Cargo metadata for Rust sources: Failed to run `cargo metadata --manifest-path /home/r/.rustup/toolchains/miri/lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.toml`: `cargo metadata` exited with an error: Updating crates.io index
error: failed to write /home/r/.rustup/toolchains/miri/lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.lock
Caused by:
failed to open: /home/r/.rustup/toolchains/miri/lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.lock
Caused by:
Read-only file system (os error 30)
rust-analyzer failed to load workspace: Failed to read Cargo metadata for Rust sources: Failed to run `cargo metadata --manifest-path /home/r/.rustup/toolchains/miri/lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.toml`: `cargo metadata` exited with an error: Updating crates.io index
error: failed to write /home/r/.rustup/toolchains/miri/lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.lock
Caused by:
failed to open: /home/r/.rustup/toolchains/miri/lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.lock
Caused by:
Read-only file system (os error 30)
Indeed /home/r/.rustup/toolchains/miri/lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.lock is read-only, but I also don’t think RA has any business mutating that file (it is managed by rustup after all), so it doesn’t seem like making that directory read-write would be the proper fix. Maybe cargo metadata should be called with --offline or --frozen?
This is probably related to my workspace settings:
// Place your settings in this file to overwrite default and user settings.
{
"rust-analyzer.rustfmt.extraArgs": [
"+nightly"
],
"rust-analyzer.checkOnSave.overrideCommand": [
"./miri",
"check",
"--message-format=json",
],
"rust-analyzer.linkedProjects": [
"./Cargo.toml",
"./cargo-miri/Cargo.toml"
],
"rust-analyzer.rustcSource": "discover"
}
Specifically I suspect the rustcSource part is relevant here.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (18 by maintainers)
Simply adding
Cargo.tomlto the rustc-dev component doesn’t work as the root workspace contains a fair amount of tools that are not included in the rustc-dev component.