diff --git a/crates/cargo-util/src/paths.rs b/crates/cargo-util/src/paths.rs index 7dafca6548e..ee314eb69fd 100644 --- a/crates/cargo-util/src/paths.rs +++ b/crates/cargo-util/src/paths.rs @@ -123,41 +123,13 @@ pub fn resolve_executable(exec: &Path) -> Result { }); for candidate in candidates { if candidate.is_file() { - // PATH may have a component like "." in it, so we still need to - // canonicalize. - // Only do so if there are relative path components - let has_relative_path_components = candidate.components().any(|c| { - matches!( - c, - std::path::Component::ParentDir | std::path::Component::CurDir - ) - }); - return Ok(if has_relative_path_components { - // Assure symlinks to programs like 'echo' don't change the file-name after resolution. - // root program like 'coreutils' which relies on the executable name for proper function. - let file_name = candidate - .file_name() - .expect("executables have a file name") - .to_owned(); - let candidate = candidate - .canonicalize()? - .parent() - .expect("a parent is always available for tools called in test-suite") - .join(file_name) - .to_owned(); - if !candidate.is_file() { - continue; - } - candidate - } else { - candidate - }); + return Ok(candidate); } } anyhow::bail!("no executable for `{}` found in PATH", exec.display()) } else { - Ok(exec.canonicalize()?) + Ok(exec.into()) } }