Skip to content

Commit ce138f3

Browse files
committed
Only normalize rustwide commands, not global commands
1 parent 824eb89 commit ce138f3

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

src/cmd/mod.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -369,27 +369,22 @@ impl<'w, 'pl> Command<'w, 'pl> {
369369
capture,
370370
)
371371
} else {
372-
let (mut binary, managed_by_rustwide) = match self.binary {
372+
let (binary, managed_by_rustwide) = match self.binary {
373+
// global paths should never be normalized
373374
Binary::Global(path) => (path, false),
374-
Binary::ManagedByRustwide(path) => (
375-
self.workspace
375+
Binary::ManagedByRustwide(path) => {
376+
let binary = self.workspace
376377
.expect("calling rustwide bins without a workspace is not supported")
377378
.cargo_home()
378379
.join("bin")
379-
.join(exe_suffix(path.as_os_str())),
380-
true,
381-
),
380+
.join(exe_suffix(path.as_os_str()));
381+
// `cargo_home()` might a relative path
382+
(crate::utils::normalize_path(&binary), true)
383+
}
382384
Binary::__NonExaustive => panic!("do not create __NonExaustive variants manually"),
383385
};
384-
// This is the relative path to a command,
385-
// so we need to normalize it or it won't be found if we change directories
386-
// NOTE: if components.count() == 1, then this is a command that will be looked up in $PATH,
387-
// so we shouldn't normalize it.
388-
if binary.is_relative() && binary.components().count() > 1 {
389-
binary = crate::utils::normalize_path(&binary);
390-
}
391-
let mut cmd = AsyncCommand::new(&binary);
392386

387+
let mut cmd = AsyncCommand::new(&binary);
393388
cmd.args(&self.args);
394389

395390
if managed_by_rustwide {

0 commit comments

Comments
 (0)