core-agent-ide/codex-cli
Prama 4acd7d8617
fix: Improper spawn of sh on Windows Powershell (#318)
# 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](https://github.com/user-attachments/assets/85faaca4-24bc-47c9-8160-4e30df6da4c3)


![image](https://github.com/user-attachments/assets/a13f7adc-52c1-4c0e-af02-e35a35dc45d4)
2025-04-18 11:35:51 -07:00
..
.husky Feat/add husky (#223) 2025-04-17 07:18:43 -07:00
bin fix: Improper spawn of sh on Windows Powershell (#318) 2025-04-18 11:35:51 -07:00
examples fix: typos in prompts and comments (#195) 2025-04-17 07:12:39 -07:00
scripts (fix) update Docker container scripts (#47) 2025-04-16 12:02:41 -07:00
src Fix handling of Shift+Enter in e.g. Ghostty (#338) 2025-04-18 09:19:06 -07:00
tests Fix handling of Shift+Enter in e.g. Ghostty (#338) 2025-04-18 09:19:06 -07:00
.dockerignore (fix) update Docker container scripts (#47) 2025-04-16 12:02:41 -07:00
.editorconfig Initial commit 2025-04-16 12:56:08 -04:00
.eslintrc.cjs Initial commit 2025-04-16 12:56:08 -04:00
.lintstagedrc.json Feat/add husky (#223) 2025-04-17 07:18:43 -07:00
build.mjs Initial commit 2025-04-16 12:56:08 -04:00
Dockerfile chore: reduce docker image size (#194) 2025-04-17 07:12:14 -07:00
HUSKY.md Feat/add husky (#223) 2025-04-17 07:18:43 -07:00
ignore-react-devtools-plugin.js Initial commit 2025-04-16 12:56:08 -04:00
package-lock.json bump(version): 0.1.2504172351 (#310) 2025-04-17 23:53:41 -07:00
package.json fix: Improper spawn of sh on Windows Powershell (#318) 2025-04-18 11:35:51 -07:00
require-shim.js Initial commit 2025-04-16 12:56:08 -04:00
tsconfig.json Back out @lib indirection in tsconfig.json (#111) 2025-04-16 14:16:53 -07:00
vite.config.ts fix: add empty vite config file to prevent resolving to parent (#273) 2025-04-17 17:03:15 -07:00