Skip to content

[BUG] install.ps1 prints "✅ Installation complete!" even when claude.exe install fails in Windows Powershell - #26880

Description

@dronewai

irm https://claude.ai/install.ps1 | iex Setting up Claude Code... × Installation failed Checksum mismatch: expected b29dca8880f7bcd8820909cb630f0bace6e8a4a126caa7aafdd5ca2dbd13c497, got e677b695c8418c687d5084cd88012d36be9695e8db59510531023601e4a0deeb Try running with --force to override checks ✅ Installation complete!

Bug Description

The PowerShell installer (install.ps1) prints ✅ Installation complete! even when the installation subprocess fails.

Root cause: The script calls & $binaryPath install $Target (an external process) inside a try/finally block but never checks $LASTEXITCODE after it. In PowerShell, $ErrorActionPreference = "Stop" only applies to cmdlets — it does not throw on non-zero exit codes from external executables. So when claude.exe install fails and exits with a non-zero code, PowerShell silently continues and executes the success message on the next line.

Relevant code in install.ps1:

try {
    & $binaryPath install $Target   # ← fails, exits non-zero
}
finally {
    Remove-Item -Force $binaryPath  # ← cleanup runs (correct)
}

Write-Output "✅ Installation complete!"  # ← BUG: always runs regardless of exit code

Proposed fix:

try {
    if ($Target) {
        & $binaryPath install $Target
    } else {
        & $binaryPath install
    }

    # $ErrorActionPreference = "Stop" does NOT cover external processes.
    # Must check $LASTEXITCODE explicitly for any executable called with &
    if ($LASTEXITCODE -ne 0) {
        Write-Error "Installation failed (claude.exe exited with code $LASTEXITCODE)"
        exit $LASTEXITCODE
    }
}
finally {
    try {
        Start-Sleep -Seconds 1
        Remove-Item -Force $binaryPath
    }
    catch {
        Write-Warning "Could not remove temporary file: $binaryPath"
    }
}

# Only reached if $LASTEXITCODE -eq 0
Write-Output ""
Write-Output "$([char]0x2705) Installation complete!"
Write-Output ""

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleIssue is inactive

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions