@@ -153,6 +153,41 @@ function Require-Git {
153153 exit 1
154154}
155155
156+ function Ensure-ClawdbotOnPath {
157+ if (Get-Command clawdbot - ErrorAction SilentlyContinue) {
158+ return $true
159+ }
160+
161+ $npmPrefix = $null
162+ try {
163+ $npmPrefix = (npm config get prefix 2> $null ).Trim()
164+ } catch {
165+ $npmPrefix = $null
166+ }
167+
168+ if (-not [string ]::IsNullOrWhiteSpace($npmPrefix )) {
169+ $npmBin = Join-Path $npmPrefix " bin"
170+ $userPath = [Environment ]::GetEnvironmentVariable(" Path" , " User" )
171+ if (-not ($userPath -split " ;" | Where-Object { $_ -ieq $npmBin })) {
172+ [Environment ]::SetEnvironmentVariable(" Path" , " $userPath ;$npmBin " , " User" )
173+ $env: Path = [System.Environment ]::GetEnvironmentVariable(" Path" , " Machine" ) + " ;" + [System.Environment ]::GetEnvironmentVariable(" Path" , " User" )
174+ Write-Host " [!] Added $npmBin to user PATH (restart terminal if command not found)" - ForegroundColor Yellow
175+ }
176+ if (Test-Path (Join-Path $npmBin " clawdbot.cmd" )) {
177+ return $true
178+ }
179+ }
180+
181+ Write-Host " [!] clawdbot is not on PATH yet." - ForegroundColor Yellow
182+ Write-Host " Restart PowerShell or add the npm global bin folder to PATH." - ForegroundColor Yellow
183+ if ($npmPrefix ) {
184+ Write-Host " Expected path: $npmPrefix \\bin" - ForegroundColor Cyan
185+ } else {
186+ Write-Host " Hint: run \" npm config get prefix\" to find your npm global path." - ForegroundColor Gray
187+ }
188+ return $false
189+ }
190+
156191function Ensure-Pnpm {
157192 if (Get-Command pnpm - ErrorAction SilentlyContinue) {
158193 return
@@ -189,7 +224,20 @@ function Install-Clawdbot {
189224 $env: NPM_CONFIG_FUND = " false"
190225 $env: NPM_CONFIG_AUDIT = " false"
191226 try {
192- npm install - g " clawdbot@$Tag "
227+ $npmOutput = npm install - g " clawdbot@$Tag " 2>&1
228+ if ($LASTEXITCODE -ne 0 ) {
229+ Write-Host " [!] npm install failed" - ForegroundColor Red
230+ if ($npmOutput -match " spawn git" -or $npmOutput -match " ENOENT.*git" ) {
231+ Write-Host " Error: git is missing from PATH." - ForegroundColor Red
232+ Write-Host " Install Git for Windows, then reopen PowerShell and retry:" - ForegroundColor Yellow
233+ Write-Host " https://git-scm.com/download/win" - ForegroundColor Cyan
234+ } else {
235+ Write-Host " Re-run with verbose output to see the full error:" - ForegroundColor Yellow
236+ Write-Host " iwr -useb https://clawd.bot/install.ps1 | iex" - ForegroundColor Cyan
237+ }
238+ $npmOutput | ForEach-Object { Write-Host $_ }
239+ exit 1
240+ }
193241 } finally {
194242 $env: NPM_CONFIG_LOGLEVEL = $prevLogLevel
195243 $env: NPM_CONFIG_UPDATE_NOTIFIER = $prevUpdateNotifier
@@ -337,6 +385,12 @@ function Main {
337385 Install-Clawdbot
338386 }
339387
388+ if (-not (Ensure- ClawdbotOnPath)) {
389+ Write-Host " Install completed, but Clawdbot is not on PATH yet." - ForegroundColor Yellow
390+ Write-Host " Open a new terminal, then run: clawdbot doctor" - ForegroundColor Cyan
391+ return
392+ }
393+
340394 # Step 3: Run doctor for migrations if upgrading or git install
341395 if ($isUpgrade -or $InstallMethod -eq " git" ) {
342396 Run- Doctor
0 commit comments