PATH is overwritten inside of the sandbox

Resolved 💬 7 comments Opened Apr 24, 2025 by mcolyer Closed Aug 7, 2025

What version of Codex is running?

0.1.2504221401

Which model were you using?

o4-mini

What platform is your computer?

darwin | arm64 | 24.4.0

What steps can reproduce the bug?

  • ```

echo ruby --version
```

  • 2 reasoning | 1 tool

What is the expected behavior?

That it respects my rbenv path. It looks like seatbelt might be overriding the PATH which forces the system ruby.

What do you see instead?

 /usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/boots
    trap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:

(stripped my personal paths at the end there)

Additional information

Happy to solve this another way, the goal is just to be able to us the proper ruby here.

View original on GitHub ↗

7 Comments

Githubradiphone5 · 1 year ago
barelyknown · 1 year ago

This isn't a good solution, but for now you can have it run eval "$(rbenv init -)"; COMMAND GOES HERE

barelyknown · 1 year ago

I put the following in my ~/.codex/instructions.md and it seems to work fine for now.

Add this to the front of any shell command. It will ensure that rbenv is loaded and the correct Ruby version is used.

`eval "$(rbenv init - zsh)";`
seiyab · 1 year ago

I'm using mise and codex can't execute npm.

seiyab · 1 year ago

Can we configure bash profile for codex?

seiyab · 1 year ago

I searched documents and found:

  • ~We can set environment variables as configuration~
  • Update: It didn't work in my environment. Maybe its also a bug?
  • Environment:
  • Linux 6.10.14-linuxkit aarch64 unknown
  • It is a docker container on macOS Darwin 24.5.0 arm64 arm
  • PATH should be inherited by default. So this issue is labelled as a bug.

https://github.com/openai/codex/blob/9846adeabf8593458bc9e3cef28e0dd6c89a59d1/codex-rs/config.md#shell_environment_policy

codex-maintainers · 11 months ago

Thank you for the feedback! Please try again on the latest version of Codex CLI. If the issue persists, we'd appreciate a report or contribution to the codex-rs/ implementation. You can find more information in our project update: https://github.com/openai/codex/discussions/1174.