-
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
Can't provide custom subcommand in $PATH if it also exists in $CARGO_HOME/bin #6507
Comments
Why would this be a breaking change? |
Because, technically, someone could currently have an environment variable like Although, to be honest, I don't think that any of the two proposed solutions are likely to cause real breakage. Although I would consider the chance of breakage a bit higher for the first solution. |
That sounds like https://xkcd.com/1172 (although xkcd, being satirical, takes the example to the max). As a large aside, conversations around what's a "breaking change" or not or "feature vs bug", which is relevant in things like semver, continue to fascinate me because it's never crystal clear. It's particularly ironic in the issue/PR tracker of semver, where contributors can't tell if a change to the semver spec is breaking or not 😁... Back on topic, the first one seems to be idea, but I agree poses the bigger risk. From the original issue #2189 and the fixing PR #2192 it doesn't sound like this behaviour was intentional, so it would be lovely to fix it in the more straightforward manner. If it's too risky we can go with the slightly more laborious other options like |
I like the "just search Idea 1Introduce a configuration option to control this behavior when desired, like an environment variable named
Then we'd pick a default: probably Idea 2Do both, trying idea 3 first and falling back to idea 1. Idea 3Introduce a Personally, I ran into this issue while working on a project whose environment is controlled by I haven't contributed to Cargo before but this seems simple enough; I'm willing to write a PR for whichever solution to this is desired. |
I am hitting the same issue. It seems that the solution proposed in #2189 would have worked as well by just appending the cargo root to the path rather than pretending it, since it seems that the issue was with some users not having the If that is an acceptable solution, I have a patch ready. |
Is there a reason why Cargo should not look for binaries alongside it first? So in case we have
It would default to |
#11020 is quite nearly a duplicate of this. Closing in favor of that. The solution used for closing that was by not checking |
Oh, I had no idea that was a thing. Is this behavior documented anywhere? I don't see anything about it in these sections for example: https://doc.rust-lang.org/cargo/commands/cargo.html?highlight=$CARGO_HOME/bin/#files, https://doc.rust-lang.org/cargo/guide/cargo-home.html?highlight=bin#directories. |
I honestly can't think of a good place to put it. I feel like most people who are wondering about precedence for this wouldn't look there but there isn't any other central place for using third-party subcommands, only a place for developing them. |
This makes it easier to discover when [this bug][0] is hit. [0]: rust-lang/cargo#6507
Problem
Cargo will always search
$CARGO_HOME/bin
first for custom subcommands. This means that testing subcommands (e.g. usingPATH="$PWD/target/debug:$PATH" cargo my-command
) won't work ifcargo-my-command
is also installed in$CARGO_HOME/bin
.Steps
Possible Solution(s)
$CARGO_HOME/bin
as a fallback location rather than the primary location[breaking-change]
.$CARGO_MY_COMMAND=...
[breaking-change]
.Notes
Output of
cargo version
:cargo 1.31.0 (339d9f9c8 2018-11-16)
Behavior introduced in #2192.
The text was updated successfully, but these errors were encountered: