rust-lang / rust-lang/rust-analyzer

RA cannot load rustc crates any more

Open
#23,392 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-rustc C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Opening Miri in RA, none of the rustc crates can be loaded, so

  • no auto-complete for rustc types
  • no ctrl-click for rustc types
  • in the crate root, I get a ton of "unresolved extern crate" errors.

This worked with with version 0.3.3025 and is broken in versions 0.3.3033 and 0.3.3049.

The server log as a lot of this:

2026-09-18T15:31:29.697923058+02:00  WARN `cargo metadata` failed and returning succeeded result with `--no-deps` error=`cargo metadata` exited with an error:     Updating crates.io index
error: cannot create the lock file /home/r/.rustup/toolchains/miri/lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.lock because --locked was passed to prevent this
help: to generate the lock file without accessing the network, remove the --locked flag and use --offline instead.


Stack backtrace:
   0: <anyhow::Error as core::convert::From<cargo_metadata::errors::Error>>::from
   1: <project_model::cargo_workspace::FetchMetadata>::exec
   2: std::sys::backtrace::__rust_begin_short_backtrace::<<project_model::workspace::ProjectWorkspace>::load_cargo::{closure#1}::{closure#2}, core::result::Result<alloc::boxed::Box<(project_model::cargo_workspace::CargoWorkspace, project_model::build_dependencies::WorkspaceBuildScripts)>, core::option::Option<alloc::string::String>>>
   3: <std::thread::lifecycle::spawn_unchecked<<project_model::workspace::ProjectWorkspace>::load_cargo::{closure#1}::{closure#2}, core::result::Result<alloc::boxed::Box<(project_model::cargo_workspace::CargoWorkspace, project_model::build_dependencies::WorkspaceBuildScripts)>, core::option::Option<alloc::string::String>>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
   4: <std::sys::thread::unix::Thread>::new::thread_start
   5: start_thread
             at ./nptl/pthread_create.c:448:8
   6: __GI___clone3
             at /build/reproducible-path/glibc-2.42/misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
2026-09-18T15:31:30.963826029+02:00  WARN `cargo metadata` failed and returning succeeded result with `--no-deps` error=`cargo metadata` exited with an error:     Updating crates.io index
error: cannot create the lock file /home/r/.rustup/toolchains/miri/lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.lock because --locked was passed to prevent this
help: to generate the lock file without accessing the network, remove the --locked flag and use --offline instead.


Stack backtrace:
   0: <anyhow::Error as core::convert::From<cargo_metadata::errors::Error>>::from
   1: <project_model::cargo_workspace::FetchMetadata>::exec
   2: std::sys::backtrace::__rust_begin_short_backtrace::<<project_model::workspace::ProjectWorkspace>::load_cargo::{closure#1}::{closure#2}, core::result::Result<alloc::boxed::Box<(project_model::cargo_workspace::CargoWorkspace, project_model::build_dependencies::WorkspaceBuildScripts)>, core::option::Option<alloc::string::String>>>
   3: <std::thread::lifecycle::spawn_unchecked<<project_model::workspace::ProjectWorkspace>::load_cargo::{closure#1}::{closure#2}, core::result::Result<alloc::boxed::Box<(project_model::cargo_workspace::CargoWorkspace, project_model::build_dependencies::WorkspaceBuildScripts)>, core::option::Option<alloc::string::String>>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
   4: <std::sys::thread::unix::Thread>::new::thread_start
   5: start_thread
             at ./nptl/pthread_create.c:448:8
   6: __GI___clone3
             at /build/reproducible-path/glibc-2.42/misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
2026-09-18T15:31:32.016539137+02:00  WARN `cargo metadata` failed and returning succeeded result with `--no-deps` error=`cargo metadata` exited with an error:     Updating crates.io index
error: cannot create the lock file /home/r/.rustup/toolchains/miri/lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.lock because --locked was passed to prevent this
help: to generate the lock file without accessing the network, remove the --locked flag and use --offline instead.

Workspace config:

{
    "rust-analyzer.rustc.source": "discover",
    "rust-analyzer.linkedProjects": [
        "Cargo.toml",
        // "genmc-sys/Cargo.toml",
        "cargo-miri/Cargo.toml",
        "miri-script/Cargo.toml",
    ],
    "rust-analyzer.check.invocationStrategy": "once",
    "rust-analyzer.check.overrideCommand": [
        "./miri",
        "clippy",
        "--all-features",
        "--message-format=json",
    ],
    "rust-analyzer.cargo.features": "all",
    "rust-analyzer.cargo.extraEnv": {
        "MIRI_AUTO_OPS": "no",
        "MIRI_IN_RA": "1",
    },
    // Contrary to what the name suggests, this also affects proc macros.
    "rust-analyzer.cargo.buildScripts.invocationStrategy": "once",
    "rust-analyzer.cargo.buildScripts.overrideCommand": [
        "./miri",
        "check",
        "--all-features",
        "-Zunstable-options",
        "--compile-time-deps",
        "--message-format=json",
    ],
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure by opening Miri in rust-analyzer with the reported workspace configuration and compare versions 0.3.3025, 0.3.3033, and 0.3.3049. Start at project_model::cargo_workspace::FetchMetadata::exec and ProjectWorkspace::load_cargo, focusing on the cargo metadata failure for the rustc source Cargo.toml. Done means rustc crates load again, with completion and ctrl-click restored and no unresolved extern crate errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.