Skip to content

RUST_TARGET_PATH usage broken since 0.3.2658 #20932

@ramidzkh

Description

@ramidzkh

rust-analyzer version: 0.3.2660-standalone

rustc version: rustc 1.92.0-nightly (dc2c3564d 2025-09-29)

editor or extension: VSCode, error seems to be reproducible in terminal

relevant settings: Everything self contained in config.toml, needs nightly.

repro.tar.gz

This project was fine in 0.3.2593, but not in 0.3.2658 or 0.3.2660. 2025-10-27...2025-08-25

The cargo.toml importantly has:

[env]
RUST_TARGET_PATH = { value = "target-specs", relative = true }

[build]
target = "my-spec"

[unstable]
unstable-options = true
build-std = ["core"]

and a spec at target-specs/my-spec.json. Trying to do analysis gives

2025-10-29T01:34:25.441674093Z  WARN `cargo metadata` failed and returning succeeded result with `--no-deps` error=`cargo metadata` exited with an error: error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `rustc - --crate-name ___ --print=file-names --target my-spec --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg -Wwarnings` (exit status: 1)
  --- stderr
  error: error loading target specification: could not find specification for target "my-spec"
    |
    = help: run `rustc --print target-list` for a list of built-in targets



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

Metadata

Metadata

Assignees

Labels

A-cargocargo related issuesC-bugCategory: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions