Skip to content

feat(installer): add ~/.local/bin to PATH when the installer falls back to it, show a first command that works #1214 - #1215

Merged
nc9 merged 11 commits into
mainfrom
feat/installer-path-setup
Oct 28, 2026
Merged

nc9 merged 11 commits into
mainfrom
feat/installer-path-setup

Conversation

@nc9

@nc9 nc9 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1214

What

  • install.sh: directory choice is unchanged (SQUIRREL_BIN_DIR, the four common dirs when on PATH and writable, else ~/.local/bin). The ~/.local/bin fallback gets one marked, append-only, idempotent line in the shell's startup file (zsh honours ZDOTDIR; bash macOS ~/.bash_profile, Linux ~/.bashrc; fish conf.d/squirrel.fish; else ~/.profile).
  • SQUIRREL_NO_MODIFY_PATH opts out (manual instructions as before). CI never edits a profile and appends to GITHUB_PATH when set.
  • Closing message: when the current shell can't find squirrel, the reload hint and a full-path squirrel audit come first. When it can, the output is byte-identical to before (tested).
  • install.ps1: User-scope Path only (never Machine) plus $env:Path, once, same opt-out and CI behaviour.
  • Both installers stamp SQUIRREL_PATH_SETUP (on_path|added|opted_out|ci|failed) for squirrel self install; the CLI persists it and sends path_setup with the install registration (same shape as install_source).
  • The profile edit happens before the download so the outcome can ride on self install; a failed install leaves a harmless PATH line.
  • A custom SQUIRREL_BIN_DIR that is off PATH is not written to a profile (only ~/.local/bin is, spelled with $HOME); it gets the manual instructions and opted_out.

Verification

  • New scripts/install-path-setup.test.ts (temp HOME, ZDOTDIR, XDG_CONFIG_HOME, explicit PATH, uname shim) covers each acceptance box except PowerShell execution. New apps/cli/tests/self/path-setup.test.ts covers persistence and the registration body.
  • install-contract.test.ts, test-suites.ts --run rest (1877 pass), cli typecheck, lint, format:check, make validate all green; shellcheck install.sh adds no findings.
  • install.ps1 was NOT executed locally (no PowerShell here). It is parsed in CI by install-ps-contract.test.ps1, which gains checks for the pure helpers and the opt-out, CI and already-on-PATH branches (none writes the registry). The registry write itself is unexercised.

Notes

  • Docs: docs/quickstart.mdx (new "How the installer sets up your PATH") and docs/cli/self.mdx; CHANGELOG [Unreleased].
  • Skill: no change needed (it links to the install page).
  • The API accepting path_setup is tracked internally; an API that does not know the field ignores it.

@claude

claude Bot commented Oct 27, 2026

Copy link
Copy Markdown

Review of the installer PATH setup. I read the install.sh diff and skimmed the CLI changes. I did not run anything, and I did not read the PowerShell changes or the tests in detail.

  • (medium) install.sh setup_path: the "already configured" check treats any non-comment line containing .local/bin as proof the profile puts the directory on PATH, then reports added. A line like alias x=~/.local/bin/foo or a conditional PATH line that doesn't fire would make it skip the edit. The closing message then tells the user to source a file that still doesn't fix PATH. Match an export PATH=/PATH=/fish_add_path line that names the directory, or just rely on the # squirrel marker. Even if you keep the loose match, report it as something other than added.
  • (low) SQUIRREL_BIN_DIR set to a directory off PATH is stamped opted_out. The user never opted out, so the telemetry value is wrong. A separate value such as custom_dir would be more accurate.
  • (low) In CI with GITHUB_PATH set, a successful append still ends in print_path_instructions, because ci is in the manual-instructions case. That prints shell-profile advice in CI logs that doesn't apply. Skip the manual instructions when the GITHUB_PATH append succeeded.
  • (low) The profile edit now runs before the download, so a failed download or install leaves a PATH line pointing at a directory with no squirrel in it. The PR describes this as harmless, so I agree it is acceptable. The SQUIRREL_PATH_SETUP outcome is still recorded for a failed install, which is fine.
  • (nit) usable_home_path_dir hardcodes manager directory names. A comment pointing at where to extend the list would help.
  • (nit) install.ps1 was not executed locally, as the PR says. Please make sure the CI PowerShell contract job actually passed before merging.

No critical or high issues found. The append-only, idempotent profile write and the test coverage look solid.

@nc9

nc9 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Triage of the review:

  • medium (loose .local/bin match): fixed. A non-comment line must mention PATH or fish_add_path and .local/bin, or carry the # squirrel marker. An alias or function that only names the directory no longer counts (tests added for both).
  • low (SQUIRREL_BIN_DIR off PATH stamped opted_out): rebutted. The issue fixes the value set at five, and a custom dir that is not on PATH gets the manual instructions, the same as an opt-out: no profile edit happens. A sixth value would need an API change; easy to add later if the funnel needs it.
  • low (profile advice after a GITHUB_PATH append): fixed, suppressed when the append succeeded.
  • nit (manager list): comment added at usable_home_path_dir.
  • nit (ps1): the CI PowerShell contract job has to be green before merge; flagged to the lead.

@claude

claude Bot commented Oct 27, 2026

Copy link
Copy Markdown

Reviewed install.sh in depth. I only skimmed the CLI, install.ps1 and test changes, and I did not run anything. The design is sound: the profile edit is append-only, idempotent and marked, opt-outs are honoured, and CI never touches a profile.

  • (medium) install.sh detect_shell_config: on Linux, bash gets ~/.bashrc. Login shells such as SSH sessions and some terminals read ~/.bash_profile or ~/.profile first. Many distro .bashrc files return early for non-interactive shells. In those setups the line may not take effect even though the installer reports added. Consider also checking whether ~/.bash_profile exists and sources .bashrc, or falling back to ~/.profile when it does not.
  • (medium) install.sh usable_home_path_dir: the denylist is open-ended. Any writable $HOME directory on PATH is now a target, for example ~/.npm-global/bin, ~/.local/share/pnpm, ~/Library/Python/*/bin, ~/.rustup or a Homebrew-in-home prefix. Several of these are owned by a package manager that can wipe the directory. Consider an allowlist (~/bin, ~/.local/bin) or a longer denylist, plus a test for each addition.
  • (low) setup_path already-on-PATH check: the grep matches any non-comment line that mentions both PATH and .local/bin. That includes lines inside conditionals or unset/echo lines. It then sets PATH_SETUP=added although nothing was added, so the telemetry value is slightly misleading.
  • (low) dir_in_path: it does an exact string compare. A PATH entry with a trailing slash, such as $HOME/.local/bin/, is not recognised. The result is a redundant profile line and a wrong "not on PATH" epilogue. Normalise trailing slashes first.
  • (nit) install.sh: the profile edit happens before the download, so a failed install leaves a PATH line behind. The PR notes this and it is harmless. The first-run messaging could still mention it.
  • (nit) install.ps1 was not executed by the author. Please get a maintainer to smoke-test it on Windows PowerShell 5.1 and PowerShell 7, specifically that the User-scope Path write does not expand or truncate an existing REG_EXPAND_SZ value.

@nc9

nc9 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Round 2 triage:

  • medium (Linux bash reads .bashrc): rebutted. Acceptance criteria fix the table (bash Linux writes ~/.bashrc), which is what an interactive shell and most terminals read; an SSH login shell that skips it is the distro's .bash_profile convention. Unknown shells and sh get ~/.profile.
  • medium (open-ended denylist): fixed. Added npm, pnpm, yarn, .npm-global, Library/Python, .rustup, .nix-profile, .linuxbrew, conda, .rye, .poetry, .gem; the test exercises each family. ~/bin and ~/.local/bin stay first in the order, so the common case is unchanged.
  • low (loose already-configured match): fixed in part. The outcome is now on_path (nothing was written), not added. The match stays a non-comment PATH/fish_add_path line naming .local/bin; a conditional that doesn't fire is the accepted miss, as the issue asks for "a file that already puts ~/.local/bin on PATH gets no line".
  • low (trailing slash): fixed in dir_in_path, with a test.
  • nit (profile edit before the download): known and documented in the PR body.

@claude

claude Bot commented Oct 27, 2026

Copy link
Copy Markdown

Reviewed the diff (install.sh, install.ps1, CLI persistence, docs, tests). I did not run the code. The shell logic reads sound, and the opt-out, CI and idempotency handling look careful.

  • (medium) install.ps1 Set-UserPath: [Environment]::SetEnvironmentVariable("Path", ..., "User") rewrites the value as REG_SZ. If the user's Path was REG_EXPAND_SZ with entries like %USERPROFILE%\bin, those entries stop expanding. This is a well-known PowerShell pitfall. Consider writing through the registry (HKCU:\Environment, REG_EXPAND_SZ) and reading with DoNotExpandEnvironmentNames. The PR says the registry write is never executed in CI, so nothing covers this.
  • (medium) install.ps1 Test-PathHasDir: it compares raw entries with $BinDir, so an unexpanded %LOCALAPPDATA%\... entry in the User Path is not recognised. The installer would append a duplicate and report added. Expand each entry with [Environment]::ExpandEnvironmentVariables before comparing.
  • (low) install.sh usable_home_path_dir: this is a denylist of manager directories, so any other writable $HOME PATH entry is accepted (for example ~/.local/share/JetBrains/Toolbox/scripts, or other tool-owned dirs). Writing the binary there is harder to predict than falling back to ~/.local/bin. Consider an allowlist (~/bin, ~/.local/bin) or a more conservative default.
  • (low) install.ps1 Show-Epilogue: & '$BinDir\squirrel.exe' is printed inside single quotes. A path containing ' (e.g. C:\Users\O'Brien) produces a command that doesn't parse. Double the single quotes in the printed path.
  • (low) install.sh setup_path: a custom SQUIRREL_BIN_DIR that is off PATH is stamped opted_out, though the user never opted out. This skews the path_setup telemetry. A distinct value such as custom_dir would be more honest, if you can change the API enum.
  • (low) install.sh detect_shell_config: on Linux, a bash login shell (ssh, some terminals) reads ~/.bash_profile or ~/.profile first, and ~/.bashrc only if those source it. The PR notes the macOS case but not this one. Consider a docs note, or writing ~/.bash_profile when it exists and doesn't source .bashrc.
  • (nit) install.sh: setup_path runs before the download, so a failed download leaves a PATH line behind. This is documented in the PR and harmless, but a one-line comment in code would help the next reader.
  • (nit) The on_path grep heuristic (PATH|fish_add_path plus .local/bin on one line) can be fooled by lines like an unset PATH... line. This is acceptable given that it only skips an append.

Tests: the shell side is well covered (temp HOME, ZDOTDIR, XDG_CONFIG_HOME, byte-identical output when already on PATH). The PowerShell registry write is the untested part, and it carries the first two findings above.

@nc9

nc9 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Round 3 triage (none of the ps1 changes were executed locally; the CI contract job parses and runs the pure helpers):

  • medium (REG_SZ flattening): fixed. The User Path is read raw from HKCU:\Environment (unexpanded, falling back to the expanded value where there is no registry). When the new value holds %VARS% it is written as REG_EXPAND_SZ, then a throwaway variable is set and cleared so Windows still broadcasts the change. Otherwise SetEnvironmentVariable as before.
  • medium (%LOCALAPPDATA% entry not recognised): fixed. Test-PathHasDir expands each entry first; contract check added.
  • low (single quote in the printed path): fixed, quotes doubled.
  • low (open denylist): kept. The issue asks for "any other existing, user-writable directory on PATH under $HOME" minus manager dirs; round 2 widened the denylist. An allowlist would drop that behaviour.
  • low (SQUIRREL_BIN_DIR stamped opted_out): rebutted in round 1. The issue fixes five values.
  • low (Linux login shells): documented in the quickstart; the table stays as the acceptance criteria say.

@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Reviewed the diff for install.sh, install.ps1 and the CLI persistence. I read it only and ran nothing. The design is sound: the profile edit is append-only, marked and idempotent, CI and opt-out are respected, and the PowerShell side preserves %VARS% in the User Path.

  • (medium) install.sh setup_path: the PATH edit runs before the download, so a failed download leaves a profile line for a binary that was never installed. The PR description calls this harmless. It is mildly surprising for users who hit a network failure and retry later. Consider moving the edit after a successful download and passing SQUIRREL_PATH_SETUP via the self install env only. Doing so costs nothing, because the stamp is read from the env at self install time.
  • (low) install.sh setup_path: the "already on PATH in rc" check is a heuristic. It greps non-comment lines containing PATH or fish_add_path and .local/bin. A line like export PATH=$PATH:/x # .local/bin or a line in a conditional branch would count as present. In that case it reports on_path without writing anything. The failure mode is only that the user has to add the line manually.
  • (low) install.sh: if SHELL is bash on Linux and the user only has ~/.bash_profile or ~/.profile, ~/.bashrc is created fresh. Login shells such as SSH sessions often don't read .bashrc unless .profile sources it. The result is added while a new login shell still lacks the PATH. Consider appending to .bash_profile when it exists and .bashrc does not.
  • (low) install.ps1: Test-PathHasDir $env:Path returning on_path when the directory is only in the session PATH, with nothing persisted, is fine. It does mean the User Path is never updated in that case. This is probably intended; a short comment would help.
  • (nit) install.ps1: the throwaway SQUIRREL_PATH_NOTIFY set and clear trick works. A short note that it forces the WM_SETTINGCHANGE broadcast would help future readers.
  • (nit) apps/cli readPathSetupEnv duplicates the shape of readInstallSourceEnv. That is fine as is.

Tests look thorough: the byte-identical output when already on PATH is covered, and the CLI persistence is covered. The PowerShell path is untested locally, as the PR says, so a reviewer on Windows should smoke-test it. This includes the REG_EXPAND_SZ branch.

@nc9

nc9 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Round 4 triage:

  • medium (move the edit after the download): rebutted. self install runs inside download_and_install, after the download and before it returns, so the stamp has to be decided before that function runs; moving the edit into it would also make every direct test call of download_and_install write a profile. The edit is idempotent and points at a directory the installer just created, so a retry after a failed download adds nothing.
  • low (heuristic match): accepted, as in round 3; the failure mode is a manual line.
  • low (bash on Linux with only .bash_profile): kept per the acceptance table; documented in the quickstart.
  • nits (ps1 comments): added in the latest commit.

@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Reviewed the diff for install.sh, with a lighter pass over the CLI and docs changes. I found no blocking problems. The profile edit is append-only, marked, idempotent and guarded by an opt-out, and the tests isolate HOME, ZDOTDIR and XDG_CONFIG_HOME. I did not run the suite or execute install.ps1, which the PR also says it did not run locally.

  • (medium) install.sh detect_shell_config: on Linux bash this writes only ~/.bashrc. SSH and other login shells read ~/.bash_profile or ~/.profile first. If one of those exists and does not source ~/.bashrc (the Debian and Ubuntu default ~/.profile does), squirrel is still missing in login sessions. The epilogue then says "Open a new terminal, or run: source ~/.bashrc", which does not help there. Consider also checking for .bash_profile, or documenting the limitation.
  • (low) install.sh setup_path already-configured check: grep -E 'PATH|fish_add_path' | grep -qF '.local/bin' can match unrelated lines. Examples are PATH=$PATH:~/.local/bin/foo, or a .local/bin line that sits inside an if block that never runs. A false match gives on_path and writes nothing, so squirrel stays off PATH. The case is rare, but a stricter match would be safer.
  • (low) install.sh usable_home_path_dir: the deny-list is hand-maintained and will drift. A writable $HOME PATH directory that is not on the list, such as a ~/Library/... or tool-specific directory, will now receive the binary. Previously only the common directories qualified. The comment explains how to extend the list, which helps. A test that pins the list's behaviour on a couple of unusual directories would help too.
  • (low) install.sh main: the profile is edited before the download. The PR already notes that a failed install leaves a harmless PATH line. Because it persists after failures, make sure the uninstall docs mention removing the # squirrel marker block.
  • (nit) install.sh find_bin_dir: local path_dir is declared after the first loop that already uses it. This works in bash, but declaring it next to path_dirs would read better.
  • (nit) install.sh print_epilogue: the "(or right now: ...)" line is shown even when PATH_SETUP is on_path, meaning the profile already had the entry. Fine as is, but the wording could differ.

Docs and CHANGELOG: I did not check the CHANGELOG bullet or docs:check output. Please confirm both before merge.

@nc9

nc9 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Scope change per the updated #1214: removed the PATH scan and manager-dir denylist. Directory choice is back to SQUIRREL_BIN_DIR, the four common dirs, else ~/.local/bin (now added to PATH). Tests, docs and CHANGELOG updated.

@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Review of the PATH setup change for install.sh, install.ps1 and the path_setup plumbing. The CLI side (PATH_SETUP_VALUES, the env reader, the .catch(null) tolerance) looks clean and matches install_source. I read the diff only and ran nothing.

  • (medium) install.sh setup_path: the idempotency check grep -qF "# squirrel" is a substring match on a very generic marker. Any rc file with a comment such as # squirrelscan notes, or an inlined # squirrel bash completion block (the header squirrel self completion emits in apps/cli/src/self/completion.ts), counts as already set up. The installer then reports on_path and writes nothing, and the user is left without PATH. Use a more specific marker (for example # added by squirrel installer) and match it as a whole line with grep -qxF.
  • (low) install.sh setup_path: the second heuristic (a non-comment line containing PATH or fish_add_path and .local/bin) also matches things like export PATH=$PATH:~/.local/bin/foo or PATH=/x/.local/bin-old. It also matches a line that removes the directory from PATH. The failure mode is the same as above (nothing written, on_path reported). Consider tightening it, or accept the false negatives and mention them in a comment.
  • (low) install.sh detect_shell_config: bash on Linux now always targets ~/.bashrc. The old code fell back to .bash_profile when .bashrc was missing. Login-only shells (SSH, or a .bash_profile that doesn't source .bashrc) won't read the new line. Consider also checking for an existing ~/.bash_profile or ~/.profile that sources .bashrc, or writing to the file that exists.
  • (low) install.sh: the fish line fish_add_path $HOME/.local/bin runs on every start. Without -g it writes a universal variable, which survives after the conf.d file is removed. Consider fish_add_path -g (or -gP) so removing the file undoes the change cleanly.
  • (low) Both installers edit PATH before the download, so a failed install leaves a PATH entry for a binary that isn't there. The PR body acknowledges this. It is harmless but worth noting in the uninstall docs.
  • (low) install.ps1 Set-UserPath: the SQUIRREL_PATH_NOTIFY set-then-clear trick to broadcast WM_SETTINGCHANGE writes to the registry twice. The PR says install.ps1 was not executed locally, and this registry branch (REG_EXPAND_SZ) isn't covered by the CI parse test. Please run it once on a real Windows box, with and without a %VAR% entry in the user Path, before merging.
  • (nit) install.sh: ci_enabled only treats "", false and 0 as off and is case-sensitive, while no_modify_path_enabled lowercases its input. CI=FALSE therefore counts as CI. Lowercase it for consistency.

Test coverage is good: the shell installer is tested with a temp HOME and PATH, and there is a persistence test on the CLI side. I'd add cases for the false-positive marker and heuristic above.

@nc9 nc9 changed the title feat(installer): add the bin dir to PATH, prefer a writable PATH dir, first command that works #1214 feat(installer): add ~/.local/bin to PATH when the installer falls back to it, show a first command that works #1214 Oct 28, 2026
@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Reviewed the diff for install.sh, install.ps1 and the CLI path_setup plumbing. I found nothing that should block the merge. I did not run any of it, and install.ps1 is untested outside the CI parse check, as the PR says.

  • (low) install.sh setup_path: the "already on PATH" check only reads the one rc file picked for the shell. On Linux, for bash, a user whose ~/.profile or ~/.bash_profile already adds ~/.local/bin but who has no match in ~/.bashrc gets a second line appended. This is harmless and idempotent, and the docs already mention the login-shell caveat. A one-line note in the code would be enough.
  • (low) The ~/.local/bin check greps for the substring .local/bin on any PATH= line. A line such as PATH=$PATH:~/.local/bin/other counts as a match, so the installer skips the append and reports on_path. This is rare, but the stamped on_path would then be wrong.
  • (low) install.ps1 Set-UserPath: the REG_EXPAND_SZ branch writes to the registry through $key.SetValue, and $key can be null if OpenSubKey fails. The surrounding try/catch returns failed, so this is safe. Calling that out in a comment would help the next reader.
  • (nit) The behaviour change for bash on Linux, where ~/.bash_profile is no longer used when it exists and ~/.bashrc does not, is correct for most users. It is worth a CHANGELOG mention under Changed.
  • (nit) I could not check that the API accepts the new path_setup field in the install registration body. Please confirm the server side ships first or tolerates unknown fields.

Tests cover the env parsing, persistence and registration body, and the shell behaviour is covered by install-path-setup.test.ts.

@nc9
nc9 force-pushed the feat/installer-path-setup branch from 5a0f311 to e9044b2 Compare October 28, 2026 00:19
@nc9

nc9 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Round 5: fixed the .local/bin/other false match (the token must end the path) and added the single-profile and null-key comments. Rebutted/skipped: CHANGELOG Changed note (the installer never wrote profiles before, so there is no prior behaviour to change). The API tolerates unknown fields (zod strips them), so order does not matter.

@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Reviewed the diff (installers, CLI persistence, docs). I did not run anything, and I did not read the test files in depth. I found no blocking issues. The append-only, marked, idempotent profile edit and the opt-outs (SQUIRREL_NO_MODIFY_PATH, CI) look sound, and path_setup is validated at both the env reader and the zod schema.

  • (low) install.sh detect_shell_config: on Linux, bash gets ~/.bashrc unconditionally. Login-only shells (for example SSH sessions where ~/.bash_profile exists and doesn't source ~/.bashrc) won't see the PATH line. The old code at least preferred an existing file. Consider writing to ~/.bash_profile when it exists and ~/.bashrc doesn't, or noting the limitation.
  • (low) install.sh setup_path: the "already on PATH" grep matches any PATH= line containing .local/bin followed by a non-path character. A line such as PATH=/other/.local/bin:$PATH would count as satisfied. This is an unlikely false positive and it fails safe (no edit), but the comment could say so.
  • (low) install.ps1 Set-UserPath: when the directory is only on the session $env:Path and not the persisted User Path, the function returns on_path and persists nothing. The comment explains why, but the telemetry value on_path then blends "persisted" with "session only".
  • (nit) install.ps1 Set-UserPath: the SQUIRREL_PATH_NOTIFY set-and-clear trick works, but a short note on why it is needed beyond the existing comment (for example that WM_SETTINGCHANGE isn't sent by a raw registry write) would help future readers.
  • (nit) The PR says install.ps1 wasn't executed locally. The new PowerShell code, especially the REG_EXPAND_SZ branch, depends on the CI contract test. A maintainer smoke test on Windows before release would be worthwhile.

Docs and CHANGELOG are updated. The PR description doesn't include the closing "Docs: ... Skill: ..." line that AGENTS.md asks for.

@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Reviewed the installer and CLI changes. The design is sound: append-only, idempotent, opt-out, CI-aware, and the profile edit is limited to the ~/.local/bin fallback. I did not run any of it, and I didn't read the new tests (scripts/install-path-setup.test.ts, apps/cli/tests/self/path-setup.test.ts). I found nothing that should block the merge.

  • (low) install.ps1 Main: in CI with GITHUB_PATH set, the append succeeds and Set-UserPath returns ci. The not in your PATH warning and manual instructions still print. install.sh suppresses these through PATH_SETUP_GITHUB. Consider the same suppression for parity. Alternatively, return a distinct state or flag for a successful GITHUB_PATH append.
  • (low) install.sh setup_path: the on_path stamp covers two different cases, the directory being on this shell's PATH and the profile already containing it. The second case is worth a separate value or a comment if the path_setup telemetry will be used to measure how often a profile is actually edited.
  • (low) install.sh: the profile is edited before the download, and a failed install leaves the PATH line behind. The PR description already acknowledges this. It is harmless, but it is a behavior change for failed installs, so it may be worth a line in the docs.
  • (nit) install.sh: on Linux, bash login shells such as SSH read ~/.bash_profile or ~/.profile rather than ~/.bashrc. That works on stock Debian/Ubuntu because their profile sources .bashrc, but not on every distro. This is a known limitation and not worth fixing here.
  • (nit) install.ps1: the SetEnvironmentVariable set-and-clear of SQUIRREL_PATH_NOTIFY is a clever way to broadcast the change. A comment is already there, which is good. Since PowerShell was not run locally, it is worth watching the Windows CI job.

@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Review of the installer PATH setup. I read the full diff and did not run anything, including install.ps1. I'm relying on the PR's CI for that.

Findings:

  • (medium) install.sh setup_path: the "already configured" check uses grep -qF "# squirrel". That matches any line containing # squirrel, such as a user's # squirrelscan notes comment or a pasted completion header (# squirrel zsh completion). The installer then reports on_path and writes nothing, even though no PATH line exists. The user ends up with squirrel not found and no instructions printed. Use a more specific marker, for example # squirrel: add to PATH, and match it as a whole line (grep -qxF).
  • (low) install.sh setup_path: the profile line is written before the download, so a failed install leaves a PATH line pointing at an empty directory. The PR description calls this harmless, and I agree it is. A one-line note in the docs would help anyone who hits it.
  • (low) install.sh setup_path: the "already on PATH in the profile" regex needs \.local/bin in a PATH= or fish_add_path line. A profile that sets PATH through a helper or a sourced file is not detected, so it gets a second line. That is harmless and the comment already says so.
  • (low) install.ps1 Set-UserPath: when $userPath is empty and $BinDir contains no %, SetEnvironmentVariable is used. That is correct. The % branch writes REG_EXPAND_SZ and then toggles a throwaway variable to force the WM_SETTINGCHANGE broadcast. This is a good approach, but it depends on a side effect. A short comment pointing at the CI test that covers it would help future readers.
  • (nit) detect_shell_config no longer falls back to ~/.bash_profile when ~/.bashrc is missing on Linux. This is a deliberate behaviour change and it is documented. The docs already warn about login shells.
  • (nit) Tests: the scripts/install-path-setup.test.ts and path-setup.test.ts coverage is thorough (temp HOME, opt-out, CI, idempotence). Nothing is missing except PowerShell execution, which the new Windows workflow job covers.

Security: SQUIRREL_PATH_SETUP is validated against an enum on the CLI side, so an arbitrary value cannot reach the registration body. The profile edit is append-only and uses $HOME, not an absolute path. I have no concerns there.

I found nothing at (high) or (critical).

@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Review of #1215 (installers put squirrel on PATH). I read the full diff. I did not run anything, and install.ps1 was not executed by the author either, so its behaviour rests on the new Windows CI job.

No blocking problems found. The profile edit is append-only and idempotent, it respects ZDOTDIR and XDG_CONFIG_HOME, it has an opt-out, and CI never edits a profile. Tests use a temp HOME throughout.

  • (medium) install.sh setup_path: a custom SQUIRREL_BIN_DIR that is off PATH is stamped opted_out even though the user never set SQUIRREL_NO_MODIFY_PATH. That value flows into path_setup telemetry, so the data can't tell a real opt-out from "we chose not to touch a custom dir". Consider a separate value (e.g. custom_dir) in PATH_SETUP_VALUES, or at least document the overload.
  • (low) install.ps1 Main: in CI with GITHUB_PATH set, the outcome is ci and the trailing "not in your PATH" warning still prints. install.sh suppresses it via PATH_SETUP_GITHUB. The two installers should behave the same.
  • (low) install.sh detect_shell_config: bash on Linux now always targets ~/.bashrc. The old code fell back to ~/.bash_profile when only that file existed. A login shell (e.g. ssh) on a box whose .bash_profile doesn't source .bashrc won't see the line, and the reload hint points at the wrong file.
  • (low) The profile is edited before the download, so a failed or aborted install leaves a PATH line pointing at a missing directory. The PR calls this out and it is harmless, but the failure message could mention it.
  • (low) The already-on-PATH grep in setup_path only matches PATH= or fish_add_path lines naming .local/bin. It misses forms like path+=(~/.local/bin) in zsh. The worst case is a duplicate line, so this is acceptable; a code comment saying so would help.
  • (nit) PowerShell is covered only by the CI job, so please watch that job's first run before merging.

Docs and CHANGELOG are updated, and the PR body has the Docs/Skill line.

@nc9
nc9 force-pushed the feat/installer-path-setup branch from b068a68 to 65ebbf7 Compare October 28, 2026 08:45
@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Reviewed install.sh and install.ps1. I read the code only and ran no tests. The change is well scoped: the profile edit is append-only and idempotent, and the opt-out and CI handling are sensible. I found nothing that should block the merge.

  • (low) install.sh setup_path: the idempotency marker is grep -qF "# squirrel". That also matches any unrelated comment that begins with "# squirrel", such as "# squirrelscan notes". The installer would then wrongly skip the edit and report on_path. Matching the whole marker line (grep -qxF) would avoid this.
  • (low) install.ps1 Main: in CI with GITHUB_PATH set, Set-UserPath appends to it and returns ci. Main then still prints the "not in your PATH" warning and manual instructions. install.sh suppresses those via PATH_SETUP_GITHUB. Consider the same behaviour here for parity.
  • (low) install.ps1: if the registry write succeeds but the later SetEnvironmentVariable broadcast trick throws, the function returns failed even though the Path was persisted. The user then gets the manual instructions for a Path that was already written. Splitting the broadcast into its own try/catch would avoid that.
  • (nit) install.sh: when $SHELL is unset and no zsh or bash startup file exists, the installer falls back to ~/.profile. Some fresh Linux setups never source that file for non-login shells. This is acceptable, since the closing message says to source the file.
  • (nit) install.ps1 was not executed locally, as the PR says. Please make sure the Windows CI contract test actually runs Set-UserPath paths on a runner before merge. Only the pure helpers are covered.

@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Reviewed the diff for install.sh, install.ps1, the CLI path_setup plumbing, the CHANGELOG and the new tests. I did not run the workflow or the tests.

  • (medium) CHANGELOG.md: the same "The installers put squirrel on your PATH" bullet appears three times, once under ### Fixed and twice under ### Docs. Two of them also differ in wording. Keep one bullet in the right block (### Changed or ### Fixed) and drop the duplicates. A rebase conflict resolution probably left them behind.
  • (medium) install.sh (setup_path, called from main): the profile is edited and SQUIRREL_PATH_SETUP=added is decided before the download and self install succeed. If the download fails, the user is left with a PATH line for a binary that does not exist. Consider deferring the write until after a successful install, or say so in the docs.
  • (low) install.sh (setup_path): a bin dir other than $HOME/.local/bin, for example /usr/local/bin or a custom SQUIRREL_BIN_DIR that is off PATH, is recorded as opted_out. The user never opted out, so the path_setup telemetry will mix the two cases. A distinct value such as skipped would keep the data honest. It needs adding to PATH_SETUP_VALUES and the zod enum.
  • (low) install.sh: the "already on PATH" detection greps only the one profile for this shell. For fish, only conf.d/squirrel.fish is checked, so a fish_add_path in the user's config.fish is missed. This is harmless, since it just adds a duplicate PATH entry, but the comment should say so.
  • (low) install.ps1 (Set-UserPath): the -like "*%*" guard returns failed only for a symbolic BinDir. That path is fine. However, SetEnvironmentVariable followed by an $env:Path append happens before the binary is installed, with the same failure-ordering issue as in install.sh.
  • (nit) install.ps1: the CI branch uses Add-Content to GITHUB_PATH. Windows PowerShell 5.1 defaults to ANSI encoding there, so non-ASCII profile paths could be mangled. Pass -Encoding utf8 explicitly.
  • (nit) Tests: the new unit tests (apps/cli/tests/self/path-setup.test.ts) cover the CLI side well. Confirm each new test file is wired into a suite with bun run scripts/test-suites.ts --check, especially scripts/install-path-setup.test.ts.

@nc9

nc9 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Reviewed head: 6d37486

Delta review since e9044b2 (5a5991d, 65ebbf7, 6d37486; the rest is the rebase onto main). Clean, good to merge.

  • self install PATH block (shouldPrintPathInstructions): correct. Every outcome the installers stamp is already covered by their own output:

    • added and on_path: the installer prints the reload hint or nothing is needed.
    • opted_out, ci and failed: both installers print the manual instructions themselves (install.sh epilogue case "$PATH_SETUP", and install.ps1 line ~693), except after a successful GITHUB_PATH append, where none are needed.

    So suppressing the CLI's own block only removes the contradicting duplicate. A manual squirrel self install (no stamp) and older installer scripts behave exactly as before. The unit test covers all five values plus the no-stamp case.

  • .github/workflows/test-installer-path.yml (hold-list check):

    • It triggers on pull_request (not pull_request_target) with a paths filter, plus workflow_dispatch, so fork PRs get a read-only token and no secrets.
    • Top-level permissions: contents: read, and no secrets.* anywhere.
    • actions/checkout is SHA-pinned to the same commit ci.yml uses.
    • The Unix job runs install.sh under env -i with a throwaway HOME. The Windows job seeds the User Path and restores it afterwards, in a child pwsh with CI/GITHUB_PATH removed and a throwaway LOCALAPPDATA.
    • cancel-in-progress is fine for a side-effect-free test job.
  • Nits, not blocking:

    • The installer under test downloads the latest released binary, so this job exercises the scripts and the released self install, not this branch's self.ts change. The unit test covers that.
    • apt-get install zsh without apt-get update can occasionally miss on a stale runner image.

nc9 added 6 commits October 29, 2026 00:40
… first command that works; report path_setup #1214

Signed-off-by: Nik Cubrilovic <[email protected]>
…dvice after a GITHUB_PATH append #1214

Signed-off-by: Nik Cubrilovic <[email protected]>
… already-configured is on_path #1214

Signed-off-by: Nik Cubrilovic <[email protected]>
…PATH entries expanded, quote the full-path command #1214

Signed-off-by: Nik Cubrilovic <[email protected]>
… existing directory choice #1214

Signed-off-by: Nik Cubrilovic <[email protected]>
nc9 added 5 commits October 29, 2026 00:40
…y a PATH= line counts as configured #1214

Signed-off-by: Nik Cubrilovic <[email protected]>
…hell profile and the Windows User Path

Signed-off-by: Nik Cubrilovic <[email protected]>
…dled PATH; installer CI: login shell for bash on macOS

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the feat/installer-path-setup branch from 6d37486 to dc25b88 Compare October 28, 2026 13:40
@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Reviewed install.sh, install.ps1 and the CLI changes (self.ts, install-meta.ts, types.ts, register-install.ts). I did not read the new workflow file or the test files in depth, and I did not run anything. The design is sound: the edit is append-only, marked and idempotent, the opt-out and CI handling are clear, and PATH_SETUP is validated against an allowlist on the CLI side. Findings:

  • (medium) install.sh setup_path / bash on Linux: the line is written to ~/.bashrc only. Bash login shells (SSH sessions, some terminals) read ~/.bash_profile or ~/.profile first. Debian-style defaults source ~/.bashrc from those, but not every distro does. In that case squirrel is still not found, yet the installer reports added. Consider a note in the docs, or also checking whether ~/.bash_profile exists and lacks a .bashrc source.
  • (low) install.sh main: the profile edit now happens before the download and version check. A failed install (network, checksum) leaves a PATH line for a directory that may not exist. The PR description says this is harmless and I agree. Say so in the docs so users are not surprised.
  • (low) install.sh idempotency check: the grep -E ... PATH= / \.local/bin heuristic misses forms such as path+=(~/.local/bin) (zsh) and PATH=$(...). The result is a duplicate line at worst, which is harmless. A short comment listing the accepted forms would help.
  • (low) install.sh setup_path: printf >> "$rc_file" follows symlinks. That is fine for stow-managed dotfiles, but it means the installer can modify a tracked file. Consider mentioning this in the docs.
  • (low) install.ps1 Set-UserPath: the REG_EXPAND_SZ branch uses a throwaway SQUIRREL_PATH_NOTIFY User variable to force a WM_SETTINGCHANGE broadcast. This is a clever workaround, but if the process is killed between the set and the clear, a stray user variable remains. It is also the least-tested branch, since PowerShell was not run locally. Please confirm the CI install-ps-contract job covers it, or run it once manually on Windows.
  • (low) self.ts: shouldPrintPathInstructions suppresses the CLI's own PATH block whenever SQUIRREL_PATH_SETUP is set to a valid value. If someone exports SQUIRREL_PATH_SETUP in their shell and then runs squirrel self install by hand, the hint is silently lost. This is an edge case, so no change is needed. It is only worth a comment.
  • (nit) ci_enabled / Test-CiEnvironment treat only "", false and 0 as off, as the comment says. The shell version is case-sensitive about False while the PowerShell version lowercases the value. Consider aligning them.
  • (nit) The PATH_SETUP_VALUES comment in types.ts could point at the installers, so that adding a value stays in sync across install.sh, install.ps1 and the CLI.

@nc9
nc9 merged commit d245cee into main Oct 28, 2026
20 checks passed
@nc9
nc9 deleted the feat/installer-path-setup branch October 28, 2026 13:57
nc9 added a commit that referenced this pull request Oct 29, 2026
…er the tags (#1248)

Restores the released v0.0.139 and v0.0.138 CHANGELOG sections byte-for-byte from their tags and puts the bullets of #1215, #1222, #1223 and #1190, deduplicated, under Unreleased. The guard against this is tracked in #1234. Docs: CHANGELOG only. Skill: no change.
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.

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

1 participant