feat(install): prefer Homebrew installation on macOS#6
Conversation
When macOS is detected and Homebrew is installed, attempt `brew install shelltime/tap/shelltime` before falling back to manual binary download. This provides better package management (upgrades, uninstalls) for macOS users while keeping the same hook/daemon setup workflow. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces Homebrew as the preferred installation method on macOS and refactors the manual installation logic into a conditional block. The review feedback highlights a potential issue where existing Homebrew installations could trigger an unnecessary fallback, points out missing indentation in the new nested block, and identifies a bug where the binary path is not updated for the current process, which would cause subsequent setup commands to fail.
| # On macOS, prefer Homebrew installation if brew is available | ||
| if [[ "$OS" == "Darwin" ]] && command_exists brew; then | ||
| echo "Homebrew detected on macOS. Attempting to install via brew..." | ||
| if brew install shelltime/tap/shelltime; then |
There was a problem hiding this comment.
The brew install command returns a non-zero exit code if the package is already installed. This triggers the fallback logic and attempts a manual installation, which can lead to duplicate installations (one via Homebrew and one in ~/.shelltime/bin) and user confusion. Checking if the package is already installed prevents this unnecessary fallback.
| if brew install shelltime/tap/shelltime; then | |
| if brew list shelltime &>/dev/null || brew install shelltime/tap/shelltime; then |
| fi | ||
| fi | ||
|
|
||
| if [ "$BREW_INSTALLED" = false ]; then |
| echo "If you know where binaries should be installed on Windows, please open an issue: https://github.com/shelltime/cli" | ||
| fi | ||
|
|
||
| fi # end of manual installation block |
There was a problem hiding this comment.
For manual installations, the binary is moved to ~/.shelltime/bin, but this directory is not added to the current process's PATH. Consequently, the shelltime daemon reinstall call at the end of the script (line 284) will fail during the first installation because the shelltime command won't be found in the current environment. Consider adding export PATH="$HOME/.shelltime/bin:$PATH" within the manual installation block to ensure the binary is available for subsequent setup steps.
PR Review: feat(install): prefer Homebrew installation on macOSOverall this is a clean, well-scoped feature with sensible fallback behavior. A few issues worth addressing before merging. Bugs / Correctness1. No verification that shelltime landed in PATH after brew install
if brew install shelltime/tap/shelltime; then
if command_exists shelltime; then
BREW_INSTALLED=true
echo "Successfully installed shelltime via Homebrew."
else
echo "Homebrew install succeeded but shelltime not found in PATH. Falling back..."
fi
fi2. Stale binary for users re-running after a prior manual install If someone installed manually before, This edge case does not need a full fix now, but at minimum the completion message could mention it, or you could detect and print a warning when Code Quality3. Large unindented block hurts readability The 4. curl check placement
Security5. No checksum verification on downloaded binaries (pre-existing, not introduced here) The manual download path fetches binaries from GitHub Releases without verifying checksums or signatures. Homebrew handles this more safely via formula verification. This PR actually improves security posture for macOS users. CI6. CI will not exercise the Homebrew code path on Actions macos-latest
Summary
Item 1 is the most important to address before merging. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d50de6a4ae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fi | ||
| fi | ||
|
|
||
| if [ "$BREW_INSTALLED" = false ]; then |
There was a problem hiding this comment.
Keep shell config bootstrap outside manual install gate
Wrapping the entire binary-install section in if [ "$BREW_INSTALLED" = false ] means macOS+Homebrew installs skip the fish config bootstrap that used to create ~/.config/fish/config.fish (and related PATH setup). On fresh machines where that file does not already exist, the later hook wiring only runs add_source_to_config when the file exists, so fish users end up with no hook source line after a successful Homebrew install.
Useful? React with 👍 / 👎.
Summary
brewis available, preferbrew install shelltime/tap/shelltimeover manual binary downloadTest plan
bash ./install.bashon macOS with Homebrew — should install via brew, set up hooks, and print completion messagebash ./install.bashon Linux — should use manual download path (unchanged behavior)ubuntu-latestandmacos-latestmatrix🤖 Generated with Claude Code