Skip to content

fix: set CARGO env var during rustc -vV probe#16811

Merged
weihanglo merged 2 commits intorust-lang:masterfrom
zhibisora:fix-cargo-env-vv-probe
Mar 31, 2026
Merged

fix: set CARGO env var during rustc -vV probe#16811
weihanglo merged 2 commits intorust-lang:masterfrom
zhibisora:fix-cargo-env-vv-probe

Conversation

@zhibisora
Copy link
Copy Markdown
Contributor

Summary

Set the CARGO environment variable when running the rustc -vV version probe, consistent with how Compilation::fill_env() sets it for all compilation invocations.

Problem

Since #13659, the -vV probe goes through RUSTC_WRAPPER and RUSTC_WORKSPACE_WRAPPER. However, the CARGO env var is not set during this probe. Tools like sccache depend on CARGO to detect the workspace wrapper pattern in their compiler detection logic (mozilla/sccache#1280), causing sccache to fail with "Compiler not supported" when a RUSTC_WORKSPACE_WRAPPER is present.

Solution

Add cmd.env(crate::CARGO_ENV, gctx.cargo_exe()?) before the -vV invocation in Rustc::new().

Test plan

  • Existing rustc_wrapper tests pass (8/8)
  • Manually verified: CARGO=$(which cargo) as a workaround resolves the issue

Closes #16805

@rustbot rustbot added A-cache-messages Area: caching of compiler messages S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 31, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 31, 2026

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

Copy link
Copy Markdown
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. We expect a new test to be written for new behavior. We've also found it helpful to add the tests in a commit before the fix, reproducing the problem. See a working-in-progress note from epage: https://epage.github.io/dev/pr-style/#c-test

View changes since this review

Add a test that verifies whether the CARGO env var is set when
the rustc wrapper is invoked during the -vV version probe. Currently
it is not set, which causes tools like sccache to fail when
RUSTC_WORKSPACE_WRAPPER is also present.

See rust-lang#16805
The -vV probe goes through RUSTC_WRAPPER and RUSTC_WORKSPACE_WRAPPER
since rust-lang#13659, but the CARGO env var was not set. Tools like sccache
depend on CARGO to detect the workspace wrapper pattern in their
compiler detection logic.

Closes rust-lang#16805
@zhibisora zhibisora force-pushed the fix-cargo-env-vv-probe branch from 40bcbe9 to e794ef7 Compare March 31, 2026 17:08
@zhibisora
Copy link
Copy Markdown
Contributor Author

Updated with two commits per C-TEST convention:

  1. test: — adds a test that reproduces the current behavior (CARGO env var is not set during the -vV probe)
  2. fix: — sets CARGO on the probe command and updates the test expectation

The test uses a custom wrapper that writes CARGO env var status to a file when invoked for -vV, since the probe's stderr is captured by cached_output and not visible in test output.

Copy link
Copy Markdown
Contributor

@arlosi arlosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weihanglo weihanglo enabled auto-merge March 31, 2026 17:39
@weihanglo weihanglo added this pull request to the merge queue Mar 31, 2026
Merged via the queue into rust-lang:master with commit 9cb2a0c Mar 31, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 31, 2026
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Apr 2, 2026
Update cargo submodule

