Skip to content

Installers: add ~/.local/bin to PATH automatically and show a first command that works #1214

Description

@nc9

Problem

When none of the installer's common bin directories is on PATH, install.sh falls back to ~/.local/bin and stops at printing instructions:

Warning: ~/.local/bin is not in your PATH
Add to ~/.zshrc:
  export PATH="~/.local/bin:$PATH"

That's common on a Mac without Homebrew and in fresh Linux shells. Three things go wrong on the first run:

  1. The closing message prints squirrel audit https://your-site.com before the PATH warning. Someone who copies the first command gets command not found and may give up.
  2. Nothing is written for them, so a user who skims past the warning has a binary they can't run, in this shell or the next one.
  3. install.ps1 has the same gap on Windows: it prints a SetEnvironmentVariable line for the user to run instead of adding the directory.

detect_shell_config already works out the right rc file from $SHELL (zsh, bash, fish, sh), and find_bin_dir already prefers a writable directory that's on PATH, but only from a fixed list of four (~/.local/bin, ~/bin, /usr/local/bin, /opt/homebrew/bin).

Other installers (Bun, Deno, rustup, uv) add their bin directory to the shell profile by default, with an opt-out.

Proposed behaviour

Keep the directory choice as it is. SQUIRREL_BIN_DIR wins, then the existing four common dirs when one is already on PATH and writable. Don't scan PATH for other directories: like uv and pipx, squirrel's own place is ~/.local/bin.

Otherwise install to ~/.local/bin and add it to PATH, the way Bun, Deno, rustup and uv add their bin dirs, idempotently, in the rc file the shell actually reads:

Shell File Line
zsh ${ZDOTDIR:-$HOME}/.zshrc export PATH="$HOME/.local/bin:$PATH"
bash, macOS ~/.bash_profile (Terminal opens login shells) same
bash, Linux ~/.bashrc same
fish ~/.config/fish/conf.d/squirrel.fish fish_add_path $HOME/.local/bin
sh / unknown ~/.profile same as zsh
  • Wrap the line in a marker comment (# squirrel) and skip the write when the marker or the directory is already present, so rerunning the installer never adds a second line.
  • Create the file if it doesn't exist. Never rewrite or reorder existing content: append only.
  • Opt out with SQUIRREL_NO_MODIFY_PATH=1: then print today's instructions instead.
  • In CI (CI set), don't edit rc files. If GITHUB_PATH is set, append the directory to it.
  • Say what was done: "Added ~/.local/bin to PATH in ~/.zshrc."

Fix the closing message order. When the current shell can't find squirrel yet (the directory was just added, or the user opted out), the epilogue says so first and shows commands that work right now:

Open a new terminal, or run:  source ~/.zshrc
Then:  squirrel audit https://your-site.com
(or right now:  ~/.local/bin/squirrel audit https://your-site.com)

When squirrel is already on PATH, the epilogue is unchanged.

Windows (install.ps1). When the bin directory isn't on the user PATH, add it to the User-scope Path ([Environment]::SetEnvironmentVariable(..., 'User'), never Machine), and to $env:Path for the current session. Same opt-out variable, same idempotence, and a message saying a new terminal picks it up.

Measure it. Pass the outcome to squirrel self install with the other install metadata, as path_setup: one of on_path (the chosen directory was already on PATH), added (rc or User Path written), opted_out, ci, failed. The CLI sends it with the install registration. The cloud side accepting the field is tracked internally.

Acceptance Criteria

  • Directory choice is unchanged: with /usr/local/bin (or ~/.local/bin) on PATH and writable, the binary goes there and no rc file is written; a writable non-standard $HOME/.mybin on PATH is not used.
  • With none of the four dirs on PATH and SHELL=/bin/zsh, the installer appends one marked export PATH line to ~/.zshrc (respecting ZDOTDIR), creating the file if needed, and prints which file it changed.
  • Running the installer twice leaves exactly one marked line. A file that already puts ~/.local/bin on PATH gets no line.
  • bash on macOS writes ~/.bash_profile, bash on Linux writes ~/.bashrc, fish writes ~/.config/fish/conf.d/squirrel.fish with fish_add_path, and an unknown shell writes ~/.profile.
  • SQUIRREL_NO_MODIFY_PATH=1 writes nothing and prints the manual instructions.
  • With CI=true, no rc file is written. With GITHUB_PATH set, the dir is appended to that file.
  • When squirrel isn't resolvable in the current shell, the epilogue's first lines are the reload hint and the full-path squirrel audit command. When it is resolvable, the epilogue is byte-identical to today's.
  • install.ps1 adds the dir to the User Path once (idempotent), updates $env:Path for the session, honours SQUIRREL_NO_MODIFY_PATH, and never touches Machine Path.
  • The install registration carries path_setup with one of the five values, from both installers.
  • The installer test suite covers each case above (shell tests against a temp HOME), and the existing installer tests pass.
  • docs/ install page documents the auto-add, the file each shell gets and the opt-out; make validate passes in docs/.

Skill: no change expected; the squirrelscan skill links to the install page.

Activity

  1. added
    enhancement
    size: M
    on Oct 27, 2026
  2. changed the title [-]Installers: add the bin directory to PATH automatically, prefer a directory already on PATH, and show a first command that works[/-] [+]Installers: add ~/.local/bin to PATH automatically and show a first command that works[/+] on Oct 27, 2026
  3. 6 remaining items

  4. added a commit that references this issue on Oct 28, 2026
    d245cee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementsize: M

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions