feat(install): add rootless Windows installer (PowerShell)#18
Conversation
Adds scripts/install.ps1 mirroring install.sh for Windows: installs to %LOCALAPPDATA%\Programs\solactl, verifies SHA256, and updates the user PATH via HKCU — no admin rights needed (winget-style). Documents both the irm|iex one-liner and the local-execution form with -Version / -InstallDir options in README. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a Windows installation script (install.ps1) and updates the README.md with comprehensive installation and upgrade instructions for Linux, macOS, and Windows. Feedback focuses on enhancing the PowerShell script's reliability, specifically by using throw instead of exit to avoid closing the user's terminal, improving architecture detection for 32-bit shells, handling potential file locks during the upgrade process, and ensuring clean PATH environment variable updates.
|
|
||
| function Die([string] $Message) { | ||
| Write-Host "ERROR: $Message" -ForegroundColor Red | ||
| exit 1 |
There was a problem hiding this comment.
Using exit 1 in a script intended to be run via iex (Invoke-Expression) will terminate the entire PowerShell session if an error occurs. This is a poor user experience for a one-liner installer. Consider using throw instead, which stops the script execution but keeps the terminal open.
throw $Message
| $arch = switch ($env:PROCESSOR_ARCHITECTURE) { | ||
| 'AMD64' { 'amd64' } | ||
| 'ARM64' { 'arm64' } | ||
| 'x86' { Die 'Unsupported architecture: x86 (32-bit). solactl ships amd64/arm64 only.' } | ||
| default { Die "Unsupported architecture: $env:PROCESSOR_ARCHITECTURE" } | ||
| } |
There was a problem hiding this comment.
The current architecture detection relies solely on $env:PROCESSOR_ARCHITECTURE, which may return x86 if the user is running a 32-bit PowerShell process on a 64-bit operating system. Checking $env:PROCESSOR_ARCHITEW6432 ensures the script correctly identifies the underlying OS architecture even when running in a 32-bit shell.
$arch = if ($env:PROCESSOR_ARCHITECTURE -eq 'AMD64' -or $env:PROCESSOR_ARCHITEW6432 -eq 'AMD64') { 'amd64' }
elseif ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64' -or $env:PROCESSOR_ARCHITEW6432 -eq 'ARM64') { 'arm64' }
else { Die "Unsupported architecture: $env:PROCESSOR_ARCHITECTURE" }
| # Existing binary is likely in use by a running process. | ||
| # Park the old one so the install still succeeds. | ||
| $stash = "$dest.old" | ||
| if (Test-Path -LiteralPath $stash) { Remove-Item -LiteralPath $stash -Force } |
There was a problem hiding this comment.
If the .old file is locked (e.g., by a previous failed installation where the process is still running), Remove-Item will throw an error and stop the script because $ErrorActionPreference is set to Stop. Adding -ErrorAction SilentlyContinue prevents a crash in this edge case.
if (Test-Path -LiteralPath $stash) { Remove-Item -LiteralPath $stash -Force -ErrorAction SilentlyContinue }
| } | ||
|
|
||
| if (-not $alreadyOnPath) { | ||
| $newPath = if ($userPath) { "$userPath;$InstallDir" } else { $InstallDir } |
There was a problem hiding this comment.
Summary
scripts/install.ps1— rootless, winget-style Windows installer (no admin required). Installs to%LOCALAPPDATA%\Programs\solactl, verifies SHA256 againstchecksums.txt, extracts the zip, and registers the directory on the userPATH(HKCU\Environment\Path).install.shbehavior: TLS 1.2 forced, redirect-bounded download, locked-binary fallback (solactl.exe.old), temp dir cleanup. Supports-Versionand-InstallDiroverrides.README.mdwith separate Linux/macOS and Windows install sections, anirm | iexone-liner, and the local-execution form for pinned versions / custom paths.Test plan
irm https://raw.githubusercontent.com/solapi/solactl/<branch>/scripts/install.ps1 | iexon Windows 11 (amd64) — verify install path, PATH entry, andsolactl --versionin a new shell.powershell -ExecutionPolicy Bypass -File install.ps1 -Version v0.1.6— verify pinned-version install succeeds.solactl.exeis in use — verify fallback tosolactl.exe.old.install.shon Linux/macOS still works unchanged (no diff to that file).🤖 Generated with Claude Code