You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to locate Codex CLI binaries. Ensure @openai/codex is installed with optional dependencies. #16408
What terminal emulator and version are you using (if applicable)?
VSCode
What issue are you seeing?
Unable to locate Codex CLI binaries. Ensure @openai/codex is installed with optional dependencies.
What steps can reproduce the bug?
the project which I use npx create-next-app@latest --all --yes to create
What is the expected behavior?
I debug the node_modules@openai\codex-sdk\dist\index.js
try {
const codexPackageJsonPath = moduleRequire.resolve(`${CODEX_NPM_NAME}/package.json`);
const codexRequire = createRequire(codexPackageJsonPath);
const platformPackageJsonPath = codexRequire.resolve(`${platformPackage}/package.json`);
vendorRoot = path2.join(path2.dirname(platformPackageJsonPath), "vendor");
} catch(error) {
console.log(error)
throw new Error(
`Unable to locate Codex CLI binaries. Ensure ${CODEX_NPM_NAME} is installed with optional dependencies.`
);
}
the real error shows
TypeError: The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '[project]/Documents/mynextproject/node_modules/@openai/codex/package.json.[json].cjs [app-route] (ecmascript)'
This doesn't look like a Codex bug, but rather a bug in your code that attempts to launch codex. If I'm misunderstanding the problem, let me know. @etraut-openai
the case happened when I use the npm package "@openai/codex-sdk" in the next.js project
import{Codex}from"@openai/codex-sdk";constcodex=newCodex();constthread=codex.startThread();constturn=awaitthread.run("Diagnose the test failure and propose a fix");console.log(turn.finalResponse);console.log(turn.items);
Fixed: I set the Windows user variable:
CODEX_CLI_PATH=C:\Program Files\WindowsApps\OpenAI.Codex_26.820.7780.0_x64__2p2nqsd0c76g0\app\resources\codex.exe
Activity
github-actions commentedon Apr 1, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
etraut-openai commentedon Apr 2, 2026
This doesn't look like a Codex bug, but rather a bug in your code that attempts to launch codex. If I'm misunderstanding the problem, let me know.
zy445566 commentedon Apr 3, 2026
the case happened when I use the npm package "@openai/codex-sdk" in the next.js project
Jian-Mengs commentedon May 21, 2026
mine is this
aideskdevservice commentedon Jun 12, 2026
same here, any solution to fix this?
offcharken commentedon Jun 12, 2026
Fixed: I set the Windows user variable:
CODEX_CLI_PATH=C:\Users\offcharken.codex\packages\standalone\current\bin\codex.exe
black-yt commentedon Jun 13, 2026
更新 Codex App 后出现:
如果之前在 Codex App 里把 Agent Environment 设置成了 WSL,那么实际上系统里可能同时存在 3 个 Codex:
这是在 Windows 终端里执行
codex用的。例如:
这是你在 Ubuntu/WSL 终端里执行
codex用的。例如:
这是 Codex App 为了桥接 Windows 和 WSL 自动生成的启动器。
问题的根源在于:
很多人会误把环境变量设置到:
或者:
结果会出现各种奇怪错误(
.cmd语法错误、node not found等)。正确修复方法:
先找到 App 自动生成的 WSL Wrapper,找到类似:
然后设置:
验证:
重启 Codex App 即可恢复。
onlinecco commentedon Aug 26, 2026
For me, I had to do
setx CODEX_CLI_PATH "C:\Users\<user>\.codex\.sandbox-bin\codex.exe"xkingda24-bot commentedon Aug 26, 2026
Fixed: I set the Windows user variable:
CODEX_CLI_PATH=C:\Program Files\WindowsApps\OpenAI.Codex_26.820.7780.0_x64__2p2nqsd0c76g0\app\resources\codex.exe