Symlinked ~/.codex/rules/default.rules is ignored when ~/.codex/rules is a real directory
What version of Codex CLI is running?
0.118.0
What subscription do you have?
plus
Which model were you using?
_No response_
What platform is your computer?
_No response_
What terminal emulator and version are you using (if applicable)?
_No response_
What issue are you seeing?
Rules are loaded when ~/.codex/rules/default.rules is a real file, and also when ~/.codex/rules itself is a symlinked directory.
But if ~/.codex/rules/ is a real directory and default.rules inside it is a symlink to another file, Codex appears to ignore the rules entirely.
This looks very similar to the older prompts symlink issue:
- #3637
- fixed by #3643 / commit
fff576cf9
I am not very familiar with the codebase, but I traced this locally with codex and the rules loader seems to still use the pre-fix pattern that prompt loading used to have.
What steps can reproduce the bug?
- Create a valid rules file somewhere outside
~/.codex/rules, for example:
prefix_rule(pattern=["git", "-C", "/Users/me/some-repo", "add", "README.md"], decision="allow")
- Create
~/.codex/rules/as a real directory.
- Create
~/.codex/rules/default.rulesas a symlink to that real rules file.
- Start a fresh Codex CLI session.
- Run a command that should match the rule. For example:
codex exec -C /Users/me/some-repo -c 'approval_policy="never"' 'Run exactly this command and nothing else: git -C /Users/me/some-repo add README.md If it succeeds, reply with exactly OK. If it fails, reply with exactly FAIL: followed by the main error message.'
- Observe that the rule is ignored and the command is denied, for example with:
fatal: Unable to create '/Users/me/some-repo/.git/index.lock': Operation not permitted
For comparison:
- If
~/.codex/rules/default.rulesis a real file, the same rule works. - If
~/.codex/rulesitself is a symlinked directory containing a realdefault.rules, the same rule also works.
What is the expected behavior?
_No response_
Additional information
I also prepared a minimal fix on my fork for comparison, but I cannot open a PR because PR creation is restricted to collaborators on this repo:
- Compare: Epokhe/codex:codex/rules-symlink-fix
- Commit: a463e379f
I am not familiar with the codebase, so I just tried to mirror the earlier prompt symlink fix.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