From a262d8fc6a5abf133cf196b4874b033a414c24ef Mon Sep 17 00:00:00 2001 From: Spencer Heywood <18178614+heywoodlh@users.noreply.github.com> Date: Thu, 19 Jun 2025 01:12:57 -0600 Subject: [PATCH] provide suggestion if xpc 'Connection invalid' error encountered (#179) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes https://github.com/apple/container/issues/80 Adds the following help message if you try to run `container` against a host that hasn't started the container system: ``` ❯ /usr/local/bin/container list Error: internalError: "failed to list containers" (cause: "interrupted: "Connection invalid: ensure container system has been started with `container system start`"") ❯ /usr/local/bin/container run -it --rm docker.io/alpine Error: interrupted: "Connection invalid: ensure container system has been started with `container system start`" ``` --- README.md | 6 ++++++ Sources/CLI/Application.swift | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 56c3da31..179b9b32 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,12 @@ Download the latest signed installer package for `container` from the [GitHub re To install the tool, double click the package file and follow the instructions. Enter your administrator password when prompted, to give the installer permission to place the installed files under `/usr/local`. +Start the system service with: + +``` +container system start +``` + ### Uninstall Use the `uninstall-container.sh` script to remove `container` from your system. To remove your user data along with the tool, run: diff --git a/Sources/CLI/Application.swift b/Sources/CLI/Application.swift index ea3e7a94..cd7c22fb 100644 --- a/Sources/CLI/Application.swift +++ b/Sources/CLI/Application.swift @@ -21,6 +21,7 @@ import CVersion import ContainerClient import ContainerLog import ContainerPlugin +import ContainerizationError import ContainerizationOS import Foundation import Logging @@ -176,7 +177,13 @@ struct Application: AsyncParsableCommand { Self.printModifiedHelpText() return } - Application.exit(withError: error) + let errorAsString: String = String(describing: error) + if errorAsString.contains("XPC connection error") { + let modifiedError = ContainerizationError(.interrupted, message: "\(error)\nEnsure container system service has been started with `container system start`.") + Application.exit(withError: modifiedError) + } else { + Application.exit(withError: error) + } } }