Codex CLI can't access any file

Resolved 💬 6 comments Opened Sep 11, 2025 by MartinKnopf Closed Sep 15, 2025

What version of Codex is running?

codex-cli 0.34.0

Which model were you using?

gpt-5

What platform is your computer?

Darwin 24.6.0 x86_64 i386

What steps can reproduce the bug?

  1. Install codex cli: npm i -g @openai/codex
  2. Login with ChatGPT subscription
  3. Create dummy README.md: echo "# Test" > README.md
  4. List directory contents:

<img width="420" height="100" alt="Image" src="https://github.com/user-attachments/assets/d51dbf45-698c-4976-b912-10a0a7aa109b" />

  1. Let codex summarize the file: codex --yolo "summarize README.md"

What is the expected behavior?

A summary of the file.

What do you see instead?

<img width="674" height="350" alt="Image" src="https://github.com/user-attachments/assets/455b1ad8-d40c-4b1b-b2d4-2dfd0f0821c0" />

Additional information

I already deleted ~/.codex and reinstalled codex. Codex is able to create files and in the same session can read those files. But in a new session it can't read those files again.

View original on GitHub ↗

6 Comments

looper200 · 11 months ago

also its can't suggest files using @

MartinKnopf · 11 months ago
also its can't suggest files using @

Thanks for mentioning. Fuzzy search using @ works in interactive mode. But it can't read the files that I point it to.

icianfi · 11 months ago

same issue here, seems sandbox limitation.

minhluuquang · 11 months ago

For anyone running into this problem, here is my case

The Codex cli always runs commands by calling:

bash -lc "your command"

(for example, bash -lc "ls -la" or bash -lc "pwd").

If you’re using fish (or any shell other than bash) as your main shell, this can break if your ~/.bash_profile or ~/.bashrc forces bash to immediately exec into another shell. In my case, my ~/.bash_profile looked like this:

export PATH="${PATH}:${HOME}/.local/bin"
export SHELL=/bin/zsh
exec /bin/zsh -l

Because of the exec /bin/zsh -l, bash never actually ran the command — it just switched over to zsh and stopped, causing empty output for codex cli

Fix:
Check your ~/.bash_profile or ~/.bashrc for any lines like exec /bin/zsh -l (or exec fish -l) and remove them. After I removed that line, Codex worked perfectly again, even though my main shell is still fish.

MartinKnopf · 11 months ago

Thank you @minhluuquang! Your fix worked for me.

Umupa · 10 months ago

I ran into a similar issue and was able to resolve it by integrating the filesystem MCP tool. Here’s the exact configuration that worked for me:

~/.codex/config.toml

[mcp_servers.filesystem]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "/your/project/path"]

With this setup, the Codex CLI can properly access and read files from the specified directory, effectively resolving the file access problem.

Feel free to replace "your/project/path" with the actual path to your project. Hope this helps!