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
Non-default cargo locations prefer binaries from default locations over their own #13784
Comments
Is there any specific reason that you cannot set RUSTC or other config for your custom tools? If you have your own custom toolchain, rustup can also do that: https://rust-lang.github.io/rustup/concepts/toolchains.html#custom-toolchains For me, I would avoid adding more complexity to the tool discovery, given there are already ways to do it. |
No, there is no (good) specific reasons. I filed this issue is because I think the behavior of cargo here is unexpected. It is nicely documented but we have developers who didn't setup the toolchain, but instead are using it. These developers come from a C world. If they call If I have a custom toolchain of Rust on version 1.77, but my default toolchain, install by rustup and in my path is version 1.50, then my intiution is that
Yea, I understand wanting to avoid additional complexity. Up to you and the cargo maintainers to make the call on what you want to do here! |
GlobalContext::get_tool
should also search in the parent of cargo_exe()
Huh. What you describe sounds surprising, @schultetwin1, and contradictory to gcc's actual documentation on lookup it seems?
Perhaps it is just late and I am misreading their documentation. However, I take that to mean that it does in fact also prefer their "standard" or "default locations" if not overridden using an explicit directive. |
For reference, here is what Jubilee was talking about: https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/Directory-Options.html#index-B. Also here is a good example of how GCC finds exec files.
As we can see that is pretty GCC or toolchain distributor specific, I'll recommend sticking to whatever rustup provides, or creating a custom toolchain override as aforementioned. Going to close this as rustup is already flexible enough. Let us (or rustup team) know if there is something that doesn't quite fit. |
I see, so GCC's documentation is out of date, I suppose. |
Thank you for the feedback and documentation links @workingjubilee and @weihanglo! Sounds good to me. |
Problem
When I have
cargo
installed in two places on my machine, both in a non-default location and in the default location, calls to/path/to/nondefault/rust/bin/cargo build
will result in~/.cargo/bin/rustc
being used instead of/path/to/nondefault/rust/bin/rustc
.Proposed Solution
In
GlobalContext::get_tool()
we should add a search path so the full search order is:Notes
This was already somewhat discussed in #1723 in 2015. This is a follow-up to see if others would be open to this idea in 2024.
The text was updated successfully, but these errors were encountered: