Skip to content

Commit 4321350

Browse files
yeldarbyclaude
andcommitted
Detect tests: honor RF_TEST_NO_DETECT_APPS in the Unix fallback too
Resolve-RfClaudeCliPath's macOS/Linux fallback unconditionally checked /usr/local/bin/claude and /opt/homebrew/bin/claude, so on any dev box with Claude Code installed the Pester "claude is nowhere" tests in Detect.Tests.ps1 picked up the real binary and failed. The Windows install-dir probe already respected RF_TEST_NO_DETECT_APPS=1 for exactly this reason; the Unix branch was missed. Add the same guard. New-RfIsolatedHome already sets the flag, so the Detect tests inherit it; the Resolve / Test-RfHostClaudeCodeCli BeforeEach blocks now only clear it on Windows (they need the install-dir probe to fire against the fake APPDATA tree). Pester on macOS dev box: 53/53 passing (was 51/53). Windows behavior unchanged because the new guard sits inside `if Test-RfMacOS -or Test-RfLinux`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e7d217c commit 4321350

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

installer/lib/detect.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@ function Resolve-RfClaudeCliPath {
135135
}
136136

137137
# 4. macOS / Linux off-PATH install locations.
138-
if (Test-RfMacOS -or Test-RfLinux) {
138+
# Same suppression flag the Windows block uses, so the Pester suite's
139+
# "no agents installed" tests pass on a dev Mac that has a real
140+
# /usr/local/bin/claude.
141+
if ((Test-RfMacOS) -or (Test-RfLinux)) {
142+
if ($env:RF_TEST_NO_DETECT_APPS -eq '1') { return $null }
139143
$unixFallbacks = @()
140144
$share = Join-Path $HOME '.local/share/anthropic-claude/claude-code'
141145
if (Test-Path -LiteralPath $share) {

tests/pester/Detect.Tests.ps1

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ Describe 'Resolve-RfClaudeCliPath' {
3333
New-Item -ItemType Directory -Path $env:LOCALAPPDATA -Force | Out-Null
3434
# New-RfIsolatedHome sets RF_TEST_NO_DETECT_APPS=1 (desktop-app
3535
# suppression), but this Describe is *testing* the install-dir
36-
# probe specifically. Clear the flag inside the controlled APPDATA
37-
# so we exercise the code under test.
38-
Remove-Item Env:RF_TEST_NO_DETECT_APPS -ErrorAction SilentlyContinue
36+
# probe specifically. Clear the flag on Windows so we exercise the
37+
# code under test. On Unix, leave it set so the macOS fallback
38+
# (/usr/local/bin/claude, /opt/homebrew/bin/claude) doesn't pick up
39+
# a real dev-box install during the "claude is nowhere" test.
40+
if ($script:rfTestIsWindows) {
41+
Remove-Item Env:RF_TEST_NO_DETECT_APPS -ErrorAction SilentlyContinue
42+
}
3943
}
4044
AfterEach {
4145
$env:APPDATA = $script:origAppData
@@ -175,7 +179,12 @@ Describe 'Test-RfHostClaudeCodeCli' {
175179
$env:LOCALAPPDATA = Join-Path $script:rfHome 'AppData/Local'
176180
New-Item -ItemType Directory -Path $env:APPDATA -Force | Out-Null
177181
New-Item -ItemType Directory -Path $env:LOCALAPPDATA -Force | Out-Null
178-
Remove-Item Env:RF_TEST_NO_DETECT_APPS -ErrorAction SilentlyContinue
182+
# Clear on Windows so the install-dir probe runs against our fake
183+
# APPDATA; leave set on Unix so a real /usr/local/bin/claude doesn't
184+
# leak into "not installed" expectations.
185+
if ($script:rfTestIsWindows) {
186+
Remove-Item Env:RF_TEST_NO_DETECT_APPS -ErrorAction SilentlyContinue
187+
}
179188
}
180189
AfterEach {
181190
$env:APPDATA = $script:origAppData

0 commit comments

Comments
 (0)