12 commits in 888f675344eb1cf2308fd53183e667bdd2c58e51..0c7d80bf5ad3b873a5dbf44e0185152890c6d18a
2026-03-30 16:59:25 +0000 to 2026-04-02 20:48:06 +0000
- refactor(network): use async for registry network operations (rust-lang/cargo#16745)
- fix(compile): Don't hide hard warnings with build.warnings=allow (rust-lang/cargo#16827)
- chore: Upgrade incompatible dependencies (rust-lang/cargo#16825)
- fix(compile): build.warnings=allow should not hide denied diagnostics (rust-lang/cargo#16824)
- fix(install): Ignore resolver.lockfile-path (rust-lang/cargo#16823)
- chore(deps): update compatible (rust-lang/cargo#16820)
- refactor(compile): Consolidate output options (rust-lang/cargo#16821)
- refactor: Export public dependencies from internal crates (rust-lang/cargo#16819)
- refactor(progress): Make the code more approachable (rust-lang/cargo#16813)
- Simplified build script bin names in new layout (rust-lang/cargo#16812)
- fix: set CARGO env var during rustc -vV probe (rust-lang/cargo#16811)
- Split out `cargo-util-terminal` (rust-lang/cargo#16809)

r? ghost
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Apr 3, 2026
Update cargo submodule



15 commits in 888f675344eb1cf2308fd53183e667bdd2c58e51..a357df4c26fc14514e66aae2a269456b5545c7db
2026-03-30 16:59:25 +0000 to 2026-04-03 16:47:15 +0000
- chore: downgrade to libz-sys@1.1.24 (rust-lang/cargo#16833)
- feat: add frame-pointers profile option (rust-lang/cargo#16742)
- upgrade to gix@0.81.0 (rust-lang/cargo#16828)
- refactor(network): use async for registry network operations (rust-lang/cargo#16745)
- fix(compile): Don't hide hard warnings with build.warnings=allow (rust-lang/cargo#16827)
- chore: Upgrade incompatible dependencies (rust-lang/cargo#16825)
- fix(compile): build.warnings=allow should not hide denied diagnostics (rust-lang/cargo#16824)
- fix(install): Ignore resolver.lockfile-path (rust-lang/cargo#16823)
- chore(deps): update compatible (rust-lang/cargo#16820)
- refactor(compile): Consolidate output options (rust-lang/cargo#16821)
- refactor: Export public dependencies from internal crates (rust-lang/cargo#16819)
- refactor(progress): Make the code more approachable (rust-lang/cargo#16813)
- Simplified build script bin names in new layout (rust-lang/cargo#16812)
- fix: set CARGO env var during rustc -vV probe (rust-lang/cargo#16811)
- Split out `cargo-util-terminal` (rust-lang/cargo#16809)
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Apr 4, 2026
Update cargo submodule



15 commits in 888f675344eb1cf2308fd53183e667bdd2c58e51..a357df4c26fc14514e66aae2a269456b5545c7db
2026-03-30 16:59:25 +0000 to 2026-04-03 16:47:15 +0000
- chore: downgrade to libz-sys@1.1.24 (rust-lang/cargo#16833)
- feat: add frame-pointers profile option (rust-lang/cargo#16742)
- upgrade to gix@0.81.0 (rust-lang/cargo#16828)
- refactor(network): use async for registry network operations (rust-lang/cargo#16745)
- fix(compile): Don't hide hard warnings with build.warnings=allow (rust-lang/cargo#16827)
- chore: Upgrade incompatible dependencies (rust-lang/cargo#16825)
- fix(compile): build.warnings=allow should not hide denied diagnostics (rust-lang/cargo#16824)
- fix(install): Ignore resolver.lockfile-path (rust-lang/cargo#16823)
- chore(deps): update compatible (rust-lang/cargo#16820)
- refactor(compile): Consolidate output options (rust-lang/cargo#16821)
- refactor: Export public dependencies from internal crates (rust-lang/cargo#16819)
- refactor(progress): Make the code more approachable (rust-lang/cargo#16813)
- Simplified build script bin names in new layout (rust-lang/cargo#16812)
- fix: set CARGO env var during rustc -vV probe (rust-lang/cargo#16811)
- Split out `cargo-util-terminal` (rust-lang/cargo#16809)
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Apr 4, 2026
Update cargo submodule



15 commits in 888f675344eb1cf2308fd53183e667bdd2c58e51..a357df4c26fc14514e66aae2a269456b5545c7db
2026-03-30 16:59:25 +0000 to 2026-04-03 16:47:15 +0000
- chore: downgrade to libz-sys@1.1.24 (rust-lang/cargo#16833)
- feat: add frame-pointers profile option (rust-lang/cargo#16742)
- upgrade to gix@0.81.0 (rust-lang/cargo#16828)
- refactor(network): use async for registry network operations (rust-lang/cargo#16745)
- fix(compile): Don't hide hard warnings with build.warnings=allow (rust-lang/cargo#16827)
- chore: Upgrade incompatible dependencies (rust-lang/cargo#16825)
- fix(compile): build.warnings=allow should not hide denied diagnostics (rust-lang/cargo#16824)
- fix(install): Ignore resolver.lockfile-path (rust-lang/cargo#16823)
- chore(deps): update compatible (rust-lang/cargo#16820)
- refactor(compile): Consolidate output options (rust-lang/cargo#16821)
- refactor: Export public dependencies from internal crates (rust-lang/cargo#16819)
- refactor(progress): Make the code more approachable (rust-lang/cargo#16813)
- Simplified build script bin names in new layout (rust-lang/cargo#16812)
- fix: set CARGO env var during rustc -vV probe (rust-lang/cargo#16811)
- Split out `cargo-util-terminal` (rust-lang/cargo#16809)
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Apr 6, 2026
Update cargo submodule



15 commits in 888f675344eb1cf2308fd53183e667bdd2c58e51..a357df4c26fc14514e66aae2a269456b5545c7db
2026-03-30 16:59:25 +0000 to 2026-04-03 16:47:15 +0000
- chore: downgrade to libz-sys@1.1.24 (rust-lang/cargo#16833)
- feat: add frame-pointers profile option (rust-lang/cargo#16742)
- upgrade to gix@0.81.0 (rust-lang/cargo#16828)
- refactor(network): use async for registry network operations (rust-lang/cargo#16745)
- fix(compile): Don't hide hard warnings with build.warnings=allow (rust-lang/cargo#16827)
- chore: Upgrade incompatible dependencies (rust-lang/cargo#16825)
- fix(compile): build.warnings=allow should not hide denied diagnostics (rust-lang/cargo#16824)
- fix(install): Ignore resolver.lockfile-path (rust-lang/cargo#16823)
- chore(deps): update compatible (rust-lang/cargo#16820)
- refactor(compile): Consolidate output options (rust-lang/cargo#16821)
- refactor: Export public dependencies from internal crates (rust-lang/cargo#16819)
- refactor(progress): Make the code more approachable (rust-lang/cargo#16813)
- Simplified build script bin names in new layout (rust-lang/cargo#16812)
- fix: set CARGO env var during rustc -vV probe (rust-lang/cargo#16811)
- Split out `cargo-util-terminal` (rust-lang/cargo#16809)
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Apr 7, 2026
Update cargo submodule



15 commits in 888f675344eb1cf2308fd53183e667bdd2c58e51..a357df4c26fc14514e66aae2a269456b5545c7db
2026-03-30 16:59:25 +0000 to 2026-04-03 16:47:15 +0000
- chore: downgrade to libz-sys@1.1.24 (rust-lang/cargo#16833)
- feat: add frame-pointers profile option (rust-lang/cargo#16742)
- upgrade to gix@0.81.0 (rust-lang/cargo#16828)
- refactor(network): use async for registry network operations (rust-lang/cargo#16745)
- fix(compile): Don't hide hard warnings with build.warnings=allow (rust-lang/cargo#16827)
- chore: Upgrade incompatible dependencies (rust-lang/cargo#16825)
- fix(compile): build.warnings=allow should not hide denied diagnostics (rust-lang/cargo#16824)
- fix(install): Ignore resolver.lockfile-path (rust-lang/cargo#16823)
- chore(deps): update compatible (rust-lang/cargo#16820)
- refactor(compile): Consolidate output options (rust-lang/cargo#16821)
- refactor: Export public dependencies from internal crates (rust-lang/cargo#16819)
- refactor(progress): Make the code more approachable (rust-lang/cargo#16813)
- Simplified build script bin names in new layout (rust-lang/cargo#16812)
- fix: set CARGO env var during rustc -vV probe (rust-lang/cargo#16811)
- Split out `cargo-util-terminal` (rust-lang/cargo#16809)
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Apr 7, 2026
Update cargo submodule



15 commits in 888f675344eb1cf2308fd53183e667bdd2c58e51..a357df4c26fc14514e66aae2a269456b5545c7db
2026-03-30 16:59:25 +0000 to 2026-04-03 16:47:15 +0000
- chore: downgrade to libz-sys@1.1.24 (rust-lang/cargo#16833)
- feat: add frame-pointers profile option (rust-lang/cargo#16742)
- upgrade to gix@0.81.0 (rust-lang/cargo#16828)
- refactor(network): use async for registry network operations (rust-lang/cargo#16745)
- fix(compile): Don't hide hard warnings with build.warnings=allow (rust-lang/cargo#16827)
- chore: Upgrade incompatible dependencies (rust-lang/cargo#16825)
- fix(compile): build.warnings=allow should not hide denied diagnostics (rust-lang/cargo#16824)
- fix(install): Ignore resolver.lockfile-path (rust-lang/cargo#16823)
- chore(deps): update compatible (rust-lang/cargo#16820)
- refactor(compile): Consolidate output options (rust-lang/cargo#16821)
- refactor: Export public dependencies from internal crates (rust-lang/cargo#16819)
- refactor(progress): Make the code more approachable (rust-lang/cargo#16813)
- Simplified build script bin names in new layout (rust-lang/cargo#16812)
- fix: set CARGO env var during rustc -vV probe (rust-lang/cargo#16811)
- Split out `cargo-util-terminal` (rust-lang/cargo#16809)
@rustbot rustbot added this to the 1.96.0 milestone Apr 7, 2026
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Apr 8, 2026
Update cargo submodule



15 commits in 888f675344eb1cf2308fd53183e667bdd2c58e51..a357df4c26fc14514e66aae2a269456b5545c7db
2026-03-30 16:59:25 +0000 to 2026-04-03 16:47:15 +0000
- chore: downgrade to libz-sys@1.1.24 (rust-lang/cargo#16833)
- feat: add frame-pointers profile option (rust-lang/cargo#16742)
- upgrade to gix@0.81.0 (rust-lang/cargo#16828)
- refactor(network): use async for registry network operations (rust-lang/cargo#16745)
- fix(compile): Don't hide hard warnings with build.warnings=allow (rust-lang/cargo#16827)
- chore: Upgrade incompatible dependencies (rust-lang/cargo#16825)
- fix(compile): build.warnings=allow should not hide denied diagnostics (rust-lang/cargo#16824)
- fix(install): Ignore resolver.lockfile-path (rust-lang/cargo#16823)
- chore(deps): update compatible (rust-lang/cargo#16820)
- refactor(compile): Consolidate output options (rust-lang/cargo#16821)
- refactor: Export public dependencies from internal crates (rust-lang/cargo#16819)
- refactor(progress): Make the code more approachable (rust-lang/cargo#16813)
- Simplified build script bin names in new layout (rust-lang/cargo#16812)
- fix: set CARGO env var during rustc -vV probe (rust-lang/cargo#16811)
- Split out `cargo-util-terminal` (rust-lang/cargo#16809)
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Apr 8, 2026
Update cargo submodule



15 commits in 888f675344eb1cf2308fd53183e667bdd2c58e51..a357df4c26fc14514e66aae2a269456b5545c7db
2026-03-30 16:59:25 +0000 to 2026-04-03 16:47:15 +0000
- chore: downgrade to libz-sys@1.1.24 (rust-lang/cargo#16833)
- feat: add frame-pointers profile option (rust-lang/cargo#16742)
- upgrade to gix@0.81.0 (rust-lang/cargo#16828)
- refactor(network): use async for registry network operations (rust-lang/cargo#16745)
- fix(compile): Don't hide hard warnings with build.warnings=allow (rust-lang/cargo#16827)
- chore: Upgrade incompatible dependencies (rust-lang/cargo#16825)
- fix(compile): build.warnings=allow should not hide denied diagnostics (rust-lang/cargo#16824)
- fix(install): Ignore resolver.lockfile-path (rust-lang/cargo#16823)
- chore(deps): update compatible (rust-lang/cargo#16820)
- refactor(compile): Consolidate output options (rust-lang/cargo#16821)
- refactor: Export public dependencies from internal crates (rust-lang/cargo#16819)
- refactor(progress): Make the code more approachable (rust-lang/cargo#16813)
- Simplified build script bin names in new layout (rust-lang/cargo#16812)
- fix: set CARGO env var during rustc -vV probe (rust-lang/cargo#16811)
- Split out `cargo-util-terminal` (rust-lang/cargo#16809)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cache-messages Area: caching of compiler messages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CARGO env var not set during rustc -vV probe, breaking sccache with RUSTC_WORKSPACE_WRAPPER

5 participants