-
Notifications
You must be signed in to change notification settings - Fork 893
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
rustup 1.25 sets RUSTC, which overrides custom toolchain specified in sub-Cargo invocation #3031
Comments
We set I'm tagging in the author of the commit, @jyn514 so that if he's aware of better ways to do this, we can discuss if we want to do a 1.25.1 of Rustup, or if we should improve our documentation so that others don't fall into this trap in the future. (FYI, the commit in question was merged in #2958 ) |
@kinnison how can I restore to the previous behavior? just remove |
Workaround in the meantime I found: In your main/entry point for xtask: std::env::remove_var("RUSTC");
// These two were apparently already present in rustup 1.24.3
// std::env::remove_var("CARGO"); // This assumes cargo is on PATH
// std::env::remove_var("RUSTUP_TOOLCHAIN");
std::env::remove_var("RUSTDOC"); Removes the injected RUSTC at the level of the wrapper and looks to work ok. Any wrapper around Edit: this only solves some of the problems, if some of your dependencies use wrappers around cargo, it looks like you may be out of luck in the short term with rustup 1.25 Edit 2: I'm not sure what variables used to be populated, I updated the snippet of code to remove all hardcoded paths linked to rust I could see in a printenv |
Would it be possible to update the 1.25.0 blog post with this info? It's reasonably straightforward to work around with |
It's actually a bit trickier to fix this on Windows, because there the Here's roughly what I'm using to work around this, in case it's useful to anyone else: let mut cmd = Command::new("cargo");
cmd.env_remove("RUSTC");
cmd.env_remove("RUSTDOC");
let orig_path = env::var_os("PATH").unwrap_or_default();
let modified_split_paths = env::split_paths(&orig_path).filter(|path| {
!path
.components()
.any(|component| component.as_os_str() == ".rustup")
});
let modified_path = env::join_paths(modified_split_paths).expect("invalid PATH");
cmd.env("PATH", modified_path); |
Starting in rustup 1.25.0, the environment is modified during `cargo` invocations in a way that breaks setting the channel arg (e.g. "+nightly") in a subprocess. Fix by unsetting those variables in the child cargo's env. See rust-lang/rustup#3031
Starting in rustup 1.25.0, the environment is modified during `cargo` invocations in a way that breaks setting the channel arg (e.g. "+nightly") in a subprocess. Fix by unsetting those variables in the child cargo's env. See rust-lang/rustup#3031
From `rustup 1.25.0` the env var `RUSTDOC` is set to avoid having to resolve proxy settings more than once. Since we run under the stable toolchain, it means `RUSTDOC` will point to stable `rustdoc`. This overrides the toolchain we specify with `+`. Clear `RUSTENV` so we can run the `+nightly` toolchain. See rust-lang/rustup#3031 (comment)
From `rustup 1.25.0` the env var `RUSTDOC` is set to avoid having to resolve proxy settings more than once. Since we run under the stable toolchain, it means `RUSTDOC` will point to stable `rustdoc`. This overrides the toolchain we specify with `+`. Clear `RUSTENV` so we can run the `+nightly` toolchain. See rust-lang/rustup#3031 (comment)
The additions rustup makes to PATH were not modified between 1.24 and 1.25.0. I am not sure how it's possible for your PATH changes to affect the 1.25.0 regression. My understanding of the issue is:
|
Thanks, since it sounds like the Windows thing is a separate problem I've filed a new bug for it: #3036 |
This reverts [#4825], which was to address Miri being broken on the latest nightly, possibly due to an issue in rustup. Rustup issue: rust-lang/rustup#3031 [#4825]: #4825
This reverts [#4825], as miri seems to be working again on the latest nightly. I had originally thought it was this issue with rustup which was to blame, but this seems to be wrong: rust-lang/rustup#3031 [#4825]: #4825
Problem
I have a Rust build wrapper (xtask) that invokes Cargo with a custom toolchain
+esp
and a toolchain-specific target--target xtensa-esp32s3-espidf
, so I can use a simple command likecargo xtask build
to cross-compile my project with a more complex command likecargo +esp --target xtensa-esp32s3-espidf
.This works with rustup 1.24, but rustup 1.25 defines RUSTC in the environment of the build wrapper, setting it to the default compiler, which causes the sub-Cargo invocation in the build wrapper to ignore the custom toolchain specified in the
+esp
argument and instead invoke the rustc compiler specified in RUSTC.And since that compiler doesn't support the toolchain-specific target, the invocation fails:
Steps
I don't yet have a set of steps to reproduce, but I'll work on a minimal test case.
Possible Solution(s)
It isn't clear why RUSTC now gets defined in the environment, but if there isn't a good reason for it, then reverting that change would obviously fix the bug. (I'm working around the issue at the moment by undefining RUSTC in the build wrapper before it invokes Cargo.) If there is a good reason for it, then I'm not sure what the solution would be.
Notes
I wonder if #3025 and/or #3029 are related.
Rustup version
Installed toolchains
The text was updated successfully, but these errors were encountered: