Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(cua-driver): report surviving local install on uninstall (#3021)

injaneity625118a9076e
diff --git a/.github/workflows/ci-test-scripts.yml b/.github/workflows/ci-test-scripts.yml
index 851bc49ef8..cb5e970283 100644
--- a/.github/workflows/ci-test-scripts.yml
+++ b/.github/workflows/ci-test-scripts.yml
@@ -46,6 +46,19 @@ on:
- "scripts/ci/macos/**"
jobs:
+ windows-uninstall:
+ runs-on: windows-latest
+ timeout-minutes: 5
+ permissions:
+ contents: read
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ persist-credentials: false
+ - name: Test Windows release uninstall reporting
+ shell: powershell
+ run: '& ./libs/cua-driver/scripts/tests/uninstall-windows-regression.ps1'
+
test:
runs-on: ubuntu-latest
diff --git a/libs/cua-driver/scripts/tests/test_uninstall_autostart.py b/libs/cua-driver/scripts/tests/test_uninstall_autostart.py
index 7689adaba9..cf26dda37a 100644
--- a/libs/cua-driver/scripts/tests/test_uninstall_autostart.py
+++ b/libs/cua-driver/scripts/tests/test_uninstall_autostart.py
@@ -152,3 +152,39 @@ def test_current_autostart_file_is_a_rust_install_marker(
assert not autostart_file.exists()
assert not skill_link.is_symlink()
+
+
[email protected]("os_name", ["Linux", "Darwin"])
+def test_release_uninstall_reports_and_preserves_local_product(
+ tmp_path: Path, os_name: str
+) -> None:
+ home, calls, env = _sandbox(tmp_path, os_name)
+ local_home = home / ".cua-driver-local"
+ local_marker = local_home / "packages/current/cua-driver-local"
+ local_marker.parent.mkdir(parents=True)
+ local_marker.write_text("local driver\n", encoding="utf-8")
+ local_cli = home / ".local/bin/cua-driver-local"
+ local_cli.parent.mkdir(parents=True)
+ local_cli.symlink_to(local_marker)
+
+ result = _run_uninstall(env)
+
+ assert "cua-driver-local" not in (calls.read_text() if calls.exists() else "")
+ assert local_cli.is_symlink()
+ assert local_marker.read_text(encoding="utf-8") == "local driver\n"
+ assert "a separate source-built cua-driver-local installation remains" in result.stdout
+ assert str(local_cli) in result.stdout
+ assert "./libs/cua-driver/scripts/uninstall-local.sh" in result.stdout
+
+
+def test_release_uninstall_ignores_marker_free_local_home(tmp_path: Path) -> None:
+ home, calls, env = _sandbox(tmp_path, "Linux")
+ local_home = home / ".cua-driver-local"
+ local_home.mkdir()
+ (local_home / "unrelated.txt").write_text("keep\n", encoding="utf-8")
+
+ result = _run_uninstall(env)
+
+ assert "cua-driver-local" not in (calls.read_text() if calls.exists() else "")
+ assert (local_home / "unrelated.txt").read_text(encoding="utf-8") == "keep\n"
+ assert "source-built cua-driver-local installation remains" not in result.stdout
diff --git a/libs/cua-driver/scripts/tests/test_uninstall_local.py b/libs/cua-driver/scripts/tests/test_uninstall_local.py
index 296c179911..6247bfdcce 100644
--- a/libs/cua-driver/scripts/tests/test_uninstall_local.py
+++ b/libs/cua-driver/scripts/tests/test_uninstall_local.py
@@ -187,9 +187,12 @@ def test_unix_local_uninstall_rejects_release_home_override(tmp_path: Path) -> N
assert "release-owned local home" in result.stderr
-def test_release_uninstallers_do_not_target_local_identity() -> None:
- for name in ("uninstall.sh", "uninstall.ps1"):
- script = (SCRIPTS / name).read_text(encoding="utf-8-sig")
- assert "CuaDriverLocal" not in script
- assert ".cua-driver-local" not in script
- assert "cua-driver-local-serve" not in script
+def test_unix_release_uninstaller_declares_local_detection_inputs() -> None:
+ unix = (SCRIPTS / "uninstall.sh").read_text(encoding="utf-8-sig")
+
+ for token in (
+ "CUA_DRIVER_LOCAL_HOME",
+ "CUA_DRIVER_LOCAL_INSTALL_DIR",
+ "/Applications/CuaDriverLocal.app",
+ ):
+ assert token in unix
diff --git a/libs/cua-driver/scripts/tests/uninstall-windows-regression.ps1 b/libs/cua-driver/scripts/tests/uninstall-windows-regression.ps1
new file mode 100644
index 0000000000..899f1dc90f
--- /dev/null
+++ b/libs/cua-driver/scripts/tests/uninstall-windows-regression.ps1
@@ -0,0 +1,147 @@
+param([string]$CaseName)
+
+Set-StrictMode -Version Latest
+$ErrorActionPreference = 'Stop'
+if ($PSVersionTable.PSVersion.ToString() -notlike '5.1.*') { throw 'Windows PowerShell 5.1 required' }
+$FixtureRoot = $env:CUA_UNINSTALL_FIXTURE_ROOT
+$DefaultCli = 'localappdata\Programs\Cua\cua-driver-local\bin\cua-driver-local.exe'
+$Cases = [ordered]@{
+ 'default-cli' = @{ Local = $DefaultCli }
+ 'configured-cli' = @{ Local = 'custom bin\cua-driver-local.exe'; Env = 'CUA_DRIVER_LOCAL_INSTALL_DIR'; Value = 'custom bin' }
+ 'default-marker' = @{ Local = 'profile\.cua-driver-local\packages\current\cua-driver-local.exe' }
+ 'configured-marker' = @{ Local = 'custom home\packages\current\cua-driver-local.exe'; Env = 'CUA_DRIVER_LOCAL_HOME'; Value = 'custom home' }
+ 'path-cli' = @{ Local = 'bin\cua-driver-local.exe' }
+ 'marker-free-home' = @{}
+ 'file-entrypoint' = @{ Local = $DefaultCli }
+ 'guard-remove' = @{ Command = "Remove-Item -LiteralPath '..\outside.txt' -Force" }
+ 'guard-stop' = @{ Command = 'Stop-Process -Id $PID -Force' }
+ 'guard-start' = @{ Command = "Start-Process -FilePath '.\missing.exe'" }
+ 'guard-discovery' = @{ Command = 'Get-Process -Name fixture-not-running' }
+ 'guard-task' = @{ Command = 'schtasks.exe /Delete /TN fixture-nonexistent /F' }
+}
+function Assert-Fixture([bool]$Condition, [string]$Message) {
+ if (-not $Condition) { throw $Message }
+}
+if ($CaseName -and -not $Cases.Contains($CaseName)) { throw "unknown case: $CaseName" }
+if (-not $FixtureRoot) {
+ $RunRoot = Join-Path ([IO.Path]::GetTempPath()) ('cua uninstall ' + [guid]::NewGuid().ToString('N'))
+ [void][IO.Directory]::CreateDirectory($RunRoot)
+ $Outside = Join-Path $RunRoot 'outside.txt'
+ [IO.File]::WriteAllText($Outside, 'keep')
+ $Names = @($Cases.Keys)
+ if ($CaseName) { $Names = @($CaseName) }
+ try {
+ foreach ($Name in $Names) {
+ $Root = Join-Path $RunRoot $Name
+ [void][IO.Directory]::CreateDirectory($Root)
+ $Arguments = "-NoLogo -NoProfile -NonInteractive -File `"$PSCommandPath`" -CaseName $Name"
+ $Start = [Diagnostics.ProcessStartInfo]::new("$PSHOME\powershell.exe", $Arguments)
+ $Start.UseShellExecute = $false
+ $Start.WorkingDirectory = $Root
+ $Start.RedirectStandardOutput = $true
+ $Start.RedirectStandardError = $true
+ $Start.RedirectStandardInput = $true
+ $Start.EnvironmentVariables.Clear()
+ $Start.EnvironmentVariables['SystemRoot'] = $env:SystemRoot
+ $Start.EnvironmentVariables['CUA_UNINSTALL_FIXTURE_ROOT'] = $Root
+ $Start.EnvironmentVariables['CUA_DRIVER_RS_UNINSTALL_FORCE'] = '1'
+ $Start.EnvironmentVariables['PATHEXT'] = '.EXE'
+ $Directories = @{
+ USERPROFILE = 'profile'; LOCALAPPDATA = 'localappdata'; APPDATA = 'appdata'
+ TEMP = 'temp'; TMP = 'temp'; PATH = 'bin'; PSModulePath = 'modules'
+ }
+ foreach ($Entry in $Directories.GetEnumerator()) {
+ $Value = Join-Path $Root $Entry.Value
+ [void][IO.Directory]::CreateDirectory($Value)
+ $Start.EnvironmentVariables[$Entry.Key] = $Value
+ }
+ if ($Cases[$Name]['Env']) {
+ $Start.EnvironmentVariables[$Cases[$Name]['Env']] = Join-Path $Root $Cases[$Name]['Value']
+ }
+ $Child = [Diagnostics.Process]::Start($Start)
+ try {
+ $Child.StandardInput.Close()
+ $Stdout = $Child.StandardOutput.ReadToEndAsync()
+ $Stderr = $Child.StandardError.ReadToEndAsync()
+ if (-not $Child.WaitForExit(30000)) {
+ $Child.Kill()
+ $Child.WaitForExit()
+ throw "$Name timed out"
+ }
+ $Output = $Stdout.GetAwaiter().GetResult() + $Stderr.GetAwaiter().GetResult()
+ if ($Cases[$Name]['Command']) {
+ Assert-Fixture ($Child.ExitCode -ne 0 -and $Output.Contains('fixture refused host operation')) "$Name did not refuse: $Output"
+ } else {
+ Assert-Fixture ($Child.ExitCode -eq 0) "$Name failed: $Output"
+ }
+ Assert-Fixture ([IO.File]::ReadAllText($Outside) -eq 'keep') 'outside artifact changed'
+ Write-Host "PASS $Name"
+ } finally { $Child.Dispose() }
+ }
+ Write-Host "$($Names.Count) Windows uninstall cases passed"
+ } finally { Microsoft.PowerShell.Management\Remove-Item -LiteralPath $RunRoot -Recurse -Force }
+ return
+}
+
+$FixtureCase = $Cases[$CaseName]
+$FixtureRoot = [IO.Path]::GetFullPath($FixtureRoot).TrimEnd('\') + '\'
+$FixtureViolations = [Collections.Generic.List[string]]::new()
+function Deny-HostOperation([string]$Operation) {
+ $FixtureViolations.Add($Operation)
+ throw "fixture refused host operation: $Operation"
+}
+function Get-Process {
+ [CmdletBinding()] param([string[]]$Name)
+ if (($Name -join ' ') -ne 'cua-driver') { Deny-HostOperation "Get-Process $Name" }
+ return @()
+}
+function schtasks.exe {
+ if (($args -join ' ') -ne '/Query /TN cua-driver-serve') { Deny-HostOperation "schtasks.exe $args" }
+ $global:LASTEXITCODE = 1
+}
+function Stop-Process { Deny-HostOperation 'Stop-Process' }
+function Start-Process { Deny-HostOperation 'Start-Process' }
+function Read-Host { Deny-HostOperation 'Read-Host' }
+function Remove-Item {
+ [CmdletBinding()] param([string]$LiteralPath, [switch]$Force, [switch]$Recurse)
+ $Resolved = [IO.Path]::GetFullPath($LiteralPath)
+ if (-not $Resolved.StartsWith($FixtureRoot, [StringComparison]::OrdinalIgnoreCase)) {
+ Deny-HostOperation "Remove-Item $LiteralPath"
+ }
+ Microsoft.PowerShell.Management\Remove-Item @PSBoundParameters
+}
+if ($FixtureCase['Command']) {
+ try { Invoke-Expression $FixtureCase['Command'] } catch {}
+} else {
+ $FixtureRelease = Join-Path $FixtureRoot 'profile\.cua-driver\packages\current\cua-driver.exe'
+ $FixtureHome = if ($FixtureCase['Env'] -eq 'CUA_DRIVER_LOCAL_HOME') { $FixtureCase['Value'] } else { 'profile\.cua-driver-local' }
+ $FixtureFiles = @((Join-Path $FixtureRoot "$FixtureHome\config.json"))
+ if ($FixtureCase['Local']) { $FixtureFiles += Join-Path $FixtureRoot $FixtureCase['Local'] }
+ foreach ($Path in @($FixtureRelease) + $FixtureFiles) {
+ [void][IO.Directory]::CreateDirectory([IO.Path]::GetDirectoryName($Path))
+ [IO.File]::WriteAllText($Path, 'fixture payload')
+ }
+ $Uninstaller = Join-Path (Split-Path -Parent $PSScriptRoot) 'uninstall.ps1'
+ if ($CaseName -eq 'file-entrypoint') {
+ $FixtureOutput = & $Uninstaller 6>&1
+ $FixtureSucceeded = $?
+ } else {
+ $FixtureOutput = Invoke-Expression ([Text.Encoding]::UTF8.GetString([IO.File]::ReadAllBytes($Uninstaller))) 6>&1
+ $FixtureSucceeded = $?
+ }
+ Assert-Fixture $FixtureSucceeded 'uninstaller failed'
+ $FixtureOutput = ($FixtureOutput | ForEach-Object { $_.ToString() }) -join "`n"
+ Assert-Fixture (-not (Test-Path -LiteralPath $FixtureRelease)) 'release payload remains'
+ foreach ($Path in $FixtureFiles) {
+ Assert-Fixture ((Test-Path -LiteralPath $Path) -and [IO.File]::ReadAllText($Path) -eq 'fixture payload') "local artifact changed: $Path"
+ }
+ $Notice = 'source-built cua-driver-local installation remains'
+ if ($FixtureCase['Local']) {
+ Assert-Fixture ($FixtureOutput.Contains($Notice)) 'missing survivor notice'
+ Assert-Fixture ($FixtureOutput.Contains((Join-Path $FixtureRoot $FixtureCase['Local']))) "missing survivor path: $FixtureOutput"
+ Assert-Fixture ($FixtureOutput.Contains('.\libs\cua-driver\scripts\uninstall-local.ps1')) 'missing removal instruction'
+ } else {
+ Assert-Fixture (-not $FixtureOutput.Contains($Notice)) 'false survivor notice'
+ }
+}
+Assert-Fixture ($FixtureViolations.Count -eq 0) "fixture refused host operations: $($FixtureViolations -join ', ')"
diff --git a/libs/cua-driver/scripts/uninstall.ps1 b/libs/cua-driver/scripts/uninstall.ps1
index c86cb7679e..fbf78e2657 100644
--- a/libs/cua-driver/scripts/uninstall.ps1
+++ b/libs/cua-driver/scripts/uninstall.ps1
@@ -119,7 +119,7 @@ function Test-NeedsElevation {
if (-not (Test-IsElevated) -and (Test-NeedsElevation)) {
Write-Host "==> cua-driver-rs uninstaller: detected -AutoStart install state" -ForegroundColor Cyan
Write-Host " (the 'cua-driver-serve' task is RunLevel=Highest and/or a daemon is"
- Write-Host " running at High IL). Removing them needs admin — triggering UAC prompt."
+ Write-Host " running at High IL). Removing them needs admin - triggering UAC prompt."
# Re-exec self elevated. $MyInvocation.MyCommand.Path is set when invoked
# from a file on disk; empty when piped through `irm ... | iex` (the
@@ -145,7 +145,7 @@ if (-not (Test-IsElevated) -and (Test-NeedsElevation)) {
} catch {
Write-Host "error: failed to elevate ($($_.Exception.Message))" -ForegroundColor Red
Write-Host " Re-run this script from an elevated PowerShell instead:" -ForegroundColor Yellow
- Write-Host " Right-click PowerShell → Run as Administrator, then re-run the uninstall." -ForegroundColor Yellow
+ Write-Host " Right-click PowerShell -> Run as Administrator, then re-run the uninstall." -ForegroundColor Yellow
exit 1
}
}
@@ -357,7 +357,7 @@ if (Test-Path -LiteralPath $VisibleBinDir) {
Write-Step "skipped $VisibleBinDir (user declined)"
}
} else {
- Write-WarningStep "$VisibleBinDir exists but is not a reparse point — refusing to remove."
+ Write-WarningStep "$VisibleBinDir exists but is not a reparse point - refusing to remove."
Write-WarningStep " install.ps1 only creates junctions at this path, so this is likely a hand-managed directory."
}
} else {
@@ -371,7 +371,7 @@ if (Test-Path -LiteralPath $CurrentDir) {
Remove-Item -LiteralPath $CurrentDir -Force -Recurse -ErrorAction SilentlyContinue
Write-Step "removed junction $CurrentDir"
} else {
- Write-WarningStep "$CurrentDir exists but is not a reparse point — leaving it for the package-home pass below."
+ Write-WarningStep "$CurrentDir exists but is not a reparse point - leaving it for the package-home pass below."
}
}
@@ -388,7 +388,7 @@ if (Test-Path -LiteralPath $HomeDir) {
if ($Purge) {
Remove-Item -LiteralPath $HomeDir -Force -Recurse -ErrorAction SilentlyContinue
if (Test-Path -LiteralPath $HomeDir) {
- Write-WarningStep "$HomeDir was not fully removed — some files may still be locked."
+ Write-WarningStep "$HomeDir was not fully removed - some files may still be locked."
Write-WarningStep " Close any open cua-driver processes / shells with cwd inside the tree and re-run."
} else {
Write-Step "purged $HomeDir (including telemetry identity and preference)"
@@ -446,7 +446,7 @@ if (Test-Path -LiteralPath $LegacyHomeDir) {
if ($Purge) {
Remove-Item -LiteralPath $LegacyHomeDir -Force -Recurse -ErrorAction SilentlyContinue
if (Test-Path -LiteralPath $LegacyHomeDir) {
- Write-WarningStep "$LegacyHomeDir was not fully removed — some files may still be locked."
+ Write-WarningStep "$LegacyHomeDir was not fully removed - some files may still be locked."
} else {
Write-Step "purged legacy package home $LegacyHomeDir"
}
@@ -475,7 +475,7 @@ foreach ($skillLink in $SkillJunctions) {
Remove-Item -LiteralPath $skillLink -Force -Recurse -ErrorAction SilentlyContinue
Write-Step "removed skill junction $skillLink"
} else {
- Write-Step "$skillLink is a real directory (not a reparse point) — skipping"
+ Write-Step "$skillLink is a real directory (not a reparse point) - skipping"
}
} else {
Write-Step "no skill junction at $skillLink (skipping)"
@@ -514,3 +514,27 @@ Write-Host " [Environment]::SetEnvironmentVariable('Path', `$new, 'User')"
Write-Host ""
Write-Host " Then open a new PowerShell window for the change to take effect."
Write-Host ""
+
+$LocalHome = if ($env:CUA_DRIVER_LOCAL_HOME) { $env:CUA_DRIVER_LOCAL_HOME } else { Join-Path $env:USERPROFILE ".cua-driver-local" }
+$LocalBinDir = if ($env:CUA_DRIVER_LOCAL_INSTALL_DIR) { $env:CUA_DRIVER_LOCAL_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA "Programs\Cua\cua-driver-local\bin" }
+$LocalCli = Join-Path $LocalBinDir "cua-driver-local.exe"
+$LocalMarker = Join-Path $LocalHome "packages\current\cua-driver-local.exe"
+$LocalCommand = Get-Command "cua-driver-local.exe" -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1
+$LocalSurvivor = if (Test-Path -LiteralPath $LocalCli) {
+ $LocalCli
+} elseif (Test-Path -LiteralPath $LocalMarker) {
+ $LocalMarker
+} elseif ($LocalCommand) {
+ $LocalCommand.Source
+} else {
+ $null
+}
+
+if ($LocalSurvivor) {
+ Write-Host "Note: a separate source-built cua-driver-local installation remains at $LocalSurvivor." -ForegroundColor Yellow
+ Write-Host "The cua-driver uninstaller intentionally leaves this local product untouched."
+ Write-Host "To remove it, run from your Cua checkout:"
+ Write-Host ""
+ Write-Host " .\libs\cua-driver\scripts\uninstall-local.ps1"
+ Write-Host ""
+}
diff --git a/libs/cua-driver/scripts/uninstall.sh b/libs/cua-driver/scripts/uninstall.sh
index 09d827444a..606d13bb0c 100755
--- a/libs/cua-driver/scripts/uninstall.sh
+++ b/libs/cua-driver/scripts/uninstall.sh
@@ -109,6 +109,37 @@ fi
# ----------------------------------------------------------------------
log() { printf '==> %s\n' "$*"; }
+report_surviving_local_install() {
+ local local_home="${CUA_DRIVER_LOCAL_HOME:-$HOME/.cua-driver-local}"
+ local local_bin_dir="${CUA_DRIVER_LOCAL_INSTALL_DIR:-$HOME/.local/bin}"
+ local local_cli="$local_bin_dir/cua-driver-local"
+ local local_marker="$local_home/packages/current/cua-driver-local"
+ local path_cli=""
+ local survivor=""
+
+ path_cli="$(command -v cua-driver-local 2>/dev/null || true)"
+ if [[ -e "$local_cli" || -L "$local_cli" ]]; then
+ survivor="$local_cli"
+ elif [[ -e "$local_marker" || -L "$local_marker" ]]; then
+ survivor="$local_marker"
+ elif [[ -n "$path_cli" ]]; then
+ survivor="$path_cli"
+ elif [[ "$OS" == "Darwin" && -x "/Applications/CuaDriverLocal.app/Contents/MacOS/cua-driver-local" ]]; then
+ survivor="/Applications/CuaDriverLocal.app"
+ else
+ return 0
+ fi
+
+ cat <<LOCALUNMSG
+
+Note: a separate source-built cua-driver-local installation remains at $survivor.
+The cua-driver uninstaller intentionally leaves this local product untouched.
+To remove it, run from your Cua checkout:
+
+ ./libs/cua-driver/scripts/uninstall-local.sh
+LOCALUNMSG
+}
+
purge_macos_history() {
local app_bundle="$1"
local helper="$2"
@@ -910,6 +941,7 @@ To delete them too, re-run with --purge:
TELEMETRYUNMSG
fi
fi
+ report_surviving_local_install
exit 0
fi