Skip to content

Commit 36dd48a

Browse files
yeldarbyclaude
andcommitted
Dump detection diagnostics on Windows when no agents are found
User report: irm | iex still prints "no supported coding agents detected" on a machine where Claude Code is clearly installed. Without seeing the env the detector saw, we can't tell whether APPDATA differs in their elevated shell, whether RF_TEST_NO_DETECT_APPS leaked in, whether the install lives under a different user profile, or whether the probe genuinely missed. Add Show-RfDetectDiagnostics, called only on the no-agents exit path on Windows. Prints: claude-on-PATH status, APPDATA/LOCALAPPDATA values, the test-suppression flag value, whoami, the contents of %APPDATA%\Claude\claude-code\ if it exists, and any sibling user profiles that contain the same dir (the elevated-shell trap). Cheap to compute; only runs on the cold-failure branch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4d13324 commit 36dd48a

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

installer/lib/detect.ps1

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,57 @@ function Get-RfKnownHostIds {
340340
'opencode-cli'
341341
)
342342
}
343+
344+
# Show-RfDetectDiagnostics — dump the inputs the detector saw on Windows
345+
# when nothing was found, so the user can tell us (or see themselves) why.
346+
# Cheap to call; only runs on the failure path.
347+
function Show-RfDetectDiagnostics {
348+
Write-Host ""
349+
Write-RfDim "Detection diagnostics (Windows):"
350+
$appdata = if ($env:APPDATA) { $env:APPDATA } else { '(unset)' }
351+
$localApp = if ($env:LOCALAPPDATA) { $env:LOCALAPPDATA } else { '(unset)' }
352+
$noDetect = if ($env:RF_TEST_NO_DETECT_APPS) { $env:RF_TEST_NO_DETECT_APPS } else { '(unset)' }
353+
$onPath = [bool](Get-Command -Name 'claude' -CommandType Application, ExternalScript -ErrorAction SilentlyContinue)
354+
Write-RfDim " claude on PATH: $onPath"
355+
Write-RfDim " `$env:APPDATA: $appdata"
356+
Write-RfDim " `$env:LOCALAPPDATA: $localApp"
357+
Write-RfDim " `$env:RF_TEST_NO_DETECT_APPS: $noDetect"
358+
Write-RfDim " whoami: $(try { whoami 2>$null } catch { '(failed)' })"
359+
360+
if ($env:APPDATA) {
361+
$codeRoot = Join-Path $env:APPDATA 'Claude\claude-code'
362+
if (Test-Path -LiteralPath $codeRoot) {
363+
Write-RfDim " Probe $codeRoot — EXISTS, subdirs:"
364+
try {
365+
foreach ($d in (Get-ChildItem -LiteralPath $codeRoot -Directory -ErrorAction Stop)) {
366+
$exe = Join-Path $d.FullName 'claude.exe'
367+
$hasExe = Test-Path -LiteralPath $exe -PathType Leaf
368+
Write-RfDim " - $($d.Name) (claude.exe present: $hasExe)"
369+
}
370+
} catch {
371+
Write-RfDim " (enumeration failed: $($_.Exception.Message))"
372+
}
373+
} else {
374+
Write-RfDim " Probe $codeRoot — does NOT exist"
375+
}
376+
}
377+
378+
# Cross-check: maybe the file lives under the *other* user profile, which
379+
# is the typical "elevated PowerShell" trap (APPDATA still points to
380+
# yours, but a sibling profile owns the install).
381+
$usersRoot = Join-Path $env:SystemDrive 'Users'
382+
if (Test-Path -LiteralPath $usersRoot) {
383+
$other = @()
384+
try {
385+
foreach ($u in (Get-ChildItem -LiteralPath $usersRoot -Directory -ErrorAction Stop)) {
386+
$p = Join-Path $u.FullName 'AppData\Roaming\Claude\claude-code'
387+
if (Test-Path -LiteralPath $p) { $other += $p }
388+
}
389+
} catch { }
390+
if ($other.Count -gt 0) {
391+
Write-RfDim " Claude install dirs found under other profiles:"
392+
foreach ($p in $other) { Write-RfDim " - $p" }
393+
Write-RfDim ' Tip: if claude was installed under a different user, run agents.ps1 from that user (or pass --host=claude-code-cli).'
394+
}
395+
}
396+
}

installer/main.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,13 @@ function Invoke-RfMain {
241241
Write-RfWarn "no supported coding agents detected (or selected)"
242242
Write-RfInfo "Install one and re-run, or pass --host=<id> to override detection."
243243
Write-RfInfo "Known host IDs: $((Get-RfKnownHostIds) -join ', ')"
244+
# Windows users hit this when Claude Code is installed off-PATH
245+
# (MSIX Claude Desktop bundle or native Anthropic installer) AND
246+
# our APPDATA probe doesn't see it for some reason — elevated
247+
# shells with a different APPDATA, RF_TEST_NO_DETECT_APPS set in
248+
# the environment, etc. Dump enough diagnostic context that the
249+
# user can see why without us having to ask.
250+
if (Test-RfWindows) { Show-RfDetectDiagnostics }
244251
exit 3
245252
}
246253

0 commit comments

Comments
 (0)