Skip to content

feat(installer): default to ~/.local/bin, no sudo required#69

Merged
renatobardi merged 2 commits intorenatobardi:mainfrom
Edudjr:feat/installer-no-sudo
Apr 17, 2026
Merged

feat(installer): default to ~/.local/bin, no sudo required#69
renatobardi merged 2 commits intorenatobardi:mainfrom
Edudjr:feat/installer-no-sudo

Conversation

@Edudjr
Copy link
Copy Markdown
Contributor

@Edudjr Edudjr commented Apr 17, 2026

Summary

  • Change INSTALL_DIR default from /usr/local/bin to ~/.local/bin — no sudo required
  • Add setup_path() that writes to ~/.profile (shell-agnostic, works with bash/zsh/sh/dash) instead of shell-specific config files
  • Remove the Bash 4+ version check — no Bash 4-only features are used, so macOS's default bash (3.2) works out of the box
  • Remove sudo fallback logic — no longer needed with a user-writable install dir
  • Show actionable source ~/.profile hint when the install dir is not yet in the current session's PATH

Why

The previous installer defaulted to /usr/local/bin which requires sudo on most systems, breaking the curl | bash one-liner experience. The fallback logic was also fragile — it wrote to shell-specific config files (.zshrc, .bashrc, .config/fish/config.fish) rather than the shell-agnostic ~/.profile. Additionally, the Bash 4+ check blocked macOS users unnecessarily since the codebase doesn't actually use any Bash 4-only features.

Test plan

  • Run bash install.sh on macOS with default bash (3.2) — should succeed without errors
  • Verify binary is installed to ~/.local/bin/hapai
  • Verify ~/.profile is updated with PATH entry
  • Run source ~/.profile && hapai version — should print version
  • Run installer a second time — should not duplicate PATH entry in ~/.profile

Edudjr added 2 commits April 17, 2026 02:11
- Change INSTALL_DIR default from /usr/local/bin to ~/.local/bin
- Add setup_path() to register the dir in ~/.profile (shell-agnostic)
- Remove Bash 4+ version check — no Bash 4-only features are used, so macOS default bash (3.2) works fine
- Remove sudo fallback logic — no longer needed with a user-writable install dir
- Show actionable "source ~/.profile" hint when install dir is not yet in PATH
@sonarqubecloud
Copy link
Copy Markdown

@renatobardi renatobardi merged commit 603a83c into renatobardi:main Apr 17, 2026
3 checks passed
renatobardi pushed a commit that referenced this pull request Apr 17, 2026
…sues from PR #69

## Critical Fixes

**1. Restore Bash 4+ requirement** (Critical issue)
- Restored version check in check_deps() that was removed in PR #69
- _lib.sh uses BASH_REMATCH arrays and other Bash 4+ constructs
- Prevents silent failures on macOS (Bash 3.2) and older Linux systems
- Updated CLAUDE.md and README.md to reflect Bash 4+ as CRITICAL requirement

**2. Fix zsh PATH setup regression** (High priority)
- New setup_path() function now detects shell and uses correct RC file
- For zsh: prefers ~/.zprofile (if exists) over ~/.profile
- For bash: uses ~/.bash_profile or ~/.bashrc
- Fixes issue where ~/.profile is not sourced in macOS zsh with custom config
- Users with ~/.zprofile no longer have silent PATH setup failure

**3. Restore error handling and fallback** (High priority)
- Re-added permission error handling in install_from_source() and install_from_github()
- Graceful fallback to ~/.local/bin if INSTALL_DIR is not writable
- Prevents cryptic "set -e" fatal errors when using restricted directories
- Maintains original try-sudo-fallback pattern

**4. Add test coverage** (Minor)
- Added 3 new tests for installer functionality
- Verifies Bash 4+ version check exists
- Tests zsh and bash path detection logic
- Tests path setup for different shell configurations

## Testing

- All 136 tests pass (3 new installer tests added)
- Existing 133 tests unaffected
- Tested on Bash 3.2 (macOS) and Bash 5.0 (Linux)

## Files Changed

- install.sh: Bash check, zsh/.zprofile detection, error handling
- tests/run-tests.sh: 3 new installer tests
- CLAUDE.md: Clarified Bash 4+ as critical requirement
- README.md: Updated Requirements section with Bash 4+ mandate

This PR addresses all findings from code review of #69.
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