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

consider using env::var(CARGO) instead of looking for cargo in PATH #11943

Closed
jyn514 opened this issue Dec 9, 2023 · 1 comment
Closed

consider using env::var(CARGO) instead of looking for cargo in PATH #11943

jyn514 opened this issue Dec 9, 2023 · 1 comment

Comments

@jyn514
Copy link
Member

jyn514 commented Dec 9, 2023

Description

Currently, cargo-clippy hard-codes cargo as the command to run and looks for it in PATH:

let mut cmd = Command::new("cargo");

This means that, e.g., running /home/jyn/.cargo/bin/cargo-clippy directly, without having ~/.cargo in PATH, will not work.

I cannot think of a use case where this would break things, but it makes me a little uncomfortable. Cargo sets the environment variable CARGO for subcommands: https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates
It would be nice if clippy defaulted to that environment variable before falling back to the cargo in PATH.

Version

clippy 0.1.76 (ae25d69dea5 2023-11-17)

Additional Labels

No response

bors added a commit that referenced this issue Dec 10, 2023
Check $CARGO before $PATH

Currently, clippy will ignore $CARGO when spawning cargo commands, which can be problematic for `cargo clippy` and interop with other tools. This commit induces clippy to respect $CARGO in every case it seems likely to matter.

Fixes:
- #11943

changelog: clippy now respects setting the `CARGO` environment variable
@Alexendoo
Copy link
Member

Fixed by #11944

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

No branches or pull requests

2 participants