Skip to content

fix(daemon): propagate error when daemon binary not found on reinstall#279

Merged
AnnatarHe merged 1 commit into
mainfrom
claude/fix-daemon-reinstall-KR3L6
May 19, 2026
Merged

fix(daemon): propagate error when daemon binary not found on reinstall#279
AnnatarHe merged 1 commit into
mainfrom
claude/fix-daemon-reinstall-KR3L6

Conversation

@AnnatarHe
Copy link
Copy Markdown
Contributor

Summary

  • shelltime daemon reinstall on Linux printed a green "✅ Daemon service has been successfully reinstalled!" even when the install step couldn't locate the shelltime-daemon binary — the service was uninstalled and never replaced, but the CLI claimed success.
  • Root cause: commandDaemonInstall swallowed the model.ResolveDaemonBinaryPath() error with return nil after printing a yellow hint, so the reinstall wrapper saw nil and printed the success line.
  • Fix: return a wrapped error so reinstall (and direct daemon install) actually exit non-zero. Also switched the "not found" line from yellow ⚠️ to red ❌ so it reads as the failure it is.

Test plan

  • go build -o /tmp/shelltime ./cmd/cli/main.go — compiles
  • go test -run TestResolveDaemonBinaryPath ./model/ — passes
  • On a Linux box without shelltime-daemon on PATH or under ~/.shelltime/bin/: shelltime daemon reinstall should print the red "not found" line plus install hints, omit the green success line, and exit non-zero
  • With a real shelltime-daemon available on PATH: shelltime daemon reinstall still prints the green success line and exits 0

https://claude.ai/code/session_01LBLq3b7dqsgfcSAEmnWDcY


Generated by Claude Code

`shelltime daemon reinstall` printed "successfully reinstalled" even when
the install step could not locate `shelltime-daemon` (common on Linux
without Homebrew/curl-installer). The install handler swallowed the
ResolveDaemonBinaryPath error with `return nil`, so the reinstall wrapper
treated it as success.

Return a wrapped error instead so the reinstall command exits non-zero
and skips the green success line, and surface the hint in red.

https://claude.ai/code/session_01LBLq3b7dqsgfcSAEmnWDcY
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the commandDaemonInstall function to return an error when the daemon binary is not found, rather than returning nil. It also updates the console output to display a red error message. A review comment suggests returning the error directly instead of wrapping it with a redundant message, as the underlying error is already descriptive and a similar message is printed to the console.

color.Yellow.Println("Install via Homebrew: brew install shelltime/tap/shelltime")
color.Yellow.Println("Or via curl installer: curl -sSL https://shelltime.xyz/i | bash")
return nil
return fmt.Errorf("shelltime-daemon binary not found: %w", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The error message wrapping here is redundant. The err returned by model.ResolveDaemonBinaryPath() already contains a descriptive message (e.g., "shelltime-daemon not found on PATH..."). Additionally, a similar message is already printed to the console on line 45. Wrapping it with the same prefix results in a repetitive output like shelltime-daemon binary not found: shelltime-daemon not found on PATH.... Returning the error directly is cleaner and avoids unnecessary redundancy.

Suggested change
return fmt.Errorf("shelltime-daemon binary not found: %w", err)
return err

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
commands/daemon.install.go 0.00% 2 Missing ⚠️
Flag Coverage Δ
unittests 39.46% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
commands/daemon.install.go 0.00% <0.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AnnatarHe AnnatarHe merged commit dec5e49 into main May 19, 2026
4 of 5 checks passed
@AnnatarHe AnnatarHe deleted the claude/fix-daemon-reinstall-KR3L6 branch May 19, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants