# Actual Computer CLI Installer for Windows # Usage: powershell -c "irm 'actual.inc/install.ps1?channel=stable'|iex" $ErrorActionPreference = "Stop" # TLS 1.2 floor for the unsigned legacy download path (additive: keep any # newer protocols the OS already enables). [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $BaseUrl = "https://dl.actual.inc" $Channel = "stable" $InstallReporting = $false $InstallChannelClass = 'stable' $InstallScript = 'legacy_powershell' $InstallSupportUrl = 'https://dl.actual.inc/supported-platforms' $script:ActualInstallReport = @{ Attempt = [Guid]::NewGuid().ToString('N') Clock = [Diagnostics.Stopwatch]::StartNew() Stage = 'preflight'; Reason = 'unexpected_error'; Outcome = 'failed' Signin = 'not_attempted'; Started = $false; Finished = $false } $Arch = 'unknown' $Backend = 'unknown' function Send-ActualInstallReport([string] $Event) { if (-not $InstallReporting -or $env:ACTUAL_INSTALL_TELEMETRY -eq '0') { return } $state = $script:ActualInstallReport $reportArch = if ($Arch -in @('x86_64', 'aarch64', 'unknown')) { $Arch } else { 'other' } $reportBackend = if ($Backend -in @('cuda', 'rocm', 'unknown')) { $Backend } else { 'other' } $payload = @{ version = 1; attempt = $state.Attempt; event = $Event outcome = $state.Outcome; reason = $state.Reason; signin = $state.Signin os = 'windows'; arch = $reportArch; backend = $reportBackend; os_band = 'unknown' channel = $InstallChannelClass; script = $InstallScript; stage = $state.Stage duration_ms = [Math]::Min(172800000, $state.Clock.ElapsedMilliseconds) } if ($Event -eq 'started') { $payload.outcome = 'started'; $payload.reason = 'none'; $payload.signin = 'not_attempted' } $client = $null $content = $null try { Add-Type -AssemblyName System.Net.Http [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $handler = New-Object Net.Http.HttpClientHandler $handler.AllowAutoRedirect = $false $handler.UseCookies = $false $client = New-Object Net.Http.HttpClient($handler) $client.Timeout = [TimeSpan]::FromSeconds(1) $content = New-Object Net.Http.StringContent(($payload | ConvertTo-Json -Compress), [Text.Encoding]::UTF8, 'application/json') $pendingReport = $client.PostAsync("$BaseUrl/install-report", $content) if (-not $pendingReport.Wait(1000)) { $client.CancelPendingRequests(); return } $response = $pendingReport.GetAwaiter().GetResult() $response.Dispose() } catch { } finally { if ($content) { $content.Dispose() } if ($client) { $client.Dispose() } } } function Start-ActualInstallReport { if (-not $script:ActualInstallReport.Started) { $script:ActualInstallReport.Started = $true Send-ActualInstallReport 'started' } } function Complete-ActualInstallReport { $state = $script:ActualInstallReport if ($state.Finished) { return } $state.Finished = $true Start-ActualInstallReport Send-ActualInstallReport 'finished' } function Stop-ActualInstall([string] $Reason, [string] $Message, [string] $Outcome = 'failed') { $script:ActualInstallReport.Reason = $Reason $script:ActualInstallReport.Outcome = $Outcome throw $Message } function Write-ActualInstallFailure([Exception] $Failure) { $cause = $Failure while ($cause) { if ($cause -is [UnauthorizedAccessException]) { $script:ActualInstallReport.Reason = 'permission_denied' } if ($cause -is [IO.IOException] -and ($cause.HResult -band 0xffff) -eq 112) { $script:ActualInstallReport.Reason = 'disk_full' } $cause = $cause.InnerException } [Console]::Error.WriteLine('Error: ' + $Failure.Message) [Console]::Error.WriteLine('Installation stopped during ' + $script:ActualInstallReport.Stage + ' (' + $script:ActualInstallReport.Reason + ').') switch ($script:ActualInstallReport.Reason) { { $_ -in @('permission_denied', 'disk_full', 'install_io_failed') } { [Console]::Error.WriteLine('Check free disk space and permissions in your user installation directory, then retry.') } 'archive_invalid' { [Console]::Error.WriteLine('The downloaded package could not be extracted or is incomplete. Retry the official installer.') } 'signature_invalid' { [Console]::Error.WriteLine('Retry the official installer. Do not bypass signature verification.') } } [Console]::Error.WriteLine('Help: ' + $InstallSupportUrl) } function Get-ActualInstallDownload([string] $Url, [string] $Destination) { try { Invoke-WebRequest -Uri $Url -OutFile $Destination -UseBasicParsing -TimeoutSec 600 } catch { $response = $_.Exception.Response $status = 0 $reason = '' if ($response) { $status = [int] $response.StatusCode try { $reason = [string] ($response.Headers.GetValues('X-Actual-Download-Reason') | Select-Object -Last 1) } catch { try { $reason = [string] $response.Headers['X-Actual-Download-Reason'] } catch {} } } switch ($status) { 401 { Stop-ActualInstall 'authentication_required' 'Download authorization is missing or expired. Obtain a fresh install command and retry.' } 403 { Stop-ActualInstall 'access_denied' 'This install command cannot access the selected release. Check your account access or obtain a fresh command.' } 404 { if ($reason -eq 'channel_not_found') { Stop-ActualInstall 'channel_not_found' 'The selected release channel is not available. Check the install command or retry later.' } Stop-ActualInstall 'artifact_not_found' 'The selected build is not available in this release. Your hardware may be supported; retry the release later.' } } if ($status -ge 500) { Stop-ActualInstall 'download_unavailable' 'The download service is temporarily unavailable. Retry later.' } if ($_.Exception -is [OperationCanceledException] -or $_.Exception.InnerException -is [OperationCanceledException] -or $_.Exception.Status -eq [Net.WebExceptionStatus]::Timeout) { Stop-ActualInstall 'download_timeout' 'The download timed out. Check your network and retry.' } if ($_.Exception.Status -in @([Net.WebExceptionStatus]::TrustFailure, [Net.WebExceptionStatus]::SecureChannelFailure) -or $_.Exception.InnerException -is [Security.Authentication.AuthenticationException]) { Stop-ActualInstall 'tls_failed' 'A secure download connection could not be verified. Check the system clock, certificates, and network.' } Stop-ActualInstall 'download_failed' 'The download failed. Check your network and retry the official installer.' } } function Test-ActualInstalledStartup([string] $Executable) { $script:ActualInstallReport.Stage = 'startup' $script:ActualInstallReport.Reason = 'binary_startup_failed' $code = -1 $originalPath = $env:PATH try { foreach ($runtime in @($env:HIP_PATH, $env:ROCM_PATH)) { if ($runtime -and (Test-Path (Join-Path $runtime 'bin'))) { $env:PATH = (Join-Path $runtime 'bin') + ';' + $env:PATH } } $output = & $Executable --version 2>&1 $code = $LASTEXITCODE } catch { $output = $_ } finally { $env:PATH = $originalPath } if ($code -ne 0) { [Console]::Error.WriteLine([string] ($output | Out-String)) if ($code -in @(-1073741515, -1073741701)) { Stop-ActualInstall 'runtime_prerequisite' 'The installed client cannot load a required system or GPU runtime. Update the selected runtime and retry.' 'blocked' } Stop-ActualInstall 'binary_startup_failed' 'The installed client could not start. Check the prerequisite error above and retry.' } } try { try { $nativeArch = [Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString() } catch { $nativeArch = if ($env:PROCESSOR_ARCHITEW6432) { $env:PROCESSOR_ARCHITEW6432 } else { $env:PROCESSOR_ARCHITECTURE } } $Arch = switch ($nativeArch) { { $_ -in @('X64', 'AMD64') } { 'x86_64'; break } 'ARM64' { 'aarch64'; break } default { 'other' } } if ($Arch -notin @('x86_64')) { Stop-ActualInstall 'unsupported_architecture' 'Actual requires 64-bit Windows on x86_64. Windows ARM and 32-bit Windows do not have builds.' 'blocked' } $Backend = $env:ACTUAL_BACKEND if (-not $Backend) { $rocmInstalled = ($env:HIP_PATH -and (Test-Path $env:HIP_PATH)) -or ($env:ROCM_PATH -and (Test-Path $env:ROCM_PATH)) -or (Test-Path 'C:\Program Files\AMD\ROCm') $Backend = if ($rocmInstalled) { 'rocm' } else { 'cuda' } } Start-ActualInstallReport if ("$Arch-$Backend" -notin @('x86_64-cuda', 'x86_64-rocm')) { Stop-ActualInstall 'unsupported_backend' 'Unsupported ACTUAL_BACKEND value. Use cuda for NVIDIA or rocm for AMD.' 'blocked' } $ArtifactSuffix = if ($Backend -eq "rocm") { "-rocm" } else { "" } $Artifact = "actual-windows-$Arch$ArtifactSuffix.zip" $DownloadUrl = "$BaseUrl/actual/client/$Channel/$($Artifact)" Write-Host "Installing Actual Computer CLI..." Write-Host " OS: windows" Write-Host " Arch: $Arch" Write-Host " Backend: $Backend" # Create temp directory $TmpDir = New-Item -ItemType Directory -Path (Join-Path $env:TEMP ([System.IO.Path]::GetRandomFileName())) try { # Download $script:ActualInstallReport.Stage = 'download' $script:ActualInstallReport.Reason = 'download_failed' Write-Host "Downloading..." $ZipPath = Join-Path $TmpDir $Artifact Get-ActualInstallDownload $DownloadUrl $ZipPath # Extract $script:ActualInstallReport.Stage = 'extract' $script:ActualInstallReport.Reason = 'archive_invalid' Write-Host "Extracting..." Expand-Archive -Path $ZipPath -DestinationPath $TmpDir -Force if (-not (Test-Path (Join-Path $TmpDir "actual.exe"))) { Write-Error "Zip did not contain actual.exe at the root." Get-ChildItem -Path $TmpDir exit 1 } # Install to ~/.actual/bin (user-writable, no sudo needed for updates). # Stable zips can be either the old single-binary layout (actual.exe only) # or the newer multi-binary layout (actual.exe + actual-daemon.exe), # with optionally bundled DLLs at root. Windows DLL search resolves from # the .exe's own directory, so we copy everything into InstallDir. Test-ActualInstalledStartup (Join-Path $TmpDir 'actual.exe') $script:ActualInstallReport.Stage = 'install' $script:ActualInstallReport.Reason = 'install_io_failed' $InstallDir = Join-Path $HOME ".actual\bin" New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null Copy-Item (Join-Path $TmpDir "actual.exe") -Destination $InstallDir -Force $DaemonPath = Join-Path $TmpDir "actual-daemon.exe" if (Test-Path $DaemonPath) { Copy-Item $DaemonPath -Destination $InstallDir -Force } else { Remove-Item (Join-Path $InstallDir "actual-daemon.exe") -Force -ErrorAction SilentlyContinue Write-Host "Stable archive did not include actual-daemon.exe; installed legacy single-binary client." } # Copy aci-cpp's engine binary when the zip carries it; actual-daemon runs # it as a managed sibling process resolved beside its own executable. # Older zips do not include it, so it stays optional. $EnginePath = Join-Path $TmpDir "aci-server.exe" if (Test-Path $EnginePath) { Copy-Item $EnginePath -Destination $InstallDir -Force } # Mirror any bundled DLLs alongside actual.exe. Get-ChildItem -Path $TmpDir -Filter *.dll -File -ErrorAction SilentlyContinue | ForEach-Object { Copy-Item $_.FullName -Destination $InstallDir -Force } Write-Host "Installed to $InstallDir\actual.exe" # Create symlink in ~/.local/bin for immediate availability (if supported) # Windows symlinks require Developer Mode or admin privileges $LocalBin = Join-Path $HOME ".local\bin" New-Item -ItemType Directory -Path $LocalBin -Force | Out-Null try { $SymlinkPath = Join-Path $LocalBin "actual.exe" if (Test-Path $SymlinkPath) { Remove-Item $SymlinkPath -Force } New-Item -ItemType SymbolicLink -Path $SymlinkPath -Target (Join-Path $InstallDir "actual.exe") -ErrorAction Stop | Out-Null Write-Host "Created symlink at $SymlinkPath" } catch { # Symlinks require Developer Mode or admin - fall back to PATH only Write-Host "Note: Symlink creation skipped (requires Developer Mode)" } # Add to PATH if not already there $PathUpdated = $false $UserPath = [Environment]::GetEnvironmentVariable("Path", "User") if ($UserPath -notlike "*$InstallDir*") { try { [Environment]::SetEnvironmentVariable("Path", "$UserPath;$InstallDir", "User") # Verify it was set $VerifyPath = [Environment]::GetEnvironmentVariable("Path", "User") if ($VerifyPath -like "*$InstallDir*") { Write-Host "Added $InstallDir to PATH" $PathUpdated = $true } else { Write-Warning "Failed to add to PATH. You may need to add manually:" Write-Warning " $InstallDir" } } catch { Write-Warning "Failed to update PATH: $_" Write-Warning "You may need to add manually: $InstallDir" } } else { Write-Host "PATH already configured" } # ROCm builds dynamically link against amdhip64.dll / hipblas.dll / # rocblas.dll which live in the system ROCm install at HIP_PATHin # (or ROCM_PATHin). Add it to user PATH so actual.exe finds them # whenever the user opens a new shell. Skip if it's already there. if ($Backend -eq "rocm") { $rocmBin = $null if ($env:HIP_PATH -and (Test-Path (Join-Path $env:HIP_PATH "bin"))) { $rocmBin = Join-Path $env:HIP_PATH "bin" } elseif ($env:ROCM_PATH -and (Test-Path (Join-Path $env:ROCM_PATH "bin"))) { $rocmBin = Join-Path $env:ROCM_PATH "bin" } if ($rocmBin) { $UserPath = [Environment]::GetEnvironmentVariable("Path", "User") if ($UserPath -notlike "*$rocmBin*") { try { [Environment]::SetEnvironmentVariable("Path", "$UserPath;$rocmBin", "User") Write-Host "Added ROCm runtime ($rocmBin) to PATH" } catch { Write-Warning "Failed to add ROCm runtime to PATH: $_" Write-Warning "Add manually so actual.exe can load amdhip64.dll: $rocmBin" } } # Current session: prepend so the install-time login below works. $env:Path = "$rocmBin;$env:Path" } else { Write-Warning "ROCm install detected but neither HIP_PATHin nor ROCM_PATHin resolves." Write-Warning "actual.exe will fail to load amdhip64.dll until you put the ROCm bin dir on PATH." } } # Add to current session PATH $env:Path = "$InstallDir;$env:Path" $InstalledActual = Join-Path $InstallDir 'actual.exe' Test-ActualInstalledStartup $InstalledActual $script:ActualInstallReport.Stage = 'signin' $script:ActualInstallReport.Reason = 'unexpected_error' $script:ActualInstallReport.Signin = 'incomplete' # Authenticate after install Write-Host "Logging in..." $LoginSucceeded = $false $env:RUST_LOG = "off" & "$InstallDir\actual.exe" login $env:RUST_LOG = $null if ($LASTEXITCODE -ne 0) { Write-Warning "Login failed. Run 'actual login' manually to authenticate." } else { $LoginSucceeded = $true $script:ActualInstallReport.Signin = 'complete' } $script:ActualInstallReport.Stage = 'finalize' $script:ActualInstallReport.Reason = 'install_io_failed' Write-Host "Locking update channel..." try { & "$InstallDir\actual.exe" update --channel $Channel --check-only | Out-Null if ($LASTEXITCODE -eq 0) { Write-Host "Update channel locked to $Channel" } else { Write-Warning "Failed to set update channel via actual update, writing state file" } } catch { Write-Warning "Failed to set update channel via actual update, writing state file" } $stateDir = Join-Path $HOME ".actual\state" $stateFile = Join-Path $stateDir "active_version.json" New-Item -ItemType Directory -Path $stateDir -Force | Out-Null $buildSha = (& "$InstallDir\actual.exe" --build-sha 2>$null) if (-not $buildSha) { $buildSha = "unknown" } $state = $null if (Test-Path $stateFile) { try { $state = Get-Content $stateFile -Raw | ConvertFrom-Json } catch { $state = $null } } if (-not $state) { $state = [ordered]@{ activeVersion = $buildSha previousVersion = $null channel = $Channel lastSwap = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") } } else { $state.activeVersion = $buildSha $state.channel = $Channel $state.lastSwap = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") } $state | ConvertTo-Json -Depth 3 | Set-Content -Path $stateFile Write-Host "Update channel set in state file: $Channel" Write-Host "" if ($LoginSucceeded) { Write-Host "Actual client installed and sign-in complete." $NextCommand = "actual" } else { Write-Host "Actual client installed. Sign-in is incomplete." $NextCommand = "actual login" } if ($PathUpdated) { Write-Host "" Write-Host "To use 'actual', open a new PowerShell or Command Prompt window." Write-Host "Then run '$NextCommand'." } else { Write-Host "Run '$NextCommand'." } } finally { # Cleanup Remove-Item -Recurse -Force $TmpDir -ErrorAction SilentlyContinue } $script:ActualInstallReport.Outcome = 'installed' $script:ActualInstallReport.Reason = 'none' $script:ActualInstallReport.Stage = 'done' } catch { Write-ActualInstallFailure $_.Exception exit 1 } finally { Complete-ActualInstallReport }