Skip to content

Fix launchctl bootstrap failures being discarded as XPC errors - #2045

Draft
rogerneal wants to merge 1 commit into
apple:mainfrom
rogerneal:fix/2008-launchctl-bootstrap-errors
Draft

Fix launchctl bootstrap failures being discarded as XPC errors#2045
rogerneal wants to merge 1 commit into
apple:mainfrom
rogerneal:fix/2008-launchctl-bootstrap-errors

Conversation

@rogerneal

@rogerneal rogerneal commented Jul 30, 2026

Copy link
Copy Markdown

Summary

  • Surface launchctl bootstrap exit status and stderr from ServiceManager.register instead of continuing into a misleading apiserver XPC error.
  • When running as root (euid == 0) outside an Aqua session, bootstrap into the system domain instead of user/0 or gui/0.
  • Keep container system start idempotent when the service is already registered.
  • Add unit tests for domain selection and a real launchctl failure path for error surfacing.

Fixes #2008

Test plan

Tested

  • swift test --filter ServiceManagerTests (domain selection cases)
  • Real launchctl failure via ServiceManager.register with a missing plist; error includes launchctl bootstrap and status
  • Local Aqua bin/container system start --app-root ...: register() loaded com.apple.container.apiserver into gui/<uid> and the process started

Not tested

  • Exact GitHub Actions macos-26 reproduction: sudo container system start in a Background / non-login session
  • End-to-end healthy XPC ping / container system status after start in that CI environment
  • Passwordless/sudo launchctl bootstrap system on this developer machine (not available in the local session used for this PR)

Suggested CI verification

On a macos-26 runner:

  1. Install or build this branch
  2. Run sudo container system start --enable-kernel-install
  3. Confirm start succeeds without XPC connection error: Connection invalid
  4. Run container system status (or another command that talks to the apiserver)

Surface launchctl stderr from ServiceManager.register, and bootstrap into
the system domain when running as root outside an Aqua session.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: container system start discards launchctl bootstrap failures, yielding a misleading XPC error in non-login (CI) sessions

1 participant