Repository navigation
Description
Follow-up to #4119, raised in review there and not blocking it.
Summary
When the containment guard refuses the hook path, uninstall_codex cleans what it can, reports that the hook was not checked, and returns Ok(()). The process exits 0, so a caller cannot tell that the Codex hook may still be registered.
Cleaning the rest is the right behaviour — refusing to touch RTK.md and AGENTS.md because the hook path is unreachable would leave more behind, not less. The question is only the exit code.
Reproduction
W=$(mktemp -d); mkdir -p "$W/proj" "$W/out/codex"; cd "$W/proj"
ln -s "$W/out/codex" .codex # .codex resolves outside the project
printf 'my notes\n' > RTK.md
printf '@RTK.md\n' > AGENTS.md
printf '{"hooks":{}}\n' > "$W/out/codex/hooks.json"
rtk init --codex --uninstall; echo "exit=$?"Observed
Kept RTK.md: RTK.md (RTK did not write it; remove it yourself if you want it gone)
RTK uninstalled for Codex CLI:
- AGENTS.md: removed @RTK.md reference
Not checked: the Codex hook in .codex/hooks.json, which may still be registered:
.codex/hooks.json resolves to <outside>/hooks.json, outside the project at <project>.
Remove the symlink, or use --global to configure Codex outside the project.
exit=0
<outside>/hooks.json still exists. rtk init --codex --uninstall && echo done prints done.
Expected
An exit code that distinguishes "uninstalled" from "uninstalled what I could reach". The message is already clear for a human reading the terminal; the gap is for anything scripted — CI teardown, a provisioning run, && chains.
Where
uninstall_codex in src/hooks/init.rs. The guard result is rendered into the report and then discarded; nothing carries it to the process exit.
Notes
- Introduced by fix(hooks): keep rtk init --codex inside the project and off the user's files #4119's containment guard, in the sense that before it there was no "refused, so not checked" state to report. It is not a regression against
develop:developwrites through the symlink instead, which is the bug fix(hooks): keep rtk init --codex inside the project and off the user's files #4119 fixes. - Distinct from fs::copy onto a .bak path follows a symlink there, so a cloned repo can redirect rtk init writes outside the project #4157, which is a pre-existing path traversal in the backup copy. Same area, different failure: this one is a refusal reported as success, that one is a write that escapes.
- Worth deciding deliberately rather than by default, since a non-zero exit from
--uninstallmay break existing teardown scripts that currently pass. A dedicated code rather than 1 would let a caller distinguish partial from failed.
Activity
rtk-wshm-sync-bot commentedon Sep 21, 2026
🔍 Automated Triage
bugmediumSummary
rtk init --codex --uninstall exits 0 even when the containment guard refuses to clean the Codex hook, hiding partial cleanup from scripts
📁 Relevant files
src/hooks/init.rsSuggested Actions
Triaged automatically by wshm · This is an automated analysis, not a human review.
fix(init): return exit code 2 when codex uninstall guard refuses hook (…
TechWizard9999 commentedon Oct 6, 2026
Hey @KuSh , sorry this pr was created by AI , I havent reviewed it yet and will see the issue
Thanks!!
fix(init): return exit code 2 when codex uninstall guard refuses hook (…
Merge pull request rtk-ai#4463 from TechWizard9999/fix/4164-codex-uni…
chore(upstream): merge 341 commits from rtk-ai/rtk develop (2 Novembe…
chore(upstream): record rtk-ai/rtk develop 22812af as merged so the n…