Cannot run java/jdk commands in macOS sandbox

Resolved 💬 3 comments Opened Sep 20, 2025 by bn3t Closed Oct 30, 2025
💡 Likely answer: A maintainer (bn3t, contributor) responded on this thread — see the highlighted reply below.

What version of Codex is running?

codex-cli 0.39.0

Which model were you using?

gpt-5-codex high

What platform is your computer?

Darwin 25.0.0 arm64 arm

What steps can reproduce the bug?

To do java development I need to have the sandbox be able to run java/jdk related commands. The java command is /usr/bin/java and is using /usr/libexec/java_home. It does a kind a discovery mechanism to run the jdk located in my case in /Library/Java/JavaVirtualMachines/amazon-corretto-24.jdk/Contents/Home.

Somehow some directories are not readable in the sandbox which makes running fail:

❯ codex debug seatbelt /usr/bin/java
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

The target directory where the jdk is installed is readable in the sandbox so by doing:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/amazon-corretto-24.jdk/Contents/Home

I can run the jdk. I gave this information as an instruction to codex and it could run mvn, java, etc. This is a workaround for now.

Copilot made the suggestion that this should be added to the sbpl configuration for the sandbox:

(allow file-read* (subpath "/Library/Java/JavaVirtualMachines"))
(allow file-read* (subpath "/System/Library/Java/JavaVirtualMachines"))
(allow file-read* (subpath "/usr/libexec"))
(allow process-exec (literal "/usr/libexec/java_home"))

Clearly, /System/Library/Java/JavaVirtualMachines is not readable, and that is maybe the problem:

❯ codex debug seatbelt ls /System/Library/Java/JavaVirtualMachines
ls: /System/Library/Java/JavaVirtualMachines: No such file or directory

What is the expected behavior?

Be able to run java and jdk commands from the sandbox.

What do you see instead?

❯ codex debug seatbelt /usr/bin/java
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

Additional information

_No response_

View original on GitHub ↗

3 Comments

bn3t contributor · 11 months ago

The initial analysis contributed by copilot was wrong. I have make a PR where the only change consists in adding the following:

; Allow Java to set CPU type grade when required (allow sysctl-write (sysctl-name "kern.grade_cputype"))
akuter-bc · 11 months ago

Same issue here.

taraskorpach · 10 months ago

+1