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(install): set up the Linux VM runtime before installing Cua Spaces (#5371)

injaneityb42cad3b24e4
diff --git a/.github/workflows/ci-installers.yml b/.github/workflows/ci-installers.yml
index dba9d0540e..188a69d6f5 100644
--- a/.github/workflows/ci-installers.yml
+++ b/.github/workflows/ci-installers.yml
@@ -82,6 +82,9 @@ jobs:
--merge /tmp/cli.json --out /rel/cua-install-latest/release-artifacts.json
(cd /rel && python3 -m http.server 8765 >/dev/null 2>&1 &)
sleep 1
+ mkdir -p /qemu-stubs
+ for t in qemu-img "qemu-system-$(uname -m)"; do printf "#!/bin/sh\nexit 0\n" > "/qemu-stubs/$t" && chmod +x "/qemu-stubs/$t"; done
+ export PATH="/qemu-stubs:$PATH"
CUA_INSTALL_BASE_URL=http://127.0.0.1:8765 sh /w/install.sh --yes --no-onboarding --mode client
/usr/local/bin/cua --version
# Linux installs the Spaces AppImage next to the CLI.
diff --git a/scripts/install/install.sh b/scripts/install/install.sh
index 925ef4275d..b1d9f654a4 100755
--- a/scripts/install/install.sh
+++ b/scripts/install/install.sh
@@ -865,6 +865,37 @@ EOF
info "installed $target"
}
+runtime_ready() {
+ [ -n "${DOCKER_HOST:-}" ] || { has docker && docker info >/dev/null 2>&1; } ||
+ { has "qemu-system-$(uname -m)" && has qemu-img; }
+}
+
+qemu_install_command() {
+ if has dnf; then
+ printf 'sudo dnf install -y qemu-kvm qemu-img\n'
+ elif [ "$arch" = arm64 ]; then
+ printf 'sudo apt-get install -y qemu-system-arm qemu-utils\n'
+ else
+ printf 'sudo apt-get install -y qemu-system-x86 qemu-utils\n'
+ fi
+}
+
+linux_runtime() {
+ if runtime_ready; then
+ info "VM runtime ok"
+ return
+ fi
+ if [ "$dry_run" = 1 ]; then
+ say "[dry-run] $cua_bin runtime setup qemu"
+ return
+ fi
+ if confirm "Cua Spaces on Linux needs QEMU; install it now ($cua_bin runtime setup qemu)?" y &&
+ "$cua_bin" runtime setup qemu </dev/null && runtime_ready; then
+ return
+ fi
+ die "Cua Spaces on Linux needs QEMU or Docker; install QEMU with: $(qemu_install_command) (or install Docker), then rerun the installer"
+}
+
write_mode() {
[ -n "$mode" ] || return 0
home="${CUA_HOME:-$HOME/.cua}"
@@ -1054,6 +1085,9 @@ main() {
if [ "$want_cli" = 1 ]; then
install_cli
fi
+ if [ "$os" = linux ] && [ "$sel_spaces" = 1 ] && { [ "$dry_run" = 1 ] || has "$cua_bin"; }; then
+ linux_runtime
+ fi
if [ "$sel_spaces" = 1 ]; then
case "$os" in
darwin) install_app_darwin ;;
diff --git a/scripts/install/tests/run.sh b/scripts/install/tests/run.sh
index 66eda57e3f..df25802dc9 100755
--- a/scripts/install/tests/run.sh
+++ b/scripts/install/tests/run.sh
@@ -60,6 +60,12 @@ if [ "\${1:-} \${2:-} \${3:-}" = "host setup --help" ]; then
exit 0
fi
echo "\$*" >>"\${CUA_FAKE_LOG:-/dev/null}"
+if [ "\$*" = "runtime setup qemu" ]; then
+ [ -z "\${CUA_FAKE_QEMU_DIR:-}" ] || for t in qemu-img qemu-system-\$(uname -m); do
+ printf '#!/bin/sh\n' >"\$CUA_FAKE_QEMU_DIR/\$t" && chmod +x "\$CUA_FAKE_QEMU_DIR/\$t"
+ done
+ exit "\${CUA_FAKE_RUNTIME_STATUS:-0}"
+fi
EOF
chmod +x "$1/cua"
}
@@ -128,6 +134,16 @@ chmod +x "$bin/cua-driver"
EOF
driver_url="$base/driver/install.sh"
+mkdir -p "$work/qemu" "$work/host-bin"
+for f in $(printf '%s' "$PATH" | tr ':' '\n' | sed 's#$#/*#'); do
+ case "${f##*/}" in qemu* | docker) continue ;; esac
+ [ -x "$f" ] && [ ! -e "$work/host-bin/${f##*/}" ] && ln -s "$f" "$work/host-bin/${f##*/}"
+done
+host_path="$work/host-bin"
+for t in qemu-img "qemu-system-$(uname -m)"; do printf '#!/bin/sh\n' >"$work/qemu/$t"; done
+chmod +x "$work/qemu"/*
+PATH="$work/qemu:$PATH"
+
# ------------------------------------------------------------ harness
# inst [ENV=VAL ...] -- ARGS: run install.sh with a fresh fake HOME.
@@ -168,6 +184,18 @@ check "non-interactive: prints next steps, no login" sh -c "grep -q 'cua auth lo
check "prefix bin not on PATH: prints a hint" has_out "is not on your PATH"
check "no --modify-path: profile untouched" absent "$home/.profile"
+check "VM runtime present: no runtime setup" sh -c "grep -q 'VM runtime ok' '$work/out' && ! grep -q 'runtime setup' '$home/cua.log' 2>/dev/null"
+
+mkdir -p "$work/qemu-r1"
+inst PATH="$work/qemu-r1:$host_path" CUA_FAKE_QEMU_DIR="$work/qemu-r1" -- --yes --no-onboarding --prefix "$work/r1"
+check "VM runtime missing, setup succeeds: installs the app" sh -c "[ $status = 0 ] && grep -qx 'runtime setup qemu' '$home/cua.log' && [ -x '$work/r1/bin/cua-spaces' ]"
+inst PATH="$host_path" CUA_FAKE_RUNTIME_STATUS=1 -- --yes --no-onboarding --prefix "$work/r2"
+check "VM runtime setup fails: exits with the fix before the app download" sh -c "[ $status != 0 ] && grep -q 'needs QEMU or Docker; install QEMU with: sudo .* install -y qemu' '$work/out' && ! grep -q 'cua-spaces-$version' '$work/out' && [ ! -e '$work/r2/bin/cua-spaces' ]"
+inst PATH="$host_path" -- --yes --no-onboarding --prefix "$work/r3"
+check "VM runtime setup leaves QEMU missing: exits with the fix" sh -c "[ $status != 0 ] && grep -q 'needs QEMU or Docker' '$work/out' && [ ! -e '$work/r3/bin/cua-spaces' ]"
+inst PATH="$host_path" -- --dry-run --no-onboarding --prefix "$work/r4"
+check "VM runtime missing, --dry-run: prints the setup only" sh -c "[ $status = 0 ] && grep -q 'dry-run. $work/r4/bin/cua runtime setup qemu' '$work/out' && [ ! -e '$work/r4' ] && [ ! -e '$home/cua.log' ]"
+
# ------------------------------------------------------------ selection
# Cua Spaces ships for macOS and Linux; the manifest also lists Windows.