Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(selfhost): check Docker Compose can load the self-host file before pulling (#11041)

linzch3a8c4d6227cba
diff --git a/scripts/install.ps1 b/scripts/install.ps1
index 85834d77d9..ef7a8c5e88 100644
--- a/scripts/install.ps1
+++ b/scripts/install.ps1
@@ -159,6 +159,52 @@ function Assert-SelfHostPortsAvailable {
}
}
+# Fail early, with a fix the user can act on, when this machine's Docker Compose
+# cannot run the self-host stack. Without this, a missing Compose v2 plugin or a
+# Compose release too old for the file's top-level `name:` only surfaces once
+# `pull` / `up` runs, as a bare "(root) Additional property name is not allowed"
+# (#1401). `config --quiet` validates the file and .env the same way `up` would,
+# without contacting the Docker daemon. Must be called from the installation
+# directory.
+function Assert-ComposeSupportsSelfHost {
+ $previousPreference = $ErrorActionPreference
+ # Native stderr must be captured, not turned into a terminating error.
+ $ErrorActionPreference = "Continue"
+ try {
+ $version = $null
+ try {
+ $version = docker compose version 2>$null
+ } catch {
+ $version = $null
+ }
+ if ($LASTEXITCODE -ne 0 -or -not $version) {
+ Write-Fail "Docker Compose v2 is required, but 'docker compose' is not available.`n The legacy standalone 'docker-compose' (v1) is not supported.`n Install or update Docker Desktop:`n https://docs.docker.com/desktop/install/windows-install/`n Then re-run the installer."
+ }
+ $version = (@($version) | Where-Object { $_ } | Select-Object -First 1)
+
+ $failed = $false
+ $output = @()
+ try {
+ $output = @(docker compose -f docker-compose.selfhost.yml config --quiet 2>&1 | ForEach-Object { "$_" })
+ $failed = ($LASTEXITCODE -ne 0)
+ } catch {
+ $output = @("$_")
+ $failed = $true
+ }
+ if (-not $failed) {
+ return
+ }
+
+ $message = ($output | Where-Object { $_ }) -join "`n "
+ if ($message -match "Additional property") {
+ Write-Fail "Your Docker Compose is too old for Multica's docker-compose.selfhost.yml.`n Found: $version`n Compose said: $message`n Update Docker Desktop to the latest release:`n https://docs.docker.com/desktop/install/windows-install/`n Then re-run the installer."
+ }
+ Write-Fail "Docker Compose could not load $InstallDir\docker-compose.selfhost.yml:`n $message`n Fix the problem above (for example a malformed line in $InstallDir\.env) and re-run the installer."
+ } finally {
+ $ErrorActionPreference = $previousPreference
+ }
+}
+
function Get-LatestVersion {
try {
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/multica-ai/multica/releases/latest" -ErrorAction Stop
@@ -514,6 +560,7 @@ function Install-Server {
Write-Ok "Using existing .env"
}
+ Assert-ComposeSupportsSelfHost
Assert-SelfHostPortsAvailable
Write-Info "Pulling official Multica images..."
diff --git a/scripts/install.ps1.test.ps1 b/scripts/install.ps1.test.ps1
index e0da6408fa..fd00c32b33 100644
--- a/scripts/install.ps1.test.ps1
+++ b/scripts/install.ps1.test.ps1
@@ -201,10 +201,23 @@ function docker {
$args_ = @($args)
if ($args_.Count -ge 1 -and $args_[0] -eq "info") { return }
if ($args_.Count -ge 1 -and $args_[0] -eq "compose") {
+ if ($env:MULTICA_TEST_NO_COMPOSE) {
+ $global:LASTEXITCODE = 1
+ return
+ }
if ($args_ -contains "up") {
$script:StubStackUp = $true
return
}
+ if ($args_ -contains "config" -and $args_ -contains "--quiet") {
+ # The installer's validation step. An old Compose rejects the
+ # file's top-level `name:` here (#1401).
+ if ($env:MULTICA_TEST_COMPOSE_REJECTS_NAME) {
+ $global:LASTEXITCODE = 1
+ return "(root) Additional property name is not allowed"
+ }
+ return
+ }
if ($args_ -contains "config") {
# Opt-in, so the port matrix never probes real host ports.
if (-not $env:MULTICA_TEST_COMPOSE_CONFIG) {
@@ -231,7 +244,10 @@ function docker {
$global:LASTEXITCODE = 1
return
}
- if ($args_ -contains "version") { return "2.30.0" }
+ if ($args_ -contains "version") {
+ if ($env:MULTICA_TEST_COMPOSE_REJECTS_NAME) { return "Docker Compose version v2.2.3" }
+ return "2.30.0"
+ }
}
return
}
@@ -291,7 +307,7 @@ function Invoke-InstallerCase {
# Control the ambient environment explicitly so a CI runner's own PORT
# cannot leak into the matrix. Absent must mean absent: an empty string is a
# different input, and the chain treats it as "set but no value".
- $caseVars = @("PORT", "BACKEND_PORT", "API_PORT", "SERVER_PORT", "FRONTEND_PORT", "MULTICA_TEST_COMPOSE_CONFIG", "MULTICA_TEST_STACK_RUNNING")
+ $caseVars = @("PORT", "BACKEND_PORT", "API_PORT", "SERVER_PORT", "FRONTEND_PORT", "MULTICA_TEST_COMPOSE_CONFIG", "MULTICA_TEST_STACK_RUNNING", "MULTICA_TEST_COMPOSE_REJECTS_NAME", "MULTICA_TEST_NO_COMPOSE")
$previous = @{}
foreach ($key in $caseVars) {
$previous[$key] = [System.Environment]::GetEnvironmentVariable($key)
@@ -396,5 +412,35 @@ $probe.Stop()
$freeCase = @{ Label = "free port"; Env = @{ MULTICA_TEST_COMPOSE_CONFIG = "1" }; Mutation = @{ PORT = $free }; Backend = $free; Frontend = "3000" }
Assert-PublishedPorts -Case $freeCase -Result (Invoke-InstallerCase -Case $freeCase)
+# ---------------------------------------------------------------------------
+# 5. A Compose release too old for the file's top-level `name:` (or no Compose
+# v2 plugin at all) stops the installer before anything is pulled or
+# started, with an error that says what to upgrade (#1401).
+# ---------------------------------------------------------------------------
+$composeCases = @(
+ @{ Label = "old compose"; Env = @{ MULTICA_TEST_COMPOSE_REJECTS_NAME = "1" }; Mutation = $null; Expect = @("Your Docker Compose is too old", "Found: Docker Compose version v2.2.3", "Additional property name is not allowed") }
+ @{ Label = "no compose v2"; Env = @{ MULTICA_TEST_NO_COMPOSE = "1" }; Mutation = $null; Expect = @("Docker Compose v2 is required") }
+)
+foreach ($case in $composeCases) {
+ $result = Invoke-InstallerCase -Case $case
+ if ($result.ExitCode -eq 0) {
+ Write-Host $result.Output
+ Fail-Test "[$($case.Label)] installer must not continue with an unusable Docker Compose"
+ }
+ foreach ($text in $case.Expect) {
+ if ($result.Output -notmatch [regex]::Escape($text)) {
+ Write-Host $result.Output
+ Fail-Test "[$($case.Label)] expected the error to contain: $text"
+ }
+ }
+ if ($result.Probes.Count -gt 0 -or $result.Output -match "Pulling official Multica images") {
+ Write-Host $result.Output
+ Fail-Test "[$($case.Label)] installer pulled or started the stack despite an unusable Docker Compose"
+ }
+}
+
Remove-Item $runnerScript -Force -ErrorAction SilentlyContinue
Write-Host "install.ps1 tests passed" -ForegroundColor Green
+# The expected-failure cases leave the last child's exit code in $LASTEXITCODE,
+# which `powershell -command` would report as the script's own result.
+exit 0
diff --git a/scripts/install.sh b/scripts/install.sh
index 6716afc89a..664b392c70 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -120,6 +120,45 @@ host_port_in_use() {
(exec 3<>"/dev/tcp/127.0.0.1/$1") 2>/dev/null
}
+# Fail early, with a fix the user can act on, when this machine's Docker Compose
+# cannot run the self-host stack. Without this, a missing Compose v2 plugin or a
+# Compose release too old for the file's top-level `name:` only surfaces once
+# `pull` / `up` runs, as a bare "(root) Additional property name is not allowed"
+# (#1401). `config --quiet` validates the file and .env the same way `up` would,
+# without contacting the Docker daemon. Must be called from the installation
+# directory.
+check_compose_supports_selfhost() {
+ local version output
+
+ if ! version="$(docker compose version 2>/dev/null)"; then
+ fail "Docker Compose v2 is required, but 'docker compose' is not available.
+ The legacy standalone 'docker-compose' (v1) is not supported.
+ Install or update Docker Desktop, or on Linux the docker-compose-plugin package:
+ https://docs.docker.com/compose/install/
+ Then re-run the installer."
+ fi
+
+ if output="$(docker compose -f docker-compose.selfhost.yml config --quiet 2>&1)"; then
+ return
+ fi
+
+ case "$output" in
+ *"Additional property"*)
+ fail "Your Docker Compose is too old for Multica's docker-compose.selfhost.yml.
+ Found: ${version}
+ Compose said: ${output}
+ Update Docker Desktop, or on Linux the docker-compose-plugin package, to the latest release:
+ https://docs.docker.com/compose/install/
+ Then re-run the installer."
+ ;;
+ *)
+ fail "Docker Compose could not load $INSTALL_DIR/docker-compose.selfhost.yml:
+ ${output}
+ Fix the problem above (for example a malformed line in $INSTALL_DIR/.env) and re-run the installer."
+ ;;
+ esac
+}
+
# Fail before pulling and starting anything when a host port the stack needs is
# already taken, instead of letting Docker abort halfway through `up -d` with
# "port is already allocated" (#883). A port this installation's own running
@@ -466,6 +505,7 @@ setup_server() {
ok "Using existing .env"
fi
+ check_compose_supports_selfhost
check_selfhost_ports
# Start Docker Compose
diff --git a/scripts/install.test.sh b/scripts/install.test.sh
index 5397a3e60d..877df692b5 100644
--- a/scripts/install.test.sh
+++ b/scripts/install.test.sh
@@ -320,6 +320,10 @@ case "${1:-}" in
info) exit 0 ;;
compose)
shift
+ if [ -n "${MULTICA_TEST_NO_COMPOSE:-}" ]; then
+ echo "docker: 'compose' is not a docker command." >&2
+ exit 1
+ fi
subcommand=""
for arg in "$@"; do
case "$arg" in
@@ -329,6 +333,17 @@ case "${1:-}" in
case "$subcommand" in
up) : >.stub-stack-up ;;
config)
+ # `config --quiet` is the installer's validation step. An old Compose
+ # rejects the file's top-level `name:` here (#1401).
+ for arg in "$@"; do
+ if [ "$arg" = "--quiet" ]; then
+ if [ -n "${MULTICA_TEST_COMPOSE_REJECTS_NAME:-}" ]; then
+ echo "(root) Additional property name is not allowed" >&2
+ exit 1
+ fi
+ exit 0
+ fi
+ done
# Opt-in, so the port matrix above never probes real host ports.
[ -n "${MULTICA_TEST_COMPOSE_CONFIG:-}" ] || exit 1
cat <<JSON
@@ -378,7 +393,13 @@ JSON
*) exit 1 ;;
esac
;;
- version) echo "2.30.0" ;;
+ version)
+ if [ -n "${MULTICA_TEST_COMPOSE_REJECTS_NAME:-}" ]; then
+ echo "Docker Compose version v2.2.3"
+ else
+ echo "2.30.0"
+ fi
+ ;;
esac
exit 0
;;
@@ -763,6 +784,55 @@ test_with_server_port_preflight_allows_free_and_own_ports() {
_require_server_ports "$tmp" "own running stack" "$held" "3000" || return 1
}
+# A Compose release too old for the file's top-level `name:` (or no Compose v2
+# plugin at all) must stop the installer before anything is pulled or started,
+# with an error that says what to upgrade, instead of Compose's bare
+# "(root) Additional property name is not allowed" from `up` (#1401).
+_require_compose_preflight_failure() {
+ local tmp="$1" label="$2" expected="$3"
+
+ if grep -q "Pulling official Multica images" "$tmp/install.out" || [ -f "$tmp/server/.stub-stack-up" ]; then
+ echo "[$label] installer pulled or started the stack despite an unusable Docker Compose" >&2
+ cat "$tmp/install.out" >&2 || true
+ return 1
+ fi
+ if ! grep -qF "$expected" "$tmp/install.err"; then
+ echo "[$label] expected the error to contain: $expected" >&2
+ cat "$tmp/install.err" >&2 || true
+ return 1
+ fi
+}
+
+test_with_server_stops_on_compose_too_old_for_name() {
+ local tmp
+ tmp="$(mktemp -d)"
+ trap 'rm -rf "$tmp"' RETURN
+
+ _setup_server_sandbox "$tmp"
+ cp "$tmp/server/.env.example" "$tmp/server/.env"
+ if _run_with_server "$tmp" MULTICA_TEST_COMPOSE_REJECTS_NAME=1 >/dev/null 2>&1; then
+ echo "installer must fail when Docker Compose rejects the self-host compose file" >&2
+ return 1
+ fi
+ _require_compose_preflight_failure "$tmp" "old compose" "Your Docker Compose is too old" || return 1
+ _require_compose_preflight_failure "$tmp" "old compose" "Found: Docker Compose version v2.2.3" || return 1
+ _require_compose_preflight_failure "$tmp" "old compose" "Additional property name is not allowed" || return 1
+}
+
+test_with_server_stops_without_compose_v2() {
+ local tmp
+ tmp="$(mktemp -d)"
+ trap 'rm -rf "$tmp"' RETURN
+
+ _setup_server_sandbox "$tmp"
+ cp "$tmp/server/.env.example" "$tmp/server/.env"
+ if _run_with_server "$tmp" MULTICA_TEST_NO_COMPOSE=1 >/dev/null 2>&1; then
+ echo "installer must fail when 'docker compose' is not available" >&2
+ return 1
+ fi
+ _require_compose_preflight_failure "$tmp" "no compose v2" "Docker Compose v2 is required" || return 1
+}
+
test_brew_install_failure_falls_back_to_release_binary
test_brew_tap_failure_falls_back_to_release_binary
test_remote_ssh_install_prints_token_login_hint
@@ -771,6 +841,8 @@ test_with_server_uses_compose_published_ports
test_with_server_fails_when_compose_port_is_unavailable
test_with_server_refuses_ports_already_in_use
test_with_server_port_preflight_allows_free_and_own_ports
+test_with_server_stops_on_compose_too_old_for_name
+test_with_server_stops_without_compose_v2
test_with_server_fails_when_checkout_does_not_land
test_cli_lookup_failure_does_not_claim_up_to_date
echo "install.sh tests passed"