Skip to content

Commit 00db2b6

Browse files
authored
feat(install): GitHub auth, Git Bash support, aligned Windows paths (#315)
* feat(install): support GitHub auth in install scripts Accept GITHUB_TOKEN/GH_TOKEN or --token/-Token for release API and asset downloads (rate limits and private releases). * feat(install): Git Bash support and align Windows install paths Allow install.sh on Git Bash/MSYS/Cygwin (zip + claurst.exe), use the same default dir and user PATH as install.ps1, and document GitHub token auth. * fix(install): remove claurst.exe.old after successful Windows upgrade
1 parent c0ea9ac commit 00db2b6

4 files changed

Lines changed: 303 additions & 38 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ curl -fsSL https://github.com/kuberwastaken/claurst/releases/latest/download/ins
5555
irm https://github.com/kuberwastaken/claurst/releases/latest/download/install.ps1 | iex
5656
```
5757

58-
This drops `claurst` into `~/.claurst/bin` (or `%USERPROFILE%\.claurst\bin` on Windows) and adds it to your `PATH` automatically. Open a new terminal and run `claurst`.
58+
This drops `claurst` into `~/.local/bin` (or `%LOCALAPPDATA%\Programs\claurst` on Windows; Git Bash uses the same Windows path) and adds it to your `PATH` automatically. Open a new terminal and run `claurst`.
5959

6060
## Via npm / bun
6161

docs/installation.md

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
Claurst is a Rust reimplementation of the Claude Code CLI. The fastest way
44
to install it is via the one-liner installers below. They drop the binary
5-
into `~/.claurst/bin` (or `%USERPROFILE%\.claurst\bin` on Windows) and add
6-
that directory to your `PATH` automatically.
5+
into `~/.local/bin` (or `%LOCALAPPDATA%\Programs\claurst` on Windows; Git Bash
6+
uses that same Windows default) and add that directory to your `PATH`
7+
automatically.
78

89
---
910

@@ -36,13 +37,26 @@ curl -fsSL https://github.com/Kuberwastaken/claurst/releases/latest/download/ins
3637
irm https://github.com/Kuberwastaken/claurst/releases/latest/download/install.ps1 | iex
3738
```
3839

40+
### Windows (Git Bash / MSYS / Cygwin)
41+
42+
`install.sh` also works under Git Bash. It downloads the Windows zip
43+
(`claurst-windows-x86_64.zip`), installs `claurst.exe` into the **same**
44+
default directory as `install.ps1` (`%LOCALAPPDATA%\Programs\claurst`), and
45+
updates the Windows user `PATH` (not only bashrc):
46+
47+
```bash
48+
curl -fsSL https://github.com/Kuberwastaken/claurst/releases/latest/download/install.sh | bash
49+
```
50+
3951
Both installers:
4052

4153
1. Detect your platform and architecture.
4254
2. Download the matching archive from the latest GitHub release.
43-
3. Extract `claurst` into `~/.claurst/bin/` (Windows: `%USERPROFILE%\.claurst\bin\`).
55+
3. Extract `claurst` into `~/.local/bin/` on Linux/macOS, or
56+
`%LOCALAPPDATA%\Programs\claurst` on Windows (`install.sh` under Git Bash
57+
uses this same Windows default).
4458
4. Append that directory to your shell config (`.bashrc`, `.zshrc`,
45-
`.config/fish/config.fish`) or to your Windows user `PATH`.
59+
`.config/fish/config.fish`) on Unix, or to your Windows user `PATH`.
4660
5. On macOS, strip the quarantine attribute so Gatekeeper does not block the
4761
unsigned binary.
4862

@@ -58,11 +72,41 @@ Both scripts accept the same flags:
5872
| `--version 0.1.0` | `-Version 0.1.0` | Install a specific version |
5973
| `--binary <path>` | `-Binary <path>` | Install from a local file (skip download) |
6074
| `--install-dir <path>` | `-InstallDir <path>` | Override the install directory |
75+
| `--token <token>` | `-Token <token>` | GitHub token for API/downloads |
6176
| `--no-modify-path` | `-NoModifyPath` | Don't touch shell config / user PATH |
6277
| `--help` | `-Help` | Show usage |
6378

6479
Example: `curl -fsSL https://.../install.sh | bash -s -- --version 0.1.0`
6580

81+
### GitHub authentication
82+
83+
If GitHub rate-limits unauthenticated requests, or you install from a private
84+
fork/release, set a token via env or flag. The installer also accepts
85+
`GH_TOKEN` (GitHub CLI convention):
86+
87+
```bash
88+
# Linux / macOS
89+
export GITHUB_TOKEN=ghp_... # or GH_TOKEN
90+
curl -fsSL https://github.com/Kuberwastaken/claurst/releases/latest/download/install.sh | bash
91+
92+
# Or pass the token as a flag when running the script locally:
93+
./install.sh --token ghp_...
94+
```
95+
96+
```powershell
97+
# Windows
98+
$env:GITHUB_TOKEN = 'ghp_...' # or $env:GH_TOKEN
99+
irm https://github.com/Kuberwastaken/claurst/releases/latest/download/install.ps1 | iex
100+
101+
# Or:
102+
.\install.ps1 -Token ghp_...
103+
```
104+
105+
The token is sent as `Authorization: Bearer …` on the GitHub API call that
106+
resolves the latest version and on asset/checksum downloads. A fine-grained
107+
or classic PAT with `contents: read` (public repos need no scopes beyond
108+
rate-limit relief) is enough.
109+
66110
---
67111

68112
## Via npm / bun
@@ -300,12 +344,14 @@ the [Upgrading](#upgrading) section above.
300344

301345
## Uninstalling
302346

303-
If you used the install script, remove the install directory:
347+
If you used the install script, remove the binary (or install directory):
304348

305349
```bash
306-
rm -rf ~/.claurst/bin # Linux / macOS
307-
# Windows (PowerShell):
308-
Remove-Item -Recurse -Force "$env:USERPROFILE\.claurst\bin"
350+
rm -f ~/.local/bin/claurst # Linux / macOS
351+
# Windows (PowerShell / default install.ps1 path):
352+
Remove-Item -Force "$env:LOCALAPPDATA\Programs\claurst\claurst.exe"
353+
# Optional: remove the empty install dir
354+
Remove-Item -Recurse -Force "$env:LOCALAPPDATA\Programs\claurst" -ErrorAction SilentlyContinue
309355
```
310356

311357
For manual installs:
@@ -322,4 +368,5 @@ rm -rf ~/.claurst
322368
```
323369

324370
You may also want to remove the `# claurst` PATH line that the installer
325-
appended to your shell config (`.bashrc`, `.zshrc`, etc.).
371+
appended to your shell config (`.bashrc`, `.zshrc`, etc.), or the Windows
372+
user PATH entry for `%LOCALAPPDATA%\Programs\claurst`.

install.ps1

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ param(
1212
[string]$Version = "",
1313
[string]$Binary = "",
1414
[string]$InstallDir = "",
15+
[string]$Token = "",
1516
[switch]$NoModifyPath,
1617
[switch]$Help
1718
)
@@ -38,17 +39,39 @@ Options:
3839
-Version <version> Install a specific version (e.g., 0.1.0)
3940
-Binary <path> Install from a local binary instead of downloading
4041
-InstallDir <path> Override install location (default: %LOCALAPPDATA%\Programs\claurst)
42+
-Token <token> GitHub token for API/downloads (or set GITHUB_TOKEN / GH_TOKEN)
4143
-NoModifyPath Don't add the install dir to user PATH
4244
4345
Examples:
4446
irm https://github.com/Kuberwastaken/claurst/releases/latest/download/install.ps1 | iex
4547
.\install.ps1 -Version 0.1.0
4648
.\install.ps1 -Binary C:\path\to\claurst.exe
49+
`$env:GITHUB_TOKEN = 'ghp_...'; .\install.ps1
4750
"@
4851
}
4952

5053
if ($Help) { Show-Usage; exit 0 }
5154

55+
# Prefer -Token; otherwise GITHUB_TOKEN, then GH_TOKEN (gh CLI convention).
56+
if ([string]::IsNullOrEmpty($Token)) {
57+
if (-not [string]::IsNullOrEmpty($env:GITHUB_TOKEN)) {
58+
$Token = $env:GITHUB_TOKEN
59+
} elseif (-not [string]::IsNullOrEmpty($env:GH_TOKEN)) {
60+
$Token = $env:GH_TOKEN
61+
}
62+
}
63+
64+
function Get-GitHubHeaders {
65+
$headers = @{
66+
'User-Agent' = 'claurst-installer'
67+
'Accept' = 'application/vnd.github+json'
68+
}
69+
if (-not [string]::IsNullOrEmpty($script:Token)) {
70+
$headers['Authorization'] = "Bearer $($script:Token)"
71+
}
72+
return $headers
73+
}
74+
5275
# ----- Detect architecture -----
5376
function Get-Arch {
5477
$procArch = $env:PROCESSOR_ARCHITECTURE
@@ -88,12 +111,17 @@ function Resolve-Version {
88111
return ($script:Version -replace '^v', '')
89112
}
90113
try {
91-
$resp = Invoke-RestMethod -UseBasicParsing -Uri "https://api.github.com/repos/$Repo/releases/latest" -Headers @{ 'User-Agent' = 'claurst-installer' }
114+
$resp = Invoke-RestMethod -UseBasicParsing `
115+
-Uri "https://api.github.com/repos/$Repo/releases/latest" `
116+
-Headers (Get-GitHubHeaders)
92117
$tag = $resp.tag_name
93118
if ([string]::IsNullOrEmpty($tag)) { throw "no tag_name in response" }
94119
return ($tag -replace '^v', '')
95120
} catch {
96121
Write-Err "Failed to fetch latest version from GitHub API: $_"
122+
if ([string]::IsNullOrEmpty($script:Token)) {
123+
Write-Info "If you hit rate limits or need a private release, set GITHUB_TOKEN or pass -Token."
124+
}
97125
exit 1
98126
}
99127
}
@@ -129,16 +157,23 @@ function Download-And-Install($desiredVersion, $arch) {
129157

130158
Write-Info "Installing claurst v$desiredVersion (windows-$arch)"
131159
Write-Muted "Downloading $url"
160+
if (-not [string]::IsNullOrEmpty($script:Token)) {
161+
Write-Muted "Using GitHub authentication."
162+
}
163+
$ghHeaders = Get-GitHubHeaders
132164
try {
133165
# Disable progress UI for a faster, less noisy download.
134166
$oldPref = $ProgressPreference
135167
$ProgressPreference = 'SilentlyContinue'
136-
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $zipPath
168+
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $zipPath -Headers $ghHeaders
137169
$ProgressPreference = $oldPref
138170
} catch {
139171
Write-Err "Download failed: $_"
140172
Write-Info ("Check that release v$desiredVersion exists for windows-" + $arch + ":")
141173
Write-Info " https://github.com/$Repo/releases/tag/v$desiredVersion"
174+
if ([string]::IsNullOrEmpty($script:Token)) {
175+
Write-Info "Private releases require GITHUB_TOKEN / GH_TOKEN or -Token."
176+
}
142177
Remove-Item -Recurse -Force $tmpRoot -ErrorAction SilentlyContinue
143178
exit 1
144179
}
@@ -154,7 +189,7 @@ function Download-And-Install($desiredVersion, $arch) {
154189
try {
155190
$oldPref2 = $ProgressPreference
156191
$ProgressPreference = 'SilentlyContinue'
157-
Invoke-WebRequest -UseBasicParsing -Uri $sumsUrl -OutFile $sumsPath
192+
Invoke-WebRequest -UseBasicParsing -Uri $sumsUrl -OutFile $sumsPath -Headers $ghHeaders
158193
$ProgressPreference = $oldPref2
159194
$haveSums = $true
160195
} catch {
@@ -223,16 +258,20 @@ function Install-FromBinary {
223258

224259
function Install-Binary($source) {
225260
$target = Join-Path $InstallDir 'claurst.exe'
261+
$stale = "$target.old"
226262

227263
# The currently running claurst.exe (if any) holds an exclusive file lock on
228-
# Windows. Try to swap by renaming the old one first.
264+
# Windows. Swap by renaming the old one aside, then remove it after the
265+
# new binary is in place (the lock is on the path that was open).
229266
if (Test-Path $target) {
230-
$stale = "$target.old"
231267
if (Test-Path $stale) { Remove-Item -Force $stale -ErrorAction SilentlyContinue }
232268
try { Move-Item -Force $target $stale } catch { }
233269
}
234270

235271
Copy-Item -Force $source $target
272+
if (Test-Path $stale) {
273+
Remove-Item -Force $stale -ErrorAction SilentlyContinue
274+
}
236275
Write-Success "Installed: $target"
237276
}
238277

0 commit comments

Comments
 (0)