diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b1ba7a7..7287a1a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -94,13 +94,9 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Remove Broken WSL bash executable + - name: Put Git Bash on PATH if: ${{ matrix.os == 'windows-latest' }} - shell: cmd - run: | - takeown /F C:\Windows\System32\bash.exe - icacls C:\Windows\System32\bash.exe /grant administrators:F - del C:\Windows\System32\bash.exe + run: cygpath -w "$(dirname "$BASH")" >> "$GITHUB_PATH" - uses: Swatinem/rust-cache@v2 diff --git a/src/command.rs b/src/command.rs index 30cb916..ab07ed6 100644 --- a/src/command.rs +++ b/src/command.rs @@ -20,7 +20,22 @@ impl Command { } pub(crate) fn execute(&self) -> Result { - let output = process::Command::new(&self.program) + #[cfg(target_os = "windows")] + let program = std::env::var_os("PATH") + .into_iter() + .flat_map(|path| std::env::split_paths(&path).collect::>()) + .flat_map(|directory| { + ["", ".com", ".exe", ".bat", ".cmd"].map(move |extension| { + directory.join(format!("{}{extension}", self.program)) + }) + }) + .find(|path| path.is_file()) + .unwrap_or_else(|| self.program.clone().into()); + + #[cfg(not(target_os = "windows"))] + let program = &self.program; + + let output = process::Command::new(program) .args(&self.arguments) .output();