feat: allow sandbox to read/write some files/directories anywhere on the machine
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.
agreed! we should expand the list of "common roots" that are allowed for auto-approval.
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.
This persists. I cannot modify ~/.cache
I can't make codex use gradle.
The issue persists for me as well
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?
A list of directories in
config.tomlthat 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-dirto 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