Skip to content

[Bug]: Service fails to auto-start after ocx update due to legacy launchctl unload and strict launchctlLoadFailed check #4141

Description

@jaychou0642-create

Client or integration

Codex CLI

Area

Service lifecycle

Summary

After updating OpenCodex (e.g. ocx update to v2.48.0 and v2.49.0) on macOS, the background service fails to automatically restart, leaving the proxy inactive. The operator has to manually run ocx start each time.

Root cause analysis:

  1. Legacy launchctl unload <plist> in src/service.ts:installLaunchd() fails to unregister the service from the modern macOS gui/<uid> domain.
  2. Subsequent launchctl load -w <plist> emits Load failed: 5: Input/output error to stderr because the job is still bootstrapped.
  3. The strict launchctlLoadFailed check (/\b(?:Load|Bootstrap) failed\b/i.test(stderr)) catches this stderr output and throws an uncaught error, aborting ocx service repair with exit code 1.
  4. The update fallback startProxyDirectly() fails to bind or exits due to the existing process/lock.
  5. In addition, statusLaunchd() uses un-scoped launchctl list | grep ${LABEL}, which returns empty in modern macOS subshells, leading ocx status to falsely report installed, not loaded (launchd).

Reproduction

  1. On macOS, install and register the background service: ocx service install.
  2. Run ocx update (or upgrade from v2.48.0 to v2.49.0).
  3. Notice:
    opencodex: service refresh failed — starting the proxy directly instead.
      Run 'ocx service repair' to see why the background service could not restart.
    
  4. Check proxy status or try to connect: no proxy is listening.
  5. Running ocx service repair manually fails with:
    launchctl could not load /Users/.../Library/LaunchAgents/com.opencodex.proxy.plist: Load failed: 5: Input/output error
    A previous job may still be bootstrapped. Try:
      launchctl bootout gui/501/com.opencodex.proxy
    then re-run 'ocx service repair'.
    

Version

2.49.0

Operating system

macOS 15.5

Provider and model

Not provider-specific

Logs or error output

launchctl could not load /Users/.../Library/LaunchAgents/com.opencodex.proxy.plist: Load failed: 5: Input/output error
A previous job may still be bootstrapped. Try:
  launchctl bootout gui/501/com.opencodex.proxy
then re-run 'ocx service repair'.

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcliCLI, config inject, packaging flagsplatformOS/service/tray/ACL (Windows-heavy, not Windows-only)serviceService lifecycle (WinSW/launchd/scheduler)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions