Skip to content

Metadata fetching incorrectly uses cargo metadata --lockfile-path=... on cargo 1.95.0-beta.1 #21783

@Zalathar

Description

@Zalathar

After rust-lang/rust bumped its bootstrap compiler to 1.95.0-beta.1 in rust-lang/rust#153462, I found myself suddenly unable to use rust-analyzer on my rust-lang/rust checkout. Instead I started seeing errors like this:

2026-03-08T14:27:57.13764+11:00  WARN `cargo metadata` failed and returning succeeded result with `--no-deps` error=`cargo metadata` exited with an error: error: unexpected argument '--lockfile-path' found

  tip: a similar argument exists: '--locked'

Usage: cargo metadata --format-version <VERSION> --manifest-path <PATH> --filter-platform <TRIPLE> --locked

For more information, try '--help'.


Stack backtrace:
   0: std::backtrace::Backtrace::create
   1: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
   2: project_model::cargo_workspace::FetchMetadata::exec
   3: std::sys::backtrace::__rust_begin_short_backtrace
   4: core::ops::function::FnOnce::call_once{{vtable.shim}}
   5: std::sys::thread::unix::Thread::new::thread_start
   6: __pthread_joiner_wake

This is surprising, because up-to-date versions of rust-analyzer contain code to specifically not pass --lockfile-path to cargo 1.95 or later.

I was able to work around the problem locally by changing "rust-analyzer.server.extraEnv" from "RUSTUP_TOOLCHAIN": "stage0" to "nightly", which has a cargo version number of cargo 1.96.0-nightly.

The fact that this workaround is effective suggests to me that there's something wrong with how rust-analyzer is detecting cargo 1.95, because it seems to be detecting cargo 1.96 without issue.

However, I was unable to determine why rust-analyzer thinks that cargo 1.95.0-beta.1 supports --lockfile-path.


Name: rust-analyzer
Id: rust-lang.rust-analyzer
Description: Rust language support for Visual Studio Code
Version: 0.3.2811
Publisher: The Rust Programming Language
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions