-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
$CARGO
passed to external subcommands can point to the wrong cargo
if already set
#15099
Comments
How to achieve that? I mean isn't it be like a revert of #11285? |
Feel like one remote cause is the |
If one invokes Are there cases where one would want the If I'm reading #10119 right, that issue is about using Cargo as a library. So I don't think clearing the |
I'm going to boldly assume #15099 (comment) is not crazy and cc some rustup maintainers. @ChrisDenton @djc @rami3l My question comes down to: should the For completeness, @Alexendoo poses a different solution in #15099 (comment). |
@smoelius Hmmm there doesn't seem to be any mention of |
I think we should fail the invocation if the |
That the variable is not handled at all (by the proxy) is my takeaway as well.
It looks like it is read by many tools: https://github.com/search?q=var%28%22CARGO%22%29&type=code This specific issue arose because Clippy reads the variable: https://github.com/rust-lang/rust-clippy/blob/e02c8857e83e9113c29e8bd2b429f62dfaba04a7/src/main.rs#L110
Please see my response to djc below.
I may be misunderstanding what you mean. But I think the issue is specifically about
I think failing the invocation would be better than the current situation (i.e., allowing the command to proceed with the wrong
In fairness, the problem is subtle. As @Alexendoo explains in rust-lang/rust-clippy#14045 (comment):
@rami3l Your question ("Maybe it's better to handle this logic over there if possible?") is fair, and may be the right answer. But please notice that Thank you both for your responses. It looks like there are currently two options:
Are there other options? Do folks have strong opinions regarding these two? |
I suppose the question is if there are good use cases for having a |
@smoelius Thanks a lot for your clarification! This looks like a cargo-calling-rustup issue so indeed it's specific to rustup. And, from my perspective, it looks like rustup needs to start following some external convention. If it's already established somewhere and our not responding (such as sending a warning instead of actually doing anything) is not an option, I guess we would have to add more magic (such as wiping $CARGO) following the current direction, because, as a user, I have no idea why calling @weihanglo This is a bit off-topic, but recursive calls are also exactly why it's so difficult for me to add a proper lock to rustup in rust-lang/rustup#988, where a common locking scheme can also be broken by considering |
The original case that ran into it was along the lines of fn main() {
cmd!("cargo clippy");
cmd!("cargo +nightly clippy");
} Which seems like a perfectly fine use case, if it were instead written as a shell script it would work as expected. Similarly the equivalent but with fn main() {
cmd!("cargo check");
cmd!("cargo +nightly check");
} |
I feel like it is a bit too much for rustup to handle this. For example, Users running nested cargo calls should be cautious to whatever it really calls by themselves, especially when nested switching toolchains. Cargo doesn't have well-supported story for this kind of use case, as it needs to make too many assumptions on user's behalf.
If I understand this correctly, this is the issue mentioned eariler that |
My view of it is that Since the rustup proxy knows it's about to call the real I don't think it's necessarily on rustup to solve but it seems like a pragmatic solution
Yeah, it's something specific to external subcommands and perhaps build scripts. For example you can hit the same issue with |
In the cases you mention, @weihanglo, I think the proxy would run. In other words, if we're going to address this, I feel like the proxy would be an appropriate place to do it. I would be happy to submit a PR to "fix" this (and include those as test cases). I think we just need to agree on what the "fix" is. Ideas that have been floated at this point include:
I'm sensing that @Alexendoo prefers to clear
Opinions? |
I don't really have a use case in mind, perhaps valgrind? |
I've created a PR here: rust-lang/rustup#4175 Everyone is welcome to comment. The approach I've taken is to clear the
@weihanglo I've tried to do some searching, but I cannot tell whether this is a common practice. Put another way, I would expect people to set Because of the warnings, I think my changes should be easy to identify if they break people's workflows. |
@smoelius Thanks for your contribution! Adding a warning is definitely worthwhile. However, I'm still not sure if we should make I don't expect
... at least you won't be able to In other words, you could imagine if somehow |
@smoelius Yes, I think that'll be the most appropriate way forward. |
Does anyone else have an opinion? @rami3l I'm going to wait at least 24 hours before modifying the PR. |
I think if we can make it work we should, as it did before 1.67 Issuing a warning and clearing the variable both effectively mean specifying It seems unlikely that somebody would intentionally specify |
What if we only emitted a warning, but the message said something like:
Would that be acceptable to everyone? |
I updated the PR, though I softened the language from "will be cleared" to "may be cleared". |
So I'm working to catch up on this. It sounds like there are the following care abouts
#11285 broke the (1) to fix (2) and (3). It did so by setting the precedence in
I'm uncomfortable with a rustup solution because this isn't inherently a rustup problem This can happen in other cases like cargo script invoked via rustup spawning the In the Cargo team meeting, someone brought up users manually unsetting Building off of the idea in #15099 (comment), my proposed solution is that cargo-the-bin opts-in to different behavior than the default. default-behavior (when using cargo-the-library):
opt-in behavior (set by cargo-the-bin):
Characteristics
|
@epage Thank you very much for your reply. Just to be sure I understand:
You're saying cargo-the-bin should set the So, for example, if nightly cargo-the-bin is run and finds that Should a warning be issued in that case, or should the override happen silently? |
imo overriding Cargo also tends to avoid warnings that can't be reasonably silenced. We hope to one day have #12235 resolved but that will be project focused and not invocation focused. We do not have plans atm for invocation-focused lint control. |
Overwrite `$CARGO` when the current exe is detected to be a cargo binary. See: rust-lang#15099 (comment)
Overwrite `$CARGO` when the current exe is detected to be a cargo binary. See: rust-lang#15099 (comment)
Overwrite `$CARGO` when the current exe is detected to be a cargo binary. See: rust-lang#15099 (comment)
Overwrite `$CARGO` when the current exe is detected to be a cargo binary. See: rust-lang#15099 (comment)
Overwrite `$CARGO` when the current exe is detected to be a cargo binary. See: rust-lang#15099 (comment)
Overwrite `$CARGO` when the current exe is detected to be a cargo binary. See: rust-lang#15099 (comment)
Overwrite `$CARGO` when the current exe is detected to be a cargo binary. From #15099 (comment): > opt-in behavior (set by cargo-the-bin): > > 1. `from_current_exe` if its `cargo[EXE_SUFFIX]` > 2. `from_argv` if its `cargo[EXE_SUFFIX]` > 3. `from_env` > 4. `from_current_exe` > 5. `from_argv` r? @epage
Fixed via #15208 |
Problem
Observed in rust-lang/rust-clippy#14045, if
cargo +nightly clippy
is ran by a process withCARGO
pointing to the stablecargo
then nightlyclippy-driver
will be ran by stablecargo
In this case that resulted in a confusing warning
Steps
Put the following into your
PATH
ascargo-foo
With stable cargo use
cargo run
onThe output will be
.../.rustup/toolchains/stable-.../bin/cargo
Possible Solution(s)
Looks to be due to #11285, perhaps there could be an exception for when the current exe really is
cargo
Notes
No response
Version
The text was updated successfully, but these errors were encountered: