EACCESS permission issue with `npm install -g @openai/codex`
What version of Codex is running?
N/A can't install
Which model were you using?
N/A
What platform is your computer?
Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 x86_64
What steps can reproduce the bug?
npm install -g @openai/codex on Ubuntu 24.04 in WSL2
What is the expected behavior?
It installs without issues
What do you see instead?
npm error code EACCES
npm error syscall mkdir
npm error path /usr/lib/node_modules/@openai/codex
npm error errno -13
npm error Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/@openai/codex'
npm error at async mkdir (node:internal/fs/promises:852:10)
npm error at async /usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:624:20
npm error at async Promise.allSettled (index 0)
npm error at async [reifyPackages] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:325:11)
npm error at async Arborist.reify (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:142:5)
npm error at async Install.exec (/usr/lib/node_modules/npm/lib/commands/install.js:150:5)
npm error at async Npm.exec (/usr/lib/node_modules/npm/lib/npm.js:207:9)
npm error at async module.exports (/usr/lib/node_modules/npm/lib/cli/entry.js:74:5) {
npm error errno: -13,
npm error code: 'EACCES',
npm error syscall: 'mkdir',
npm error path: '/usr/lib/node_modules/@openai/codex'
npm error }
npm error
npm error The operation was rejected by your operating system.
npm error It is likely you do not have the permissions to access this file as the current user
npm error
npm error If you believe this might be a permissions issue, please double-check the
npm error permissions of the file and its containing directories, or try running
npm error the command again as root/Administrator.
npm error A complete log of this run can be found in: /home/anon/.npm/_logs/2025-07-08T06_55_50_130Z-debug-0.log
Additional information
_No response_
13 Comments
Out of curiosity, what if you drop the
-g:That works, but I want a global install (and that's the instructions in the README as well)
codex-cli 0.3.0
Interestingly this is missing from the README since a while back why is that?
Now
codex --loginsays it will allow me to create an organization on the next page but it just jumps to the "Success login" page.Sign in with ChatGPT to generate an API key or paste one you already have.
[use arrows to move, enter to select]
Paste an API key (or set as OPENAI_API_KEY)
More info: https://help.openai.com/en/articles/11381614
The model "codex-mini-latest" does not appear in the list of models available to your account. Double-check the spelling (use
openai models list
to see the full list) or choose another model with the --model flag.
And
codex --freejust gives mecodex --free attempting to redeem credits...
Users with Plus or Pro subscriptions can redeem free API credits.
More info: https://help.openai.com/en/articles/11381614
The model "codex-mini-latest" does not appear in the list of models available to your account. Double-check the spelling (use
openai models list
to see the full list) or choose another model with the --model flag.
Why is this "The model "codex-mini-latest" does not appear in the list of models available to your account. Double-check the spelling (use
openai models list
to see the full list) or choose another model with the --model flag." shown for each command?
@fouad-openai did something change with codex-mini-latest?
@Frulfump re:
npm install -gnot working, from the error message, it looks like your version ofnpmis configured to write/usr/lib/node_modules/@openai/codex, but presumably/usr/libis owned by root, which is why it doesn't like that?The sudo warning got dropped as part of https://github.com/openai/codex/pull/1440. I only added the npm stuff back in https://github.com/openai/codex/pull/1475, so I suppose I need to resurrect that line, as well.
Yes /usr/lib is owned by root
drwxr-xr-x 58 root root 4096 May 18 19:23 /usr/lib
I haven't changed anything in relation to npm configuration, should it not try to write to
/usr/lib/node_modules/@openai/codex?Have you tried
sudo npm install -g @openai/codexNope, previously there was a comment in the README stating "Never run sudo npm install -g; fix npm permissions instead." and according to this comment https://github.com/openai/codex/issues/1480#issuecomment-3047668435 it should be brought back.
While the README should still be updated, I think the _fix npm permissions_ part of the advice applies in your case, @Frulfump. What does
ls -al $(which npm)say? Is it also owned byroot?@bolinfest
Yeah probably.
lrwxrwxrwx 1 root root 38 May 21 18:27 /usr/bin/npm -> ../lib/node_modules/npm/bin/npm-cli.js
Yupp owned by
rootCan you tell me the versions of node and npm?
In my case (Ubuntu), I resolved the issue by upgrading the Node version using the following steps.
I think I borked the node (and therefore the npm) install so I just deleted the WSL2 OS and re-did the installation. It works now on
Node 22 and npm 10
Not sure why this is tagged windows-os since it happened on Ubuntu (still on WSL but doesn't seem related to WSL at all).
From my perspective this issue can be closed.
Thanks! Closing
It’s actually not resolved — this bug is still there. Closing the issue should only happen when the problem is resolved for everyone, not just for a few people using workarounds.
For me, it happens 100% of the time: after a fresh installation of a Linux distro, it only works locally or with sudo, which is not the correct or intended behavior (by README).