Skip to content

Comments

fix: install to ~/.local/bin instead of /usr/local/bin#161

Merged
pszymkowiak merged 1 commit intomasterfrom
fix/install-local-bin
Feb 17, 2026
Merged

fix: install to ~/.local/bin instead of /usr/local/bin#161
pszymkowiak merged 1 commit intomasterfrom
fix/install-local-bin

Conversation

@FlorianBruniaux
Copy link
Collaborator

Summary

  • Install to $HOME/.local/bin instead of /usr/local/bin, removing the need for sudo (closes Don't install to /usr/local/bin #155)
  • Support RTK_INSTALL_DIR env var for custom install path
  • Add PATH guidance in verify() and README for users where ~/.local/bin isn't in PATH

Test plan

  • Run curl ... | sh on a fresh machine — installs without sudo
  • Verify RTK_INSTALL_DIR=/custom/path curl ... | sh respects override
  • Verify PATH warning appears when ~/.local/bin is not in PATH

🤖 Generated with Claude Code

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]>
Copilot AI review requested due to automatic review settings February 17, 2026 07:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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/bin to $HOME/.local/bin, with RTK_INSTALL_DIR override 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
> ```
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
> ```
> ```
>
> 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
> ```

Copilot uses AI. Check for mistakes.
REPO="rtk-ai/rtk"
BINARY_NAME="rtk"
INSTALL_DIR="/usr/local/bin"
INSTALL_DIR="${RTK_INSTALL_DIR:-$HOME/.local/bin}"
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
INSTALL_DIR="${RTK_INSTALL_DIR:-$HOME/.local/bin}"
INSTALL_DIR=${RTK_INSTALL_DIR:-"${HOME:?}/.local/bin"}

Copilot uses AI. Check for mistakes.
Comment on lines +86 to 88
mkdir -p "$INSTALL_DIR"
mv "${TEMP_DIR}/${BINARY_NAME}" "${INSTALL_DIR}/"

Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

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

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment on lines 99 to 104
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
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@pszymkowiak pszymkowiak merged commit 0b34772 into master Feb 17, 2026
8 of 9 checks passed
heAdz0r pushed a commit to heAdz0r/rtk that referenced this pull request Feb 17, 2026
…#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]>
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.

Don't install to /usr/local/bin

2 participants