Custom sandboxing

Resolved 💬 4 comments Opened Oct 3, 2025 by o1lo01ol1o Closed Dec 18, 2025
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What feature would you like to see?

Related to #4665 ; i'd like codex to be able to run a command with a PATH environment that I provide it. Currently, in a nix project, codex seems to be unable to run basic compiler tasks because it cannot enter the nix environment.

Are you interested in implementing this feature?

_No response_

Additional information

_No response_

View original on GitHub ↗

4 Comments

github-actions[bot] contributor · 10 months ago

Potential duplicates detected:

  • #4658

Powered by Codex Action

Meowzz95 · 10 months ago

Are you looking for
https://github.com/openai/codex/blob/main/docs/config.md#sandbox_mode

search for writable_roots

o1lo01ol1o · 10 months ago

@Meowzz95 No, my issue is that nix-shell or the equivalent will load a shell with all my tools for the given project. if I launch codex, codex does not have access to that shell. Codex is not allowed to invoke that shell and, though nix is fast all things considered, it should not reload the shell every time it needs to check the compiler output.

the shell policy should default to all but apparently codex does not take the ambient PATH at execution because it doesn't have any of the tools, including nix-shell:

• Ran cabal test tests
  └ Error: cabal: Could not resolve dependencies:
    [__0] trying: foo-0.1 (user goal)
    … +7 lines
    goals I've had most trouble fulfilling: base, snap-stream, foo

• Ran nix-shell --command 'cabal test tests'
  └ bash: line 1: nix-shell: command not found

> nix-shell isn’t available in this environment (command not found), so the combined command can’t run. If you have Nix installed elsewhere, you could
  invoke the same command there; otherwise we’ll need another way to get the right GHC/base version.

This policy might be able to do something if I could populate it from the given path during the nix shell evaluation:

[shell_environment_policy]
inherit = "all"
set = { PATH = "$NIX_SHELL_PATH" }

But that's already a bit more janky then just passing through the PATH to codex

etraut-openai contributor · 8 months ago

This feature request hasn't received any upvotes or additional posts in over two months, so I'm going to close it out.