Skip to content
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 environment variable, if set to a proxy, should be changed to match the selected toolchain #4274

Closed
ChrisDenton opened this issue Apr 2, 2025 · 1 comment · Fixed by #4275

Comments

@ChrisDenton
Copy link
Member

ChrisDenton commented Apr 2, 2025

Problem you are trying to solve

This is a follow up to rust-lang/cargo#15099

In short, it used to be that setting the CARGO environment variable to, e.g. $CARGO_HOME/bin/cargo prior to invoking cargo could result in mismatched toolchains when cargo is managed by rustup, E.g. cargo +nightly will run the nightly cargo but later use of the CARGO environment variable would mean running the default toolchain instead (which may be different).

That issue is fixed for newer versions of Cargo but rustup obviously supports installing old versions. Should we make a best effort to ensure the CARGO environment variable is correctly set to the right toolchain when running via a proxy?

Solution you'd like

If running cargo via rustup and if the CARGO environment variable is set to a rustup proxy (e.g. as in rustup managed $CARGO_HOME/bin/cargo) then set CARGO to the actual path for cargo.

Notes

This mimics newer cargo behaviour. We shouldn't go out of our way to fix this in all cases but if a minimal change works around this issue in most cases then it would still be useful, I think.

@djc
Copy link
Contributor

djc commented Apr 3, 2025

Sounds good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants