Can't run java command in codex
Resolved 💬 2 comments Opened Jan 27, 2026 by chouzz Closed Jan 30, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor)
responded on this thread — see the highlighted reply below.
What version of Codex is running?
0.91.0
What subscription do you have?
Plus
Which model were you using?
gpt-5.2-codex
What platform is your computer?
Darwin 24.6.0 arm64 arm
What terminal emulator and version are you using (if applicable)?
iTerm2
What issue are you seeing?
Can't run java command in codex.
Java is a very common command, don't understand why it can't find java.
<img width="644" height="548" alt="Image" src="https://github.com/user-attachments/assets/c310865f-ef0f-4633-ad5b-7f42e122e753" />
What steps can reproduce the bug?
- Open codex
- ask it run java --version
- Can't find java command
What is the expected behavior?
It should find the java command.
Additional information
❯ which java
/opt/homebrew/opt/openjdk@21/bin/java
2 Comments
If you're able to repro this, please use the
/feedbackslash command to upload your logs and session details, then post the thread ID here.This is likely because the tool you're using is attempting to perform an action that's not allowed by the Codex sandbox, and it's not dealing well with the error it receives. You will likely need to do some debugging of the issue yourself and/or report the problem to the maintainer of the tool you're using.
@etraut-openai
Thanks for the question! I was able to resolve it locally by moving my Java PATH setup
into my login shell profile. Specifically, I added this to ~/.zprofile:
That fixed it for Codex because it runs commands via
zsh -lc(non‑interactive login), which reads.zprofilebut not.zshrc. After that, java is found correctly.I also looked into the Codex code and found the environment is built from the parent process plus shell -lc execution; so
PATHupdates that live only in.zshrcwon’t be visible. There’s an experimental_use_profile config field defined but it doesn’t seem wired into execution yet. I’m not fully sure it needs a code change, since using.zprofile(or ensuring the parent process PATH is set) works, but it might be worth clarifying in docs or wiring the flag if the project wants .zshrc-style behavior.