Skip to content

feat(install): prefer Homebrew installation on macOS#6

Merged
AnnatarHe merged 1 commit intomainfrom
feat/prefer-homebrew-on-macos
Apr 12, 2026
Merged

feat(install): prefer Homebrew installation on macOS#6
AnnatarHe merged 1 commit intomainfrom
feat/prefer-homebrew-on-macos

Conversation

@AnnatarHe
Copy link
Copy Markdown
Contributor

@AnnatarHe AnnatarHe commented Apr 12, 2026

Summary

  • When macOS is detected and brew is available, prefer brew install shelltime/tap/shelltime over manual binary download
  • Falls back to manual installation if Homebrew install fails
  • Hooks, daemon setup, and shell config remain unchanged regardless of install method
  • Updated CI verification to handle both Homebrew and manual install paths

Test plan

  • Run bash ./install.bash on macOS with Homebrew — should install via brew, set up hooks, and print completion message
  • Run bash ./install.bash on Linux — should use manual download path (unchanged behavior)
  • Verify CI passes on both ubuntu-latest and macos-latest matrix

🤖 Generated with Claude Code


Open with Devin

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>
Copy link
Copy Markdown

@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 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.

Comment thread install.bash
# 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

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.

Suggested change
if brew install shelltime/tap/shelltime; then
if brew list shelltime &>/dev/null || brew install shelltime/tap/shelltime; then

Comment thread install.bash
fi
fi

if [ "$BREW_INSTALLED" = false ]; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The manual installation block (lines 34-194) is now nested within an if statement but lacks indentation. This makes the script significantly harder to read and maintain. Please indent the entire block to reflect the new logical structure.

Comment thread install.bash
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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.

@claude
Copy link
Copy Markdown

claude Bot commented Apr 12, 2026

PR Review: feat(install): prefer Homebrew installation on macOS

Overall this is a clean, well-scoped feature with sensible fallback behavior. A few issues worth addressing before merging.


Bugs / Correctness

1. No verification that shelltime landed in PATH after brew install

brew install succeeding only guarantees the formula installed — it does not confirm the binary is reachable in the current shell's PATH. Apple Silicon Macs have Homebrew in /opt/homebrew/bin, which is not always in PATH for non-interactive script invocations. Consider adding a verification step:

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
fi

2. Stale binary for users re-running after a prior manual install

If someone installed manually before, ~/.shelltime/bin/shelltime exists and is already in their PATH (added to .zshrc/.bashrc). On re-run with Homebrew available, the Homebrew binary installs correctly, but the PATH entry for ~/.shelltime/bin is retained from the first run (the PATH setup block is skipped inside the BREW_INSTALLED=false guard). Depending on PATH ordering, the shell may silently keep using the old manual binary.

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 ~/.shelltime/bin/shelltime exists alongside a Homebrew install.


Code Quality

3. Large unindented block hurts readability

The if [ "$BREW_INSTALLED" = false ]; then ... fi block spans ~165 lines (lines 32-196) with no indentation, making the control flow hard to follow at a glance. The closing fi # end of manual installation block comment helps, but the lack of indentation is the real problem. Consider either indenting the block body or refactoring it into an install_manual() function.

4. curl check placement

curl is required for STEP 2 hook downloads regardless of install method, so the early check is correct. The error message could note that curl is needed for shell hook downloads even on the Homebrew path — low priority.


Security

5. 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.


CI

6. CI will not exercise the Homebrew code path on Actions macos-latest

brew list shelltime will return non-zero on the CI runner since the tap formula is not pre-installed, meaning CI will always fall through to the else branch. The Homebrew code path goes untested in CI — worth noting as a known gap.


Summary

Severity Item
Medium Verify shelltime is reachable in PATH after brew install (1)
Low Document/warn about stale binary when re-running after manual install (2)
Low Indent the manual-install block for readability (3)
Info Homebrew path not covered by CI (6)

Item 1 is the most important to address before merging.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread install.bash
fi
fi

if [ "$BREW_INSTALLED" = false ]; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@AnnatarHe AnnatarHe merged commit 3cf6db8 into main Apr 12, 2026
8 of 13 checks passed
@AnnatarHe AnnatarHe deleted the feat/prefer-homebrew-on-macos branch April 12, 2026 17:55
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.

1 participant