Skip to content

Cannot run java/jdk commands in macOS sandbox #3978

Closed

Description

@bn3t

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

Activity

  1. added
    bug
    on Sep 20, 2025
  2. bn3t commented on Sep 20, 2025

    @bn3t
    ContributorAuthor

    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"))

  3. akuter-bc commented on Oct 1, 2025

    @akuter-bc

    Same issue here.

  4. taraskorpach commented on Oct 3, 2025

    @taraskorpach

    +1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions