-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Warn when installing with a non-default toolchain #16131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -55,6 +55,13 @@ fn real_rustc_wrapper(bin_dir: &Path, message: &str) -> PathBuf { | |||||||||||||||
| // The toolchain rustc needs to call the real rustc. In order to do that, | ||||||||||||||||
| // it needs to restore or clear the RUSTUP environment variables so that | ||||||||||||||||
| // if rustup is installed, it will call the correct rustc. | ||||||||||||||||
| let rustup_toolchain_source_setup = match std::env::var_os("RUSTUP_TOOLCHAIN_SOURCE") { | ||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should be doing anything based on the rustup we are running in See also #16131 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the risk of sounding like an excuse, I was following the example of the code just below this: cargo/tests/testsuite/rustup.rs Lines 65 to 71 in ff31445
Should that following code be modified? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems suspicious and I'd like to better understand why we do this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just FYI, I'm willing to make changes not directly related #11036. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How would you feel about rustc's path being determined in Cargo's build script rather than via environment variables in this function? That is, I'm proposing that /// Creates an executable which prints a message and then runs the *real* rustc.
fn real_rustc_wrapper(bin_dir: &Path, message: &str) -> PathBuf {
let real_rustc = PathBuf::from(env!("RUSTC"));
let env = vec![("CARGO_RUSTUP_TEST_real_rustc", real_rustc)];
make_exe(
bin_dir,
"rustc",
&format!(
r#"
eprintln!("{message}");
let r = std::process::Command::new(env!("CARGO_RUSTUP_TEST_real_rustc"))
.args(std::env::args_os().skip(1))
.status();
std::process::exit(r.unwrap().code().unwrap_or(2));
"#
),
&env,
)
}EDIT: Also, please tell me whether you think a separate PR would be appropriate. |
||||||||||||||||
| Some(t) => format!( | ||||||||||||||||
| ".env(\"RUSTUP_TOOLCHAIN_SOURCE\", \"{}\")", | ||||||||||||||||
| t.into_string().unwrap() | ||||||||||||||||
| ), | ||||||||||||||||
| None => format!(".env_remove(\"RUSTUP_TOOLCHAIN_SOURCE\")"), | ||||||||||||||||
| }; | ||||||||||||||||
| let rustup_toolchain_setup = match std::env::var_os("RUSTUP_TOOLCHAIN") { | ||||||||||||||||
| Some(t) => format!( | ||||||||||||||||
| ".env(\"RUSTUP_TOOLCHAIN\", \"{}\")", | ||||||||||||||||
|
|
@@ -78,6 +85,7 @@ fn real_rustc_wrapper(bin_dir: &Path, message: &str) -> PathBuf { | |||||||||||||||
| eprintln!("{message}"); | ||||||||||||||||
| let r = std::process::Command::new(env!("CARGO_RUSTUP_TEST_real_rustc")) | ||||||||||||||||
| .args(std::env::args_os().skip(1)) | ||||||||||||||||
| {rustup_toolchain_source_setup} | ||||||||||||||||
| {rustup_toolchain_setup} | ||||||||||||||||
| {rustup_home_setup} | ||||||||||||||||
| .status(); | ||||||||||||||||
|
|
@@ -162,6 +170,7 @@ fn typical_rustup() { | |||||||||||||||
| // `~/.cargo/bin/rustc to use our custom rustup proxies. | ||||||||||||||||
| let path = prepend_path(&cargo_bin); | ||||||||||||||||
| p.cargo("check") | ||||||||||||||||
| .env("RUSTUP_TOOLCHAIN_SOURCE", "default") | ||||||||||||||||
| .env("RUSTUP_TOOLCHAIN", "test-toolchain") | ||||||||||||||||
| .env("RUSTUP_HOME", &rustup_home) | ||||||||||||||||
| .env("PATH", &path) | ||||||||||||||||
|
|
@@ -179,6 +188,7 @@ real rustc running | |||||||||||||||
| p.build_dir().rm_rf(); | ||||||||||||||||
|
|
||||||||||||||||
| p.cargo("check") | ||||||||||||||||
| .env("RUSTUP_TOOLCHAIN_SOURCE", "default") | ||||||||||||||||
| .env("RUSTUP_TOOLCHAIN", "test-toolchain") | ||||||||||||||||
| .env("RUSTUP_HOME", &rustup_home) | ||||||||||||||||
| .env("PATH", &path) | ||||||||||||||||
|
|
@@ -249,6 +259,7 @@ fn custom_calls_other_cargo() { | |||||||||||||||
| // Set these to simulate what would happen when running under rustup. | ||||||||||||||||
| // We want to make sure that cargo-custom does not try to use the | ||||||||||||||||
| // rustup proxies. | ||||||||||||||||
| .env("RUSTUP_TOOLCHAIN_SOURCE", "default") | ||||||||||||||||
| .env("RUSTUP_TOOLCHAIN", "test-toolchain") | ||||||||||||||||
| .env("RUSTUP_HOME", &rustup_home) | ||||||||||||||||
| .with_stderr_data(str![[r#" | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For myself, I'm not too much of a fan of us reusing like this as it hides in the test what is happening and gets annoying when you just need a little customization. Just directly publish the needed package inside of your test.