From 60f35ed7720d20806657ed0411341c759ef446fb Mon Sep 17 00:00:00 2001 From: zenbal <80584946+zenbal@users.noreply.github.com> Date: Wed, 20 Aug 2025 04:18:28 +0200 Subject: [PATCH] fix(shell): relative command path for tests (#13767) --- plugins/shell/src/process/mod.rs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/plugins/shell/src/process/mod.rs b/plugins/shell/src/process/mod.rs index 44f037b015..ed5a697c03 100644 --- a/plugins/shell/src/process/mod.rs +++ b/plugins/shell/src/process/mod.rs @@ -116,13 +116,24 @@ pub struct Output { } fn relative_command_path(command: &Path) -> crate::Result { - match platform::current_exe()?.parent() { - #[cfg(windows)] - Some(exe_dir) => Ok(exe_dir.join(command).with_extension("exe")), - #[cfg(not(windows))] - Some(exe_dir) => Ok(exe_dir.join(command)), - None => Err(crate::Error::CurrentExeHasNoParent), - } + let exe_path = platform::current_exe()?; + + let exe_dir = exe_path + .parent() + .ok_or(crate::Error::CurrentExeHasNoParent)?; + + let base_dir = if exe_dir.ends_with("deps") { + exe_dir.parent().unwrap_or(exe_dir) + } else { + exe_dir + }; + + let mut sidecar_path = base_dir.join(command); + + #[cfg(windows)] + sidecar_path.set_extension("exe"); + + Ok(sidecar_path) } impl From for StdCommand {