Skip to content

fix(files-widget): use 'where' instead of 'which' on Windows for dep detection#44

Open
hhelibeb wants to merge 1 commit into
tmustier:mainfrom
hhelibeb:fix/windows-which-compat
Open

fix(files-widget): use 'where' instead of 'which' on Windows for dep detection#44
hhelibeb wants to merge 1 commit into
tmustier:mainfrom
hhelibeb:fix/windows-which-compat

Conversation

@hhelibeb
Copy link
Copy Markdown

Summary

hasCommand() uses which via execSync() to detect whether bat, delta, and glow are installed. On Windows, Node.js's execSync() defaults to cmd.exe as the shell, where which is not a valid command. This causes the check to always fail, and the startup dependency warning fires even when all three tools are installed and on PATH.

Fixes dependency detection for /readfiles on Windows.

Behavior

  • On Windows (process.platform === "win32"), uses where — the Windows command available from the default cmd.exe shell used by Node.js's execSync().
  • On macOS/Linux, keeps which — no change for existing users.

Implementation

Small change in hasCommand() inside utils.ts: platform-conditional command selection before the execSync call.

Testing

  • Verified where bat / where delta / where glow return exit code 0 from cmd.exe on Windows 11.
  • Also verified that bat, delta, and glow are correctly found when hasCommand uses where from a Node.js execSync() context on Windows, regardless of whether pi is launched from PowerShell or Git Bash (on Windows, process.platform is always "win32", so the where path is taken).
  • The which fallback (macOS/Linux path) is kept unchanged; no behavioral regression expected.

…detection

'which' is a Unix command not available in cmd.exe, which Node.js
uses as the default shell on Windows. When running pi from PowerShell
or cmd.exe, 'execSync(`which ${cmd}`)' always fails, causing the
startup dependency check to report bat, delta, and glow as missing
even when they are installed and on PATH.

Use 'where' on Windows (the platform-native equivalent) and keep
'which' on other platforms.

Fixes dependency detection for Windows users of /readfiles.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants