Codex uses bundled pnpm instead of host toolchain
Open 💬 24 comments Opened Jun 28, 2026 by kkaatii
What version of the Codex App are you using (From “About Codex” dialog)?
26.623.42026
What subscription do you have?
Pro
What platform is your computer?
Darwin 24.6.0 arm64 arm
What issue are you seeing?
Codex is consistently failing to run my build script because that script invokes pnpm install.
As per its own diagnosis:
- My local projects uses PNPM v10
- Codex comes bundled with PNPM v11 in
~/.cache/codex-runtimes/codex-primary-runtime/dependencies/bin/pnpm - When running the build script, Codex uses the bundled one, leading to failure to resolve dependencies, whereas the build script is run fine in any local terminal
What steps can reproduce the bug?
- Create a pnpm v10 project with dependencies in package.json
- Run
pnpm installin terminal to install the dependencies - Create a js script
```javascript
import { spawn } from "node:child_process";
const child = spawn("pnpm", ["install"], {
cwd: process.cwd(),
stdio: ["ignore", "pipe", "pipe"],
});
child.on("close", (code) => {
process.exit(code ?? 1);
});
```
- Ask Codex (with pnpm v11 bundled) to run
node script.mjsinside project dir
What is the expected behavior?
Codex should use my local pnpm binary, and ask for permission elevation when needed.
In fact, using this to run the build script is fine: PATH="path-to-my-local-nodejs/bin:$PATH" CI=true node script.mjs
Additional information
_No response_
24 Comments
I encountered the same problem in Codex Desktop App
I am seeing the same issue on Windows Codex Desktop.
Codex App: 26.623.8305.0
OS: Windows 11 Education x64, 10.0.26200
Project packageManager: pnpm@10.34.1
User-global pnpm: 10.34.1
Bundled Codex pnpm: 11.7.0
Inside Codex, Get-Command pnpm -All resolves the bundled runtime first:
Running pnpm check uses the bundled pnpm and fails before the project script runs:
Explicitly calling the user-global pnpm works:
This uses pnpm 10.34.1 and passes. pnpm test and pnpm build also pass with the user-global pnpm.
I opened #30541 before noticing this issue. I will close it as a duplicate, but leaving the Windows reproduction details here since the same bundled pnpm shadowing happens on Windows too.
Running into this as well on my mac, exactly the same diagnoses.
I am also running into this same issue since the last codex app update on my mac.
how to solve
Having the same issue. As a workaround, I have told Codex to use Corepack with every pnpm command in agents.md.
I would expect turning off Configuration > Codex dependencies to fix this, but this only seems to affect Node itself.
same for me
Temp solution:
config.toml:``
toml
``[shell_environment_policy]
experimental_use_profile = true
This let agents spawning pwsh with your user pwsh profile
code $profile, put the following at head:CodexAgent_profile.ps1file in dir of$profile, with following content:same
Confirming this is more than a cosmetic PATH mismatch.
On our Windows Codex Desktop setup, the bundled runtime pnpm is taking precedence over the project's host toolchain and this has direct operational impact on agent-driven repo workflows.
Observed behavior in our case:
pnpm@9.15.9pnpm 11.7.0from a Codex-managed runtime path under the user's profile cache (for example:...\.cache\codex-runtimes\...\dependencies\bin\pnpm.cmd)pnpm-workspace.yamlThe critical point is reliability: this reduces the ability of Codex agents to autonomously and safely work through normal project loops such as:
So from an agent-workflow perspective, this is not just a version mismatch. It is a host-vs-bundled toolchain boundary bug.
The bundled runtime for Codex-internal use is understandable. The issue is that the bundled package manager/runtime leaks into user repo command execution instead of staying isolated to Codex-internal use.
We also verified that forcing the host toolchain makes the same repo checks pass normally, which further points to session-level toolchain injection rather than a project-local configuration problem.
Codex App: 26.623.70822
macOS : 15.5
command -v pnpm:/Users/<user-name>/.cache/codex-runtimes/codex-primary-runtime/dependencies/bin/pnpmencountered the same issue; even clearing .cache/codex-runtimes didn't help, as it just rebuilds itself.
I am seeing the same issue in Codex Desktop on macOS.
Additional details:
workspace_dependencies = false.noderesolves to the host nvm-managed Node, butpnpmresolves first to Codex’s bundled runtime path under~/.cache/codex-runtimes/codex-primary-runtime/dependencies/bin/pnpm.PATH, so this does not appear to come from shell startup files.Expected behavior:
When “Codex dependencies” is disabled, bundled package-manager binaries should not shadow the host/project toolchain for repository commands. Bundled runtime tools may still exist for Codex internals, but they should not take precedence for user repo command execution.
Same issue here on Codex Desktop macOS. Repo pins
pnpm@10.34.4, and local nvm/corepack resolves that correctly, but Codex prepends its bundled pnpm:That binary is
pnpm@11.7.0, so scripts/Turbo child tasks that call plainpnpmuse the bundled version instead of the repo-pinned one. In our case this caused repeatednode_modulesrecreation attempts andERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTY.hope this gets fixed soon, this week has been a nightmare to work with codex as my work enviroment uses pnpm 10 also
I hit the same root cause and have a fix branch prepared, but opening a PR is currently restricted to collaborators on this repository.
Compare link: https://github.com/openai/codex/compare/main...Amour1688:fix-runtime-path-precedence?expand=1
This has made Codex a complete nightmare, agreed.
Here's a workaround that worked for me (Mac):
On my machine Codex finds its bundled pnpm runtime as 11.7.0. But if
~/.local/bincomes earlier, pnpm should resolve to the Corepack shim instead. Note:.zshenvis required, because~/.zshrcis for interactive shells only. It should work ok with different pnpm versions across your repos, because corepack should resolve the correct version.I currently use nvm or fnm to manage Node versions, alongside a Node 22 installation via Homebrew; all of these are configured in
~/.zshrc(for interactive shells). However, the Codex App runs in a non-interactive mode, so it does not load~/.zshrc.My temporary workaround is to add the following conditional check to
~/.zshenv:With this in place, executing Node-related commands (such as npm, yarn, or pnpm) will use the binary located at
/usr/local/opt/node@22/bin.If this approach suits your needs, you can adjust the user directory path accordingly. You can determine the correct path by running
which pnpminside the Codex App and then substituting it into the script.Adding a root-cause detail that I don't think has come up yet: PATH precedence isn't the whole story. There's a second mechanism that makes the bundled pnpm ignore
packageManagereven once it's picked up, and fixing PATH alone won't address it.The runtime's pnpm shim exports a flag that disables the
packageManagercheck:packageManagerexists precisely so that a pnpm 11 binary landing in a pnpm 10 repo self-corrects to the pinned version.pnpm_config_pm_on_fail=ignoreturns that off, so it proceeds as 11 instead.Same entrypoint, same repo (pinned to
pnpm@10.24.0), the only difference being that variable:So the bundled binary already resolves correctly on its own — the shim is what prevents it.
Why this matters for the fix: with the flag in place, any path that reaches this shim still silently ignores the repo's version pin, even with PATH precedence corrected. Conversely, dropping the flag makes the bundled pnpm honour
packageManageron its own, which looks like a much smaller change than reordering PATH — and it restores the exact behaviourpackageManageris designed to provide, rather than depending on the user having a correctly-ordered host toolchain.Concrete damage beyond the reported failures. On pnpm 11 the
pnpmfield inpackage.jsonis no longer read:It migrates those settings into a new
pnpm-workspace.yamland rewritespnpm-lock.yaml. Both then show up as unexplained working-tree changes. I nearly committed them into upstream PRs across several worktrees before tracing where they came from. That's a quieter failure mode thanERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTY(which I also hit): nothing errors, the repo just silently acquires a lockfile diff and a new file.Workaround, for anyone without corepack.
env -u pnpm_config_pm_on_fail pnpm ...does not work — the shim re-exports it internally. The variable has to be cleared inside a wrapper that bypasses the shim:This reuses the bundled pnpm rather than requiring a host install, so it works without corepack or nvm/fnm (the corepack suggestions above assume corepack is installed; it isn't on my machine). After this,
pnpm --versionreports 10.24.0 in the pinned repo andpnpm installleaves the tree clean across four worktrees — no lockfile diff, no straypnpm-workspace.yaml.Note
CI=trueis still useful for non-TTY installs, for theERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTYcase others have reported.Environment: macOS (Darwin arm64), Codex CLI, repo pinned to
pnpm@10.24.0, bundled pnpm 11.9.0.When will this get fixed? I use windows and this is a pain.
Codex prefers its bundled pnpm over the host toolchain, and the bundled shim also sets
pnpm_config_pm_on_fail=ignore, sopackageManagerin package.json is ignored.Method:
Get-Command pnpm/which pnpm). If it resolves under~/.cache/codex-runtimes/.../dependencies/bin/fallback, that is the bundled copy.~/.zshenvguard; Windows: User PATH, then a new terminal).packageManagerplus Corepack) and tell the agent in AGENTS.md to call that exact binary, not barepnpm.Evidence: the fallback
pnpmshim exportspnpm_config_pm_on_fail=ignoreand execs the runtime's own Node+pnpm. A current Windows session can resolvepnpm.cmdfrom that fallback directory.Independent community workaround; not an official OpenAI fix.
Running into the same issue on Mac. It's wild that pnpm 10 is completely broken inside of codex and has been for 2 months with no response.
Perhaps they're telling us not to use pnpm 🤔