-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
$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 |
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: