Default install to ~/.local/bin to avoid requiring sudo#17
Merged
Conversation
INSTALL_DIR previously defaulted to /usr/local/bin, which is root-owned on stock macOS, forcing every install through sudo. Default to the XDG-style ~/.local/bin instead (still overridable via INSTALL_DIR) and bootstrap PATH in the user's shell RC file when needed, mirroring existing patterns like rustup/pipx. uninstall.sh cleans up the same PATH export it adds.
Both the PATH bootstrap step and the final "installation complete" message independently re-detected the shell RC file with the same case statement. Compute SHELL_PROFILE once and reuse it in both places.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
install.sh/uninstall.shdefaultedINSTALL_DIRto/usr/local/bin, which is root-owned on stock macOS. Even though the scripts already hadsudo_if_install_dir_not_writeable()to skipsudowhen possible, that helper never actually got a chance to skip it because the default target directory itself required elevated privileges — every fresh install prompted for a password.This PR switches the default to the XDG-style
~/.local/bin(a common no-sudo convention, used by tools likepipx,uv,rustup), while keeping/usr/local/binfully supported as an opt-in viaINSTALL_DIR=/usr/local/bin ./install.sh.install.shINSTALL_DIRnow defaults to$HOME/.local/bininstead of/usr/local/bin.$INSTALL_DIRisn't already onPATHfor the current session, appends anexport PATH=...line to the detected shell RC file (.bashrc/.zshrc), idempotently (skips if the exact line is already present), and exports it into the current process too. If the shell can't be detected, prints a manual instruction instead of failing.$SHELL→ RC file in two separate, identicalcaseblocks (once for the new PATH step, once for the final "how to start using Luca" message). Consolidated into a singleSHELL_PROFILEvariable computed once and reused by both.uninstall.shINSTALL_DIRdefault updated to match.README.md~/.local/binas the default and the new PATH-bootstrap step.Notes
PATHalready contains$INSTALL_DIRin the running shell (e.g. because another tool likeuv/rustupalready sources an env file that adds~/.local/bin), the script correctly no-ops on the RC file — it doesn't need to duplicate PATH setup that's already handled elsewhere./usr/local/bin(from before this change) are unaffected; they just won't be found unlessINSTALL_DIR=/usr/local/binis set, or the user re-runs uninstall with that override before switching to the new default location.Test plan
bash -n install.sh/bash -n uninstall.sh— syntax checkbats tests/*.bats— full suite (60/60) passes unchanged, since tests already overrideINSTALL_DIRexplicitlylucafrom~/.local/binwithout sudo; confirmed the "already on PATH" fast path correctly skips redundant RC edits when another tool (uv's~/.local/bin/env) already manages PATH