EACCESS permission issue with `npm install -g @openai/codex`

Resolved 💬 13 comments Opened Jul 8, 2025 by Frulfump Closed Oct 16, 2025
💡 Likely answer: A maintainer (bolinfest, collaborator) responded on this thread — see the highlighted reply below.

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_

View original on GitHub ↗

13 Comments

bolinfest collaborator · 1 year ago

Out of curiosity, what if you drop the -g:

npm install @openai/codex
./node_modules/.bin/codex --version
Frulfump · 1 year ago
Out of curiosity, what if you drop the -g: `` npm install @openai/codex ./node_modules/.bin/codex --version ``

That works, but I want a global install (and that's the instructions in the README as well)

➜ ./node_modules/.bin/codex --version

codex-cli 0.3.0

Interestingly this is missing from the README since a while back why is that?

Never run sudo npm install -g; fix npm permissions instead.

Now codex --login says it will allow me to create an organization on the next page but it just jumps to the "Success login" page.

➜ codex --login

Sign in with ChatGPT to generate an API key or paste one you already have.
[use arrows to move, enter to select]

❯ Sign in with ChatGPT

Paste an API key (or set as OPENAI_API_KEY)

Opening login page in your browser: REDACTED
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.

And codex --free just gives me

➜ codex --free

codex --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?

bolinfest collaborator · 1 year ago

@fouad-openai did something change with codex-mini-latest?

@Frulfump re: npm install -g not working, from the error message, it looks like your version of npm is configured to write /usr/lib/node_modules/@openai/codex, but presumably /usr/lib is owned by root, which is why it doesn't like that?

bolinfest collaborator · 1 year ago

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.

Frulfump · 1 year ago
@Frulfump re: npm install -g not working, from the error message, it looks like your version of npm is configured to write /usr/lib/node_modules/@openai/codex, but presumably /usr/lib is owned by root, which is why it doesn't like that?

Yes /usr/lib is owned by root

➜ ls -ld /usr/lib

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?

Leo-Muo · 1 year ago

Have you tried sudo npm install -g @openai/codex

Frulfump · 1 year ago
Have you tried sudo npm install -g @openai/codex

Nope, 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.

bolinfest collaborator · 1 year ago

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 by root?

Frulfump · 1 year ago

@bolinfest
Yeah probably.

➜ ls -al $(which npm)

lrwxrwxrwx 1 root root 38 May 21 18:27 /usr/bin/npm -> ../lib/node_modules/npm/bin/npm-cli.js

Yupp owned by root

takuma1229 · 9 months ago

Can 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.

// 1) Install nvm
$ curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

// 2) Apply to your shell
$ export NVM_DIR="$HOME/.nvm"
$ [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"

// 3) Install and use the LTS version of Node 
$ nvm use --lts
$ node -v
$ npm -v
Frulfump · 9 months ago
Can 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. `` // 1) Install nvm $ curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash // 2) Apply to your shell $ export NVM_DIR="$HOME/.nvm" $ [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" // 3) Install and use the LTS version of Node $ nvm use --lts $ node -v $ npm -v ``

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.

tibo-openai collaborator · 9 months ago

Thanks! Closing

ghost · 6 months ago

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).