Skip to content

Outdated toolchain error is not propagated to language server client #19594

Open
@frozenspider

Description

@frozenspider

rust-analyzer version:

$ /Users/fs/.cargo/bin/rust-analyzer --version
rust-analyzer 1.86.0 (05f9846f893 2025-03-31)

$ "/Users/fs/Library/Application Support/Zed/languages/rust-analyzer/rust-analyzer-2025-04-14" --version
rust-analyzer 0.3.2379-standalone (8365cf853e 2025-04-13)

rustc version:

rustc 1.86.0 (05f9846f8 2025-03-31)

editor or extension:
Issue was discovered when running Zed but it's not directly relevant.

relevant settings:
(I don't think any settings are relevant here)

repository link (if public, optional):
(Default rust-analyzer will do)

code snippet to reproduce:
(Not applicable)

See zed-industries/zed#28179
When running rust-analyzer with outdated toolchain on a project that requires newer edition, rust-analyzer seems to error out like this:

2025-04-15T20:55:37.208415+05:00  WARN rustc_cfg::get: failed to run `cd "/Users/fs/code/test-project" && RUSTUP_TOOLCHAIN="/opt/homebrew/Cellar/rust/1.81.0_1" "/Users/fs/.cargo/bin/cargo" "rustc" "-Z" "unstable-options" "--print" "cfg" "--target" "aarch64-apple-darwin" "--" "-O"`, falling back to invoking rustc directly e=cd "/Users/fs/code/test-project" && RUSTUP_TOOLCHAIN="/opt/homebrew/Cellar/rust/1.81.0_1" "/Users/fs/.cargo/bin/cargo" "rustc" "-Z" "unstable-options" "--print" "cfg" "--target" "aarch64-apple-darwin" "--" "-O" failed, exit status: 101
stderr:
error: the `-Z` flag is only accepted on the nightly channel 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.

2025-04-15T20:55:37.21781+05:00  WARN failed to run `cd "/Users/fs/code/test-project" && RUSTC_BOOTSTRAP="1" RUSTUP_TOOLCHAIN="/opt/homebrew/Cellar/rust/1.81.0_1" "/Users/fs/.cargo/bin/cargo" "rustc" "-Z" "unstable-options" "--print" "target-spec-json" "--" "-Z" "unstable-options" "--target" "aarch64-apple-darwin"`, falling back to invoking rustc directly e=cd "/Users/fs/code/test-project" && RUSTC_BOOTSTRAP="1" RUSTUP_TOOLCHAIN="/opt/homebrew/Cellar/rust/1.81.0_1" "/Users/fs/.cargo/bin/cargo" "rustc" "-Z" "unstable-options" "--print" "target-spec-json" "--" "-Z" "unstable-options" "--target" "aarch64-apple-darwin" failed, exit status: 101
stderr:
error: failed to parse manifest at `/Users/fs/code/test-project/Cargo.toml`

Caused by:
  feature `edition2024` is required

  The package requires the Cargo feature called `edition2024`, but that feature is not stabilized in this version of Cargo (1.81.0).
  Consider adding `cargo-features = ["edition2024"]` to the top of Cargo.toml (above the [package] table) to tell Cargo you are opting in to use this unstable feature.
  See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-2024 for more information about the status of this feature.

2025-04-15T20:55:37.257468+05:00  INFO did fetch workspaces workspaces=[Err(Failed to load the project at /Users/fs/code/test-project/Cargo.toml

Caused by:
    0: Failed to read Cargo metadata from Cargo.toml file /Users/fs/code/test-project/Cargo.toml, Some(Version { major: 1, minor: 81, patch: 0 })
    1: Failed to run `cd "/Users/fs/code/test-project" && RUSTUP_TOOLCHAIN="/opt/homebrew/Cellar/rust/1.81.0_1" "/Users/fs/.cargo/bin/cargo" "metadata" "--format-version" "1" "--manifest-path" "/Users/fs/code/test-project/Cargo.toml" "--filter-platform" "aarch64-apple-darwin"`
    2: `cargo metadata` exited with an error: error: failed to parse manifest at `/Users/fs/code/test-project/Cargo.toml`

       Caused by:
         feature `edition2024` is required

         The package requires the Cargo feature called `edition2024`, but that feature is not stabilized in this version of Cargo (1.81.0).
         Consider trying a newer version of Cargo (this may require the nightly release).
         See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-2024 for more information about the status of this feature.


Stack backtrace:
   0: std::backtrace::Backtrace::create
   1: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
   2: project_model::cargo_workspace::CargoWorkspace::fetch_metadata_
   3: project_model::cargo_workspace::CargoWorkspace::fetch_metadata
   4: std::sys::backtrace::__rust_begin_short_backtrace
   5: core::ops::function::FnOnce::call_once{{vtable.shim}}
   6: std::sys::pal::unix::thread::Thread::new::thread_start
   7: __pthread_cond_wait)]
2025-04-15T20:55:37.262434+05:00 ERROR GlobalState::handle_event{event=Event::Task}:GlobalState::handle_event/task: FetchWorkspaceError: rust-analyzer failed to load workspace: Failed to load the project at /Users/fs/code/test-project/Cargo.toml: Failed to read Cargo metadata from Cargo.toml file /Users/fs/code/test-project/Cargo.toml, Some(Version { major: 1, minor: 81, patch: 0 }): Failed to run `cd "/Users/fs/code/test-project" && RUSTUP_TOOLCHAIN="/opt/homebrew/Cellar/rust/1.81.0_1" "/Users/fs/.cargo/bin/cargo" "metadata" "--format-version" "1" "--manifest-path" "/Users/fs/code/test-project/Cargo.toml" "--filter-platform" "aarch64-apple-darwin"`: `cargo metadata` exited with an error: error: failed to parse manifest at `/Users/fs/code/test-project/Cargo.toml`

Caused by:
  feature `edition2024` is required

  The package requires the Cargo feature called `edition2024`, but that feature is not stabilized in this version of Cargo (1.81.0).
  Consider trying a newer version of Cargo (this may require the nightly release).
  See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-2024 for more information about the status of this feature.

However, I don't think this error is properly propagated to the LSP client, as Zed is unable to pick it up to show to user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions