Skip to content

rtk init --codex --uninstall exits 0 when the hook path was refused and the hook may still be registered #4164

Closed

Description

@KuSh

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

Activity

  1. added
    bug
    on Sep 21, 2026
  2. rtk-wshm-sync-bot commented on Sep 21, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 90%

    Summary

    rtk init --codex --uninstall exits 0 even when the containment guard refuses to clean the Codex hook, hiding partial cleanup from scripts

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/hooks/init.rs

    Suggested Actions

    1. Decide exit-code semantics deliberately: dedicated non-zero/non-1 code vs plain failure for partial uninstall
    2. Wire the guard result from uninstall_codex through to the process exit code in src/hooks/init.rs
    3. Cross-reference fix(hooks): keep rtk init --codex inside the project and off the user's files #4119 (introduced the guard) and fs::copy onto a .bak path follows a symlink there, so a cloned repo can redirect rtk init writes outside the project #4157 (related path-traversal in backup copy) when scoping the fix
    4. Flag potential breakage of existing teardown scripts that rely on --uninstall always exiting 0

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. added a commit that references this issue on Oct 6, 2026
    b6b250a
  4. TechWizard9999 commented on Oct 6, 2026

    @TechWizard9999
    Contributor

    Hey @KuSh , sorry this pr was created by AI , I havent reviewed it yet and will see the issue
    Thanks!!

  5. added a commit that references this issue on Oct 22, 2026
    779ff92
  6. added a commit that references this issue on Oct 30, 2026
    2fe9cff
  7. added 2 commits that reference this issue on Nov 2, 2026
    fd68451
    e3dc290
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions