charmbracelet/crush · warning
failed to get follow flag: %v
Error message
failed to get follow flag: %v
What it means
The `crush logs` command reads the boolean --follow flag via cmd.Flags().GetBool and wraps any lookup failure with this message. As with the other flag lookups, failure means the flag was never registered on the command — the value itself is always parseable for a bool flag.
Source
Thrown at internal/cmd/logs.go:40
var logsCmd = &cobra.Command{
Use: "logs",
Short: "View crush logs",
Long: `View the logs generated by Crush. This command allows you to see the log output for debugging and monitoring.`,
RunE: func(cmd *cobra.Command, args []string) error {
cwd, err := cmd.Flags().GetString("cwd")
if err != nil {
return fmt.Errorf("failed to get current working directory: %v", err)
}
dataDir, err := cmd.Flags().GetString("data-dir")
if err != nil {
return fmt.Errorf("failed to get data directory: %v", err)
}
follow, err := cmd.Flags().GetBool("follow")
if err != nil {
return fmt.Errorf("failed to get follow flag: %v", err)
}
tailLines, err := cmd.Flags().GetInt("tail")
if err != nil {
return fmt.Errorf("failed to get tail flag: %v", err)
}
log.SetLevel(log.DebugLevel)
log.SetOutput(os.Stdout)
if !term.IsTerminal(os.Stdout.Fd()) {
log.SetColorProfile(colorprofile.NoTTY)
}
cfg, err := config.Load(cwd, dataDir, false)
if err != nil {
return fmt.Errorf("failed to load configuration: %v", err)
}
logsFile := filepath.Join(cfg.Config().Options.DataDirectory, "logs", "crush.log")View on GitHub (pinned to 7944b8e522)
Solutions
- Use an official crush build or rebuild from source.
- If developing: ensure `cmd.Flags().Bool("follow", false, "Follow log output")` is registered.
- In tests, register all queried flags before invoking RunE.
Example fix
// before
cmd.Flags().Bool("tail", true, "Number of lines to tail") // follow never registered
// after
cmd.Flags().Bool("follow", false, "Follow log output") Defensive patterns
Strategy: fallback
Validate before calling
if f := cmd.Flags().Lookup("follow"); f == nil {
follow = false // default without -f
} Try / catch
follow, err := cmd.Flags().GetBool("follow")
if err != nil {
follow = false
} Prevention
- Keep flag registration and lookup keys in sync (rename both together).
- Cover each command with an integration test exercising all flags.
- Review fork/patch diffs for dropped cobra flag lines.
- Use a helper to register and return flags atomically.
When it happens
Trigger: RunE querying "follow" when the --follow flag registration is absent (fork/custom build), or RunE invoked programmatically without flag setup.
Common situations: Rebuilt/patched binaries with dropped flag registration; test harnesses constructing the command manually; refactor that renamed the flag but not the lookup key.
Related errors
- failed to get current working directory: %v
- failed to get data directory: %v
- failed to get tail flag: %v
- failed to get data directory: %v
- failed to get debug flag: %v
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/f95c14333aae711b.
Report an issue: GitHub.