Skip to content

Check $CARGO before $PATH #11944

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

Merged
merged 1 commit into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions clippy_dev/src/lint.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{cargo_clippy_path, exit_if_err};
use std::fs;
use std::process::{self, Command};
use std::{env, fs};

pub fn run<'a>(path: &str, args: impl Iterator<Item = &'a String>) {
let is_file = match fs::metadata(path) {
Expand All @@ -13,7 +13,7 @@ pub fn run<'a>(path: &str, args: impl Iterator<Item = &'a String>) {

if is_file {
exit_if_err(
Command::new("cargo")
Command::new(env::var("CARGO").unwrap_or("cargo".into()))
.args(["run", "--bin", "clippy-driver", "--"])
.args(["-L", "./target/debug"])
.args(["-Z", "no-codegen"])
Expand All @@ -23,7 +23,11 @@ pub fn run<'a>(path: &str, args: impl Iterator<Item = &'a String>) {
.status(),
);
} else {
exit_if_err(Command::new("cargo").arg("build").status());
exit_if_err(
Command::new(env::var("CARGO").unwrap_or("cargo".into()))
.arg("build")
.status(),
);

let status = Command::new(cargo_clippy_path())
.arg("clippy")
Expand Down
4 changes: 2 additions & 2 deletions clippy_dev/src/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::ffi::OsStr;
use std::num::ParseIntError;
use std::path::Path;
use std::process::Command;
use std::thread;
use std::time::{Duration, SystemTime};
use std::{env, thread};

/// # Panics
///
Expand All @@ -16,7 +16,7 @@ pub fn run(port: u16, lint: Option<&String>) -> ! {

loop {
if mtime("util/gh-pages/lints.json") < mtime("clippy_lints/src") {
Command::new("cargo")
Command::new(env::var("CARGO").unwrap_or("cargo".into()))
.arg("collect-metadata")
.spawn()
.unwrap()
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/utils/internal_lints/metadata_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ use rustc_span::{sym, Loc, Span, Symbol};
use serde::ser::SerializeStruct;
use serde::{Serialize, Serializer};
use std::collections::{BTreeSet, BinaryHeap};
use std::fmt;
use std::fmt::Write as _;
use std::fs::{self, File};
use std::io::prelude::*;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::{env, fmt};

/// This is the json output file of the lint collector.
const JSON_OUTPUT_FILE: &str = "../util/gh-pages/lints.json";
Expand Down Expand Up @@ -415,7 +415,7 @@ fn get_lint_output(lint_name: &str, example: &[&mut String], clippy_project_root

let prefixed_name = format!("{CLIPPY_LINT_GROUP_PREFIX}{lint_name}");

let mut cmd = Command::new("cargo");
let mut cmd = Command::new(env::var("CARGO").unwrap_or("cargo".into()));

cmd.current_dir(clippy_project_root)
.env("CARGO_INCREMENTAL", "0")
Expand Down
6 changes: 3 additions & 3 deletions lintcheck/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ impl Crate {
//
// The wrapper is set to the `lintcheck` so we can force enable linting and ignore certain crates
// (see `crate::driver`)
let status = Command::new("cargo")
let status = Command::new(env::var("CARGO").unwrap_or("cargo".into()))
.arg("check")
.arg("--quiet")
.current_dir(&self.path)
Expand Down Expand Up @@ -441,7 +441,7 @@ impl Crate {

/// Builds clippy inside the repo to make sure we have a clippy executable we can use.
fn build_clippy() {
let status = Command::new("cargo")
let status = Command::new(env::var("CARGO").unwrap_or("cargo".into()))
.arg("build")
.status()
.expect("Failed to build clippy!");
Expand Down Expand Up @@ -816,7 +816,7 @@ fn lintcheck_test() {
"--crates-toml",
"lintcheck/test_sources.toml",
];
let status = std::process::Command::new("cargo")
let status = std::process::Command::new(env::var("CARGO").unwrap_or("cargo".into()))
.args(args)
.current_dir("..") // repo root
.status();
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl ClippyCmd {
}

fn into_std_cmd(self) -> Command {
let mut cmd = Command::new("cargo");
let mut cmd = Command::new(env::var("CARGO").unwrap_or("cargo".into()));
let clippy_args: String = self
.clippy_args
.iter()
Expand Down