Skip to content

Commit b824f02

Browse files
committed
Auto merge of #4624 - sinkuu:workaround_cargo, r=llogiq
Workaround cargo issue on appveyor Use absolute paths for `cargo` and `rustfmt` to workaround rust-lang/cargo#7475. Appveyor passed on my fork: https://ci.appveyor.com/project/sinkuu/rust-clippy/builds/27870367 changelog: none
2 parents 737f0a6 + 248251b commit b824f02

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

clippy_dev/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ regex = "1"
1111
lazy_static = "1.0"
1212
shell-escape = "0.1"
1313
walkdir = "2"
14+
# FIXME: remove this once cargo issue #7475 is fixed
15+
home = "0.5"

clippy_dev/src/fmt.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ fn cargo_fmt(context: &FmtContext, path: &Path) -> Result<bool, CliError> {
140140
args.push("--");
141141
args.push("--check");
142142
}
143-
let success = exec(context, "cargo", path, &args)?;
143+
let success = exec(context, &bin_path("cargo"), path, &args)?;
144144

145145
Ok(success)
146146
}
147147

148148
fn rustfmt_test(context: &FmtContext) -> Result<(), CliError> {
149-
let program = "rustfmt";
149+
let program = bin_path("rustfmt");
150150
let dir = std::env::current_dir()?;
151151
let args = &["+nightly", "--version"];
152152

@@ -173,7 +173,7 @@ fn rustfmt(context: &FmtContext, path: &Path) -> Result<bool, CliError> {
173173
if context.check {
174174
args.push("--check".as_ref());
175175
}
176-
let success = exec(context, "rustfmt", std::env::current_dir()?, &args)?;
176+
let success = exec(context, &bin_path("rustfmt"), std::env::current_dir()?, &args)?;
177177
if !success {
178178
eprintln!("rustfmt failed on {}", path.display());
179179
}
@@ -198,3 +198,12 @@ fn project_root() -> Result<PathBuf, CliError> {
198198

199199
Err(CliError::ProjectRootNotFound)
200200
}
201+
202+
// Workaround for https://github.com/rust-lang/cargo/issues/7475.
203+
// FIXME: replace `&bin_path("command")` with `"command"` once the issue is fixed
204+
fn bin_path(bin: &str) -> String {
205+
let mut p = home::cargo_home().unwrap();
206+
p.push("bin");
207+
p.push(bin);
208+
p.display().to_string()
209+
}

0 commit comments

Comments
 (0)