"Permission denied (os error 13)" : codex cli respects HOME value from .env file within project directory

Resolved 💬 0 comments Opened Sep 4, 2025 by tee-writes-code Closed Sep 5, 2025

What version of Codex is running?

codex-cli 0.29.0

Which model were you using?

gpt-5

What platform is your computer?

Microsoft Windows NT 10.0.19045.0 x64 (with WSL2 Ubuntu 24.04)

What steps can reproduce the bug?

  1. Create a new project folder with a .env file containing:
HOME=/something
  1. Run any codex command inside that folder:
  2. Observe the error:
Error: Permission denied (os error 13)

What is the expected behavior?

codex should not be affected by the project's .env file.

What do you see instead?

codex is affected by the project's .env file.

Additional information

When running Codex CLI inside WSL2 (and in VS Code), if the project contains a .env file that sets HOME=..., the CLI picks up this value as its home directory. This makes Codex try to read/write its config and state in a non-existent or inaccessible directory. The result is: Error: Permission denied (os error 13).

Meanwhile, if I comment out or remove the HOME variable from .env, codex cli works normally.

View original on GitHub ↗