fix: install to ~/.local/bin instead of /usr/local/bin#161
fix: install to ~/.local/bin instead of /usr/local/bin#161pszymkowiak merged 1 commit intomasterfrom
Conversation
Remove sudo requirement by defaulting to $HOME/.local/bin (XDG standard). Supports RTK_INSTALL_DIR env var for custom install path. Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
Pull request overview
Updates the installation experience to install rtk into a user-writable directory by default (avoiding sudo) and adds guidance for ensuring the installed binary is discoverable via PATH.
Changes:
- Default install path changed from
/usr/local/binto$HOME/.local/bin, withRTK_INSTALL_DIRoverride support. - Removed
sudo-based install branch; always creates the install directory and moves the binary there. - Added PATH guidance in the installer’s
verify()output and in the README.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| install.sh | Changes default install directory and updates install/verify flow with PATH guidance. |
| README.md | Documents the new default install location and how to add it to PATH. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| > **Note**: rtk installs to `~/.local/bin` by default. If this directory is not in your PATH, add it: | ||
| > ```bash | ||
| > echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc # or ~/.zshrc | ||
| > ``` |
There was a problem hiding this comment.
This new note documents the default ~/.local/bin install, but it doesn’t mention the newly-added RTK_INSTALL_DIR override described in the PR. Consider extending the note to include how to set RTK_INSTALL_DIR (and that PATH updates should match that directory) so users discover the feature from the README.
| > ``` | |
| > ``` | |
| > | |
| > To install rtk into a different directory, set `RTK_INSTALL_DIR` **before** running the install script: | |
| > ```bash | |
| > export RTK_INSTALL_DIR="$HOME/.rtk/bin" # choose your preferred directory | |
| > ``` | |
| > | |
| > Make sure your `PATH` matches the directory you install to, for example: | |
| > ```bash | |
| > echo 'export PATH="$RTK_INSTALL_DIR:$PATH"' >> ~/.bashrc # or ~/.zshrc | |
| > ``` |
| REPO="rtk-ai/rtk" | ||
| BINARY_NAME="rtk" | ||
| INSTALL_DIR="/usr/local/bin" | ||
| INSTALL_DIR="${RTK_INSTALL_DIR:-$HOME/.local/bin}" |
There was a problem hiding this comment.
INSTALL_DIR default uses $HOME unquoted inside parameter expansion. If HOME contains spaces (or is unset), this can produce an invalid path and surprising install location (e.g., /.local/bin). Consider using a safer default like ${RTK_INSTALL_DIR:-"${HOME:?}/.local/bin"} (or equivalent POSIX-safe check) so the script fails with a clear error when HOME is missing and avoids word-splitting.
| INSTALL_DIR="${RTK_INSTALL_DIR:-$HOME/.local/bin}" | |
| INSTALL_DIR=${RTK_INSTALL_DIR:-"${HOME:?}/.local/bin"} |
| mkdir -p "$INSTALL_DIR" | ||
| mv "${TEMP_DIR}/${BINARY_NAME}" "${INSTALL_DIR}/" | ||
|
|
There was a problem hiding this comment.
The install step now always does mkdir -p + mv without any permission handling. If RTK_INSTALL_DIR is set to a non-writable location (e.g. /usr/local/bin), this will fail with a generic shell error under set -e and no actionable guidance. Consider detecting non-writable dirs (or mkdir/mv failure) and exiting via error with a message instructing users to pick a writable RTK_INSTALL_DIR (or optionally keep a sudo fallback only when explicitly requested).
| mkdir -p "$INSTALL_DIR" | |
| mv "${TEMP_DIR}/${BINARY_NAME}" "${INSTALL_DIR}/" | |
| # Ensure install directory is writable or can be created | |
| if [ -d "$INSTALL_DIR" ]; then | |
| if [ ! -w "$INSTALL_DIR" ]; then | |
| error "Install directory '$INSTALL_DIR' is not writable. Set RTK_INSTALL_DIR to a writable location (e.g. \$HOME/.local/bin) and rerun the installer." | |
| fi | |
| else | |
| INSTALL_PARENT_DIR=$(dirname "$INSTALL_DIR") | |
| if [ ! -w "$INSTALL_PARENT_DIR" ]; then | |
| error "Cannot create install directory '$INSTALL_DIR' (parent '$INSTALL_PARENT_DIR' is not writable). Set RTK_INSTALL_DIR to a writable location (e.g. \$HOME/.local/bin) and rerun the installer." | |
| fi | |
| fi | |
| if ! mkdir -p "$INSTALL_DIR"; then | |
| error "Failed to create install directory '$INSTALL_DIR'. Check permissions or choose a different RTK_INSTALL_DIR." | |
| fi | |
| if ! mv "${TEMP_DIR}/${BINARY_NAME}" "${INSTALL_DIR}/"; then | |
| error "Failed to move binary into '$INSTALL_DIR'. Check permissions or choose a different RTK_INSTALL_DIR." | |
| fi |
| if command -v "$BINARY_NAME" >/dev/null 2>&1; then | ||
| info "Verification: $($BINARY_NAME --version)" | ||
| else | ||
| warn "Binary installed but not in PATH. Add $INSTALL_DIR to your PATH." | ||
| warn "Binary installed but not in PATH. Add to your shell profile:" | ||
| warn " export PATH=\"\$HOME/.local/bin:\$PATH\"" | ||
| fi |
There was a problem hiding this comment.
verify() can report the wrong binary/version: command -v rtk finds the first rtk on PATH, which may be a previously-installed copy (e.g. in /usr/local/bin) rather than the one just placed in $INSTALL_DIR. Also, the PATH guidance is hardcoded to $HOME/.local/bin, which is incorrect when RTK_INSTALL_DIR is used. Consider verifying ${INSTALL_DIR}/${BINARY_NAME} --version and, if it differs from command -v, warn about PATH ordering; and print an export line that uses $INSTALL_DIR (properly quoted/escaped) instead of a fixed path.
…#155) (rtk-ai#161) Remove sudo requirement by defaulting to $HOME/.local/bin (XDG standard). Supports RTK_INSTALL_DIR env var for custom install path. Co-authored-by: Claude Opus 4.6 <[email protected]>
Summary
$HOME/.local/bininstead of/usr/local/bin, removing the need forsudo(closes Don't install to /usr/local/bin #155)RTK_INSTALL_DIRenv var for custom install pathverify()and README for users where~/.local/binisn't in PATHTest plan
curl ... | shon a fresh machine — installs without sudoRTK_INSTALL_DIR=/custom/path curl ... | shrespects override~/.local/binis not in PATH🤖 Generated with Claude Code