codex icon indicating copy to clipboard operation
codex copied to clipboard

feat: allow sandbox to read/write some files/directories anywhere on the machine

Open jdemeulenaere opened this issue 1 year ago • 7 comments

The sandboxed mode currently fails to run gradle commands because it is not allowed to read the ~/.cache/ directory:

    xargs: sysconf(_SC_ARG_MAX) failed
    Exception in thread "main" java.io.FileNotFoundException:
    /Users/jdemeulenaere/.gradle/wrapper/dists/gradle-8.11.1-bin/bpt9gzteqjrbo1mjrsomdt32c/gradle-8.11.1-bin.zip.lck (Operation not permitted)
    	at java.base/java.io.RandomAccessFile.open0(Native Method)
    	at java.base/java.io.RandomAccessFile.open(RandomAccessFile.java:366)
    ... (7 more lines)

It would be nice if we could give read or write access to some files when in sandboxed mode on macOS.

jdemeulenaere avatar Apr 18 '25 14:04 jdemeulenaere

agreed! we should expand the list of "common roots" that are allowed for auto-approval.

fouad-openai avatar Apr 19 '25 02:04 fouad-openai

Thank you for the feedback! Please try the latest version of Codex CLI, as we're actively addressing issues and improving the sandboxing capabilities. If the issue persists, feel free to let us know.

codex-maintainers avatar Aug 07 '25 18:08 codex-maintainers

This persists. I cannot modify ~/.cache

paperbenni avatar Sep 16 '25 13:09 paperbenni

I can't make codex use gradle.

esafak avatar Oct 15 '25 21:10 esafak

The issue persists for me as well

viktor-shymko-hebron avatar Oct 16 '25 18:10 viktor-shymko-hebron

Same here you guys! Cypress write cache in ~/.cache/Cypress and we can't write to it from our codebase sandbox!

A list of directories in config.toml that allows to write would really work!

[sandbox_workspace_write]
external_directories = [ "~/.cache", "~/.local" ]

Are you guys able to implement that?

edoardo-bluframe avatar Oct 18 '25 16:10 edoardo-bluframe

A list of directories in config.toml that allows to write would really work!

Are you guys able to implement that?

Since v0.48.0:

  • https://github.com/openai/codex/releases/tag/rust-v0.48.0
    • --add-dir to add an additional working directory.

      • https://github.com/openai/codex/pull/5335
      • https://github.com/openai/codex/pull/5351

And then not sure exactly what version from, but maybe similar or earlier(?):

  • https://github.com/openai/codex/blob/main/docs/config.md#sandbox_mode
# Extra settings that only apply when `sandbox = "workspace-write"`.
[sandbox_workspace_write]
# ..snip..
# Optional list of _additional_ writable roots beyond $TMPDIR and /tmp.
writable_roots = ["/Users/YOU/.pyenv/shims"]

Edit: Seemingly writable_roots has been around for quite a while. Docs were added August 20th, which implies the feature may have existed even earlier than that:

  • https://github.com/openai/codex/issues/2444
    • https://github.com/openai/codex/pull/2464

Edit 2: It looks like writable_roots may have been first introduced in the following PR back on June 25th:

  • https://github.com/openai/codex/pull/1373

0xdevalias avatar Oct 27 '25 23:10 0xdevalias