Skip to content

Conversation

@smoelius
Copy link
Contributor

@smoelius smoelius commented Oct 18, 2025

This PR implements the cargo changes for #11036. The rustup changes were implemented in rust-lang/rustup#4518.

The PR is currently organized as four commits:

  • The first expands the rustup tests to set RUSTUP_TOOLCHAIN_SOURCE. This change is not strictly necessary, but it improves the rustup tests' fidelity.
  • The second moves the pkg function to a location where the next commit can use it.
  • The third implements a test to check the fourth commit's fix.
  • The fourth warns when cargo install is invoked with a non-default toolchain, as indicated by RUSTUP_TOOLCHAIN_SOURCE.

In the third commit, two significant changes were made to simulated_rustup_environment:

  • Previously, the constructed proxy would call an always-panicking executable whenever it was asked to run cargo. Now, the proxy can be made to run the cargo under test.
  • The proxy can now be made to set additional environment variables (e.g., RUSTUP_TOOLCHAIN_SOURCE) before calling the proxied tool.

The PR is currently marked as draft because rust-lang/rustup#4518 has not yet been released. Technically, this PR could be merged before then. But testing it with a fixed rustup would seem to make sense.

Nits are welcome.

cc: @epage

@rustbot rustbot added Command-install S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 18, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 18, 2025

r? @weihanglo

rustbot has assigned @weihanglo.
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

@smoelius smoelius marked this pull request as draft October 18, 2025 09:36
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 18, 2025
@smoelius smoelius force-pushed the second-half-of-11036 branch from 2157847 to 9006944 Compare October 18, 2025 09:52
Copy link
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.

EDIT: The force push was to make Clippy happy.

Feel free to force-push and re-organize your commits during the iterations.

@rustbot

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. label Nov 6, 2025
@smoelius smoelius force-pushed the second-half-of-11036 branch from c64e01a to f0f222f Compare November 6, 2025 23:07
@smoelius
Copy link
Contributor Author

smoelius commented Nov 6, 2025

Just FYI, I know it looks like only some of the comments have been addressed. I am still hoping to get feedback on #16131 (comment) and #16131 (comment).

@rustbot rustbot added A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. A-testing-cargo-itself Area: cargo's tests labels Dec 28, 2025
@smoelius smoelius force-pushed the second-half-of-11036 branch from f75ccb8 to a386ddd Compare December 28, 2025 21:21
@smoelius
Copy link
Contributor Author

smoelius commented Dec 28, 2025

I resolved comments that I thought I implemented uncontroversially. I hope that was okay.

EDIT: I also hid a few of my own comments that were old.

@epage
Copy link
Contributor

epage commented Dec 30, 2025

Please clean up your commits for how they should be reviewed and merged, rather than for how it was developed.

@smoelius smoelius force-pushed the second-half-of-11036 branch 2 times, most recently from 13bd099 to 2e97d39 Compare January 1, 2026 13:34
@smoelius
Copy link
Contributor Author

smoelius commented Jan 1, 2026

I think the PR is ready to be looked at again.

epage added a commit to epage/cargo that referenced this pull request Jan 2, 2026
Thought of this when reviewing new cases for `std::env` in rust-lang#16131.
@smoelius smoelius force-pushed the second-half-of-11036 branch from 2e97d39 to 79a32f6 Compare January 3, 2026 12:40
epage added a commit to epage/cargo that referenced this pull request Jan 5, 2026
Thought of this when reviewing new cases for `std::env` in rust-lang#16131.
epage added a commit to epage/cargo that referenced this pull request Jan 5, 2026
Thought of this when reviewing new cases for `std::env` in rust-lang#16131.
github-merge-queue bot pushed a commit that referenced this pull request Jan 5, 2026
### What does this PR try to resolve?

Thought of this when reviewing new cases for `std::env` in #16131.

### How to test and review this PR?
This is the first of several commits to implement a fix for rust-lang#11036.
The changes fetch the `RUSTUP_TOOLCHAIN_SOURCE` environment variable set
by Rustup, and warn if it is anything other than "default" or "cli".
@smoelius smoelius force-pushed the second-half-of-11036 branch from 79a32f6 to a106b1d Compare January 10, 2026 13:03
@smoelius
Copy link
Contributor Author

I need to fix the commits. I will do that within the next few hours.

@smoelius smoelius force-pushed the second-half-of-11036 branch from a106b1d to bd62811 Compare January 10, 2026 14:13
@smoelius
Copy link
Contributor Author

The commits should be fixed now.

Comment on lines 54 to 63
fn is_default_or_cli_override(&self) -> Option<bool> {
match self {
Self::Default => Some(true),
Self::Environment => Some(false),
Self::CommandLine => Some(true),
Self::OverrideDB => Some(false),
Self::ToolchainFile => Some(false),
Self::Other(_) => None,
}
}
Copy link
Contributor

@epage epage Jan 13, 2026

Choose a reason for hiding this comment

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

Instead of enumerating the cases in the function name, can we describe the policy this functions is meant to convey?

Copy link
Contributor

Choose a reason for hiding this comment

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

is_override_requiring_warning

That doesn't convey any meaning to the caller, requiring them to read the function to understand what is happening

One option is to flip the logic and name it is_implicit_override. I know this variant read better in the caller code but this is the most clear name I can think of to clarify the intent.

@smoelius smoelius force-pushed the second-half-of-11036 branch from bd62811 to 78f7c63 Compare January 14, 2026 11:20
Comment on lines 364 to 374
let report = &[Level::WARNING
.secondary_title(format!(
"default toolchain{maybe_toolchain} implicitly overridden by {source}"
))
.element(Level::HELP.message(format!(
"use `cargo +stable install` if you meant to use the stable toolchain."
)))];
Copy link
Contributor

Choose a reason for hiding this comment

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

in thinking over the warnings message in #16131 (comment), I'm wondering novice users will realize why this is a concern or why this is happening.

One thought is adding:

note: rustup selects the toolchain based on the parent environment and not the environment of the package being installed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I implemented this. Also, I removed the period from the help message for consistency.

Comment on lines 470 to 472
[WARNING] default toolchain `test-toolchain` implicitly overridden by unrecognized source
|
= [HELP] use `cargo +stable install` if you meant to use the stable toolchain.
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't RUSTUP_TOOLCHAIN the active toolchain, not the default, making this

[WARNING] default toolchain implicitly overridden to test-toolchain by unrecognized source

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oof. You're right.

"overridden to test-toolchain" not "overridden with test-toolchain"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went with "with". But I would be happy to change it if you like.

@epage
Copy link
Contributor

epage commented Jan 14, 2026

Thanks for your patience through the rounds of feedback! This is looking great!

@smoelius smoelius force-pushed the second-half-of-11036 branch from 78f7c63 to 5aee235 Compare January 20, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. A-testing-cargo-itself Area: cargo's tests Command-install S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants