Codex Windows app (WSL): non-interactive shell doesn’t load NVM, so node/pnpm are missing from PATH (command not found)
What version of the Codex App are you using (From “About Codex” dialog)?
26.304.1528.0
What subscription do you have?
Plus
What platform is your computer?
Windows 11 and WSL
What issue are you seeing?
Environment:
1) Codex desktop app on Windows
2) Commands executed inside WSL (zsh)
3) Node installed via NVM ($NVM_DIR=$HOME/.nvm)
4) Project uses .nvmrc (example: v22.14.0) and pnpm via Corepack
Problem:
1) In Codex-run command sessions, node is not available (zsh: command not found: node)
2) pnpm is also not available (zsh: command not found: pnpm)
3) Same machine + same repo works fine in a regular WSL terminal
Repro steps:
1) Open Codex app (Windows) with a WSL workspace
2) Run node -v → zsh: command not found: node
3) Run pnpm -v → zsh: command not found: pnpm
Expected:
1) Codex-run shells should have the same Node toolchain availability as a normal WSL terminal session when Node is installed via NVM
2) node, corepack, and pnpm should be usable without manual sourcing
Actual:
1) Non-interactive Codex command sessions do not source NVM init scripts, so NVM-managed Node is not added to PATH
Workaround:
export NVM_DIR="$HOME/.nvm"
. "$NVM_DIR/nvm.sh"
nvm use "$(cat .nvmrc)"
corepack prepare pnpm@10.14.0 --activate
Notes / possible cause:
Codex appears to run non-login / non-interactive shells that don’t source .zshrc/.profile, so NVM isn’t loaded and node isn’t on PATH. A fix could be to launch commands via a login shell or explicitly source the user’s shell init (or at least NVM when NVM_DIR is set).
9 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Mine started doing this last night and got very confused, started using increasingly convoluted path hacks to try and utilize npm etc that have always worked just fine
mine doesn't work at all. no responses. thinking without results, it's just broken on windows 11
I just installed the Codex App. Codex was running node/npm fine 10 minutes before in CLI and VS Extension. After installing the app every time I try to run it, I get: Assertion failed: ncrypto::CSPRNG(nullptr, 0)
I can confirm the exact same problem on an identical platform. Even the model itself confirms that it is running a non-interactive shell:
---
Yes, the comparison confirms it clearly: ~/.zshrc is not loaded in the shell I use by default, but it is loaded when I explicitly start an interactive zsh -i.
Comparison:
In the current shell, neither ll nor node was available.
This shows:
zsh -i, the aliasll='ls -lh'is set.zshrcis loaded.nodeis available and reportsv22.18.0.The additional error messages in
zsh -ihappened because the environment here is read-only andoh-my-zsh/compinittried to create cache files. They are not relevant to the actual conclusion.I'm Codex, and I was able to reproduce a very similar issue on Codex App on Windows with a WSL workspace.
What I observed:
The important distinction is:
~/.zshrc/~/.bashrc, Codex can miss it.For
zshusers, the direction mentioned in older issues/comments still makes sense: put the minimal NVM/Node PATH setup into a file that non-interactivezshactually loads (for example~/.zshenv, with the usual caveats).For
bashusers on Ubuntu/WSL, the equivalent workaround is not.zshenv, but moving the minimal shared toolchain setup above the interactive early-return in~/.bashrc. Example pattern:After doing that and starting a fresh shell / fresh app session,
node,npm,npx, andpnpmbecame available in Codex command execution as well.So from my side this issue looks less like "NVM itself is broken" and more like "Codex App on Windows + WSL is not inheriting the same shell init path as a normal interactive terminal".
A product-level fix would ideally be one of:
zshenv,BASH_ENV, etc.)Hope this helps narrow it down.
This is the issue I found, as well as his solution, after adjustments via Codex, it now works normally on my platform.
To the codex team that is potentially going to work on this, even though the temporary solution of changing ~/.profile or the bash login scripts for
bash -lcworks, this is a nuance bug that further breaks with subagents. The propagation is not properly set up. Subagent command shells inherit a stale environment from the Codex app server instead of starting with the profile/rc starting scripts no matter what. Because of that, shell startup-based PATH setup is skipped, so user-installed commands or program like node, may be missing even though they work in normal bash -lc or bash -ic shells in the main thread. You have to make sure your subagent shells also work!I can reproduce the same class of issue on Windows + WSL, with
fnmrather thannvm.Environment:
26.422.2437.0codex-cli 0.124.0-alpha.210.0.26200.82462.6.3.0/usr/bin/zsh(zsh 5.9)/home/<user>/.../<repo>, not/mnt/cfnm 1.38.1.node-version = 20.19.6.nvmrc;nvmis not installed on this machineDiagnostics:
command -v node-> not foundnode -v->zsh: command not found: nodecommand -v npm-> not foundnpm -v->zsh: command not found: npmcommand -v pnpm-> not foundpnpm -v->zsh: command not found: pnpmcommand -v fnm-> not foundzsh -c 'command -v node; node -v; command -v npm; npm -v'zsh -lc 'command -v fnm; fnm --version; command -v node; node -v; command -v npm; npm -v; command -v corepack; corepack --version'fnm 1.38.1/home/<user>/.local/share/fnm/aliases/default/bin/nodenode -v->v20.19.6npm -v->10.8.2corepack --version->0.34.1On this machine,
fnmis initialized from~/.profile, which adds the fnm directory and the default alias bin directory to PATH. That explains the difference:zsh -lcloads the login profile, while the command session /zsh -cpath does not.Root-cause hypothesis:
Codex command execution in the Windows App + WSL path appears to run a non-login/non-interactive shell. For Node installed via
nvm/fnm, that commonly means the shell init that adds the Node toolchain to PATH is skipped, sonode,npm,corepack, andpnpmdisappear even though the same WSL environment works once the relevant profile/init has been loaded.Low-risk fix direction:
.nvmrcor.node-versionbutnodeis not found in the command environment, and suggest configuring/sourcing the relevantnvm/fnminit.