Skip to content

Commit a630d21

Browse files
committed
Normalize paths, just not commands
1 parent e4d6384 commit a630d21

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/cmd/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ impl<'w, 'pl> Command<'w, 'pl> {
369369
capture,
370370
)
371371
} else {
372-
let (binary, managed_by_rustwide) = match self.binary {
372+
let (mut binary, managed_by_rustwide) = match self.binary {
373373
Binary::Global(path) => (path, false),
374374
Binary::ManagedByRustwide(path) => (
375375
self.workspace
@@ -381,6 +381,13 @@ impl<'w, 'pl> Command<'w, 'pl> {
381381
),
382382
Binary::__NonExaustive => panic!("do not create __NonExaustive variants manually"),
383383
};
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+
}
384391
let mut cmd = AsyncCommand::new(&binary);
385392

386393
cmd.args(&self.args);

0 commit comments

Comments
 (0)