Summary
npx agmsg fails on Windows because bin/agmsg.js passes a backslash-separated path to bash.
Reproduction
# Windows 11, PowerShell, Git Bash on PATH
npx agmsg
/bin/bash: C:Users<user>AppDataLocalTempagmsg-bootstrap-OXDr4qsetup.sh: No such file or directory
Root cause
runInstaller() in bin/agmsg.js (L94-95) builds a tempfile path with os.tmpdir() + path.join(), which returns backslash-separated paths on Windows (e.g. C:\Users\...\Temp\agmsg-bootstrap-XXXXXX\setup.sh). This path is passed directly to spawnSync('bash', [setupPath]) at L109, where bash interprets the backslashes as escape characters and mangles the path.
The bug was introduced in 9768445 (PR #100), which replaced the pipe-to-bash flow with a tempfile download. That commit was verified on Debian 12 only.
Proposed fix
Normalise backslashes to forward slashes before handing the path to external processes (bash and curl), while keeping the native-separator path for Node.js filesystem calls (fs.rmSync):
const bashPath = setupPath.replace(/\/g, '/');
The replacement is a no-op on Linux/macOS (no backslashes to replace).
curl -o and bash both accept forward-slash paths on Windows. fs.rmSync continues to use the native tmpDir.
Verification
Tested on Windows 11 (PowerShell, Git Bash on PATH per README recommendation):
node bin/agmsg.js --version — passes
- Path normalisation unit test —
C:\...\setup.sh → C:/.../setup.sh, no backslashes remain
- Linux noop test —
/tmp/... path unchanged by .replace()
- E2E:
node bin/agmsg.js from PowerShell (with Git Bash in PATH) — full install completes successfully
Notes
- On systems with WSL installed,
bash may resolve to WSL's bash.exe (C:\Windows\System32\bash.exe) before Git Bash. This is a separate environment-configuration issue, already documented in the README under "Windows: Git Bash & Codex" with the Set-Alias recommendation. The backslash bug affects all Windows environments regardless of WSL.
- The fix scope is minimal: 1 file, ~3 lines changed, limited to
runInstaller().
- I'm planning to open a PR for this fix. If there are additional verification scenarios or considerations I should address, please let me know.
Summary
npx agmsgfails on Windows becausebin/agmsg.jspasses a backslash-separated path tobash.Reproduction
# Windows 11, PowerShell, Git Bash on PATH npx agmsgRoot cause
runInstaller()inbin/agmsg.js(L94-95) builds a tempfile path withos.tmpdir()+path.join(), which returns backslash-separated paths on Windows (e.g.C:\Users\...\Temp\agmsg-bootstrap-XXXXXX\setup.sh). This path is passed directly tospawnSync('bash', [setupPath])at L109, where bash interprets the backslashes as escape characters and mangles the path.The bug was introduced in
9768445(PR #100), which replaced the pipe-to-bash flow with a tempfile download. That commit was verified on Debian 12 only.Proposed fix
Normalise backslashes to forward slashes before handing the path to external processes (bash and curl), while keeping the native-separator path for Node.js filesystem calls (
fs.rmSync):The replacement is a no-op on Linux/macOS (no backslashes to replace).
curl -oandbashboth accept forward-slash paths on Windows.fs.rmSynccontinues to use the nativetmpDir.Verification
Tested on Windows 11 (PowerShell, Git Bash on PATH per README recommendation):
node bin/agmsg.js --version— passesC:\...\setup.sh→C:/.../setup.sh, no backslashes remain/tmp/...path unchanged by.replace()node bin/agmsg.jsfrom PowerShell (with Git Bash in PATH) — full install completes successfullyNotes
bashmay resolve to WSL'sbash.exe(C:\Windows\System32\bash.exe) before Git Bash. This is a separate environment-configuration issue, already documented in the README under "Windows: Git Bash & Codex" with theSet-Aliasrecommendation. The backslash bug affects all Windows environments regardless of WSL.runInstaller().