Repository navigation
Closed
Description
What version of Codex is running?
0.80.0
What subscription do you have?
Plus
Which model were you using?
gpt-5.2-codex
What platform is your computer?
Linux 6.8.0-90-generic x86_64 x86_64
What issue are you seeing?
Codex prompts me for every test in needs to run, for example rspec some_spec.rb
What steps can reproduce the bug?
Add a rule file in ~/.codex/rules/ with something like:
# rspec via PATH or binstubs
prefix_rule(
pattern = [["rspec", "bin/rspec", "./bin/rspec"]],
decision = "allow",
justification = "Allow rspec outside the sandbox.",
)
# bundle exec rspec
prefix_rule(
pattern = ["bundle", "exec", "rspec"],
decision = "allow",
justification = "Allow bundle exec rspec outside the sandbox.",
)
Then tell codex to run some test
What is the expected behavior?
Codex runs the test without having to require permissions
Additional information
The problem is that every command is actually prefixed with your shell, for example all the rules that I have that were created automatically go like:
prefix_rule(pattern=["/usr/bin/zsh", "-lc", "APP_ENV=test bundle exec rspec spec/web/gql/operator/query_spec.rb spec/web/gql/operator/mutations/delete_spec.rb"], decision="allow")
So every command is prefixed by my shell /usr/bin/zsh which makes rules useless unless they're an absolute exact match. So there's no way for me to say "run any tests with rspec without requiring permission" while still keeping Codex safe and not allowing everything
Activity
github-actions commentedon Jan 14, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
bolinfest commentedon Jan 14, 2026
@yassenb In general, we have logic that parses invocations like
bash -lc COMMANDinto its constituent parts and runs them through the rules individually:codex/codex-rs/core/src/command_safety/is_safe_command.rs
Lines 30 to 38 in e1447c3
Though we don't match the case when
COMMANDstarts with an env var today.As a workaround, what if you create a wrapper script,
bundle.sh, that does:and create a
prefix_rule()forbundle.sh?yassenb commentedon Jan 15, 2026
Yes, sorry for the confusion, it's indeed the environment variable in the prefix that's causing this not to work for me. Feel free to close this or update the details to point out it's not working only for this case. Thank you.
jon-sully commentedon Feb 6, 2026
For those who ended up here and are having a hard time, key note, you need to restart Codex (the app, the CLI process, or VS Code if you run the extension) before the rule changes take effect. Nonetheless I recommend a bin-stub style wrapper like suggested above... for my Rails app it looks like:
But YMMV. Just remember to restart codex after making rule changes!