rtk-ai/rtk

`rtk init -g` shows redundant "run `rtk init -g`" warning

Open

#1,011 建立於 2026年4月4日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)Rust (2,914 fork)batch import
area:clibugeffort-smallgood first issuepriority:low

倉庫指標

Star
 (48,085 star)
PR 合併指標
 (平均合併 11天 1小時) (30 天內合併 45 個 PR)

描述

Description

Running rtk init -g prints a confusing warning before it has a chance to install the hook:

$ rtk init -g
[rtk] /!\ No hook installed — run `rtk init -g` for automatic token savings

The warning tells the user to run the exact command they're already running.

Steps to Reproduce

  1. Uninstall any existing hooks: rtk init -g --uninstall
  2. Reset the rate-limit marker: rm ~/Library/Application\ Support/rtk/.hook_warn_last
  3. Run rtk init -g
  4. Observe the redundant warning before the hook is installed

Root Cause

maybe_warn() in hook_check.rs fires for all commands except Gain before the command dispatches. When the command is Init, the hook hasn't been installed yet, so the check sees a missing hook and warns.

The warning is also rate-limited to once per day, making it hard to reproduce consistently.

Expected Behavior

rtk init -g should not warn missing hooks nor redundantly recommend running rtk init -g again. If anything, it should indicate that it's about to install the hooks.

貢獻者指南