Skip to content

fix: Improper spawn of sh on Windows Powershell#318

Merged
tibo-openai merged 1 commit intoopenai:mainfrom
PramaYudhistira:windows-sh-launch
Apr 18, 2025
Merged

fix: Improper spawn of sh on Windows Powershell#318
tibo-openai merged 1 commit intoopenai:mainfrom
PramaYudhistira:windows-sh-launch

Conversation

@PramaYudhistira
Copy link
Copy Markdown
Contributor

@PramaYudhistira PramaYudhistira commented Apr 18, 2025

Fix CLI launcher on Windows by replacing sh-based entrypoint with cross-platform Node script

What's changed

  • This PR attempts to replace the sh-based entry point with a node script that works on all platforms including Windows Powershell and CMD

Why

  • Previously, when installing Codex globally via npm i -g @openai/codex, Windows resulted in a broken CLI issue due to the ps1 launcher trying to execute sh.exe.

  • If users don't have Unix-style shell, running the command will fail as seen below since sh.exe can't be found

  • Output:

& : The term 'sh.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\{user}\AppData\Roaming\npm\codex.ps1:24 char:7
+     & "sh$exe"  "$basedir/node_modules/@openai/codex/bin/codex" $args
+       ~~~~~~~~
   + CategoryInfo          : ObjectNotFound: (sh.exe:String) [], CommandNotFoundException
   + FullyQualifiedErrorId : CommandNotFoundException

How

  • By using a Node based entry point that resolves the path to the compiled ESM bundle and dynamically loads it using native ESM

  • Removed dependency on platform-specific launchers allowing a single entrypoint to work everywhere Node.js runs.

Result

Codex CLI now supports cross-platform and launches correctly via:

  • macOS / Linux
  • Windows PowerShell
  • GitBash
  • CMD
  • WSL

Directly addresses #316

image

image

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 18, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@PramaYudhistira PramaYudhistira changed the title fixed improper spawn of sh on windows fix: Improper spawn of sh on windows powershell Apr 18, 2025
@PramaYudhistira
Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Apr 18, 2025
@PramaYudhistira
Copy link
Copy Markdown
Contributor Author

I have given a description of the issue here
#316

@PramaYudhistira PramaYudhistira changed the title fix: Improper spawn of sh on windows powershell fix: Improper spawn of sh on Windows Powershell Apr 18, 2025
@tibo-openai
Copy link
Copy Markdown
Collaborator

looks good, ty!

@tibo-openai tibo-openai merged commit 4acd7d8 into openai:main Apr 18, 2025
2 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants