Error: Permission denied (os error 13) – Codex seems to need $HOME write permission
Resolved 💬 9 comments Opened Aug 11, 2025 by dlejay Closed Oct 27, 2025
💡 Likely answer: A maintainer (pakrym-oai, contributor)
responded on this thread — see the highlighted reply below.
What version of Codex is running?
codex-cli 0.20.0
Which model were you using?
No idea
What platform is your computer?
Darwin 24.6.0 arm64 arm
What steps can reproduce the bug?
- Install Codex with
brew install codex - Run
codex
What is the expected behavior?
Codex should run correctly.
What do you see instead?
Error: Permission denied (os error 13)
Additional information
In order to “Defend $HOME”, the $HOME folder is not writable.
9 Comments
This is expected, we store session logs in ~/.codex/sessions and have some logic to update config.toml.
Well, this is not what I personally expected as a first
codexexperience, given that on macOS$HOMEis not the recommended default location for app configuration, data, etc.They are correct, this should probably be changed to
$XDG_DATA_HOME/Codexor$XDG_DATA_HOME/Application Support/Codexon MacOS.Most users won't have permissions issues with
$HOME/.codex, but the above change would create more consistent behavior for MacOS users.macOS does not follow the
X Desktop Groupspecifications.The default location is supposed to be
~/Library/Application Support/Codex.Ah, you are correct. I was working from an Apple developer thread that seemed to indicate that
$XDG_DATA_HOMEpointed to~/Library. Tested on my Macbook Sequoia 15.5, doesn't exist. I mostly work on Linux so I didn't double check.So yes,
~/Library/Application Support/Codexwould be the most normal place to store files in a MacOS environment.Notably, you can set
$CODEX_HOMEin your shell to redirect this. I prefer these things to end up in~/.configso I had to set that anyway. I haven't tested yet, but seems like it should work according to the readme?I still second defaulting to Application Support on MacOS installs, as that is the most consistent MacOS place to store app data.
Thanks for the bug report. Codex is working as intended here, so I'm going to close.
what worked for me on MAC OS is getting ownership of the .codex folder below is what I did
sudo chown -R $(whoami) ~/.codexchmod -R 700 ~/.codexI've been experiencing a related issue on macOS with
npm install -g @openai/codex@latest. The installation fails with:Workaround: I have to manually clean up before installing:
However, there's an additional issue: the installed executable lacks execute permissions (
644instead of755), which causesPermission deniederrors. After installation, I have to manually fix it:This suggests the npm package installation process may not be properly preserving file permissions, or there's a cleanup/upgrade issue when updating the package. This compounds the existing permission/directory issues mentioned in this thread.
I am on arch, and this helped me, thank you.