Skip to content

[Bug]: launchd_restart() fails with bootstrap failed: 5 when plist is missing #31224

@dev-jin

Description

@dev-jin

Bug Description

When running hermes gateway setup to configure a platform (e.g. Telegram) on macOS, the setup wizard offers to restart the gateway to pick up changes. If the gateway was running but the launchd plist was never installed (or was deleted), the restart fails with:

Steps to Reproduce

1. On macOS, ensure the gateway is running (e.g. hermes gateway run in foreground, or installed as a launchd service)
2. Delete the launchd plist: rm ~/Library/LaunchAgents/ai.hermes.gateway.plist
3. Run hermes gateway setup and configure any platform (e.g. Telegram)
4. When prompted "Restart the gateway to pick up changes?", select Yes
5. The restart fails with Bootstrap failed: 5: Input/output error

Alternatively, without the setup wizard:

1. Delete the plist: rm ~/Library/LaunchAgents/ai.hermes.gateway.plist
2. Ensure the gateway is running: hermes gateway status
3. Run: hermes gateway restart
4. Same error occurs

Expected Behavior

launchd_restart() should self-heal a missing plist, the same way launchd_start() already does (line ~2943).

Actual Behavior

⚠ Gateway drain timed out after 180s — forcing launchd restart
Could not find service "ai.hermes.gateway" in domain for user gui: 501
↻ launchd job was unloaded; reloading
Bootstrap failed: 5: Input/output error
✗ Restart failed

Affected Component

Gateway (Telegram/Discord/Slack/WhatsApp)

Messaging Platform (if gateway-related)

Telegram, Discord, Slack, WhatsApp

Debug Report

Report       https://paste.rs/7MMct
  agent.log    https://paste.rs/5Z3bI
  gateway.log  https://paste.rs/Ez4DX

Operating System

macos 15.6.1

Python Version

No response

Hermes Version

No response

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

launchd_restart() in hermes_cli/gateway.py has a fallback path (line ~3054) that handles the case where the launchd job is not loaded. It attempts to launchctl bootstrap the plist, but never checks whether the plist file actually exists on disk first. If the plist is missing, bootstrap fails with error 5 (EIO).

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/cliCLI entry point, hermes_cli/, setup wizardcomp/gatewayGateway runner, session dispatch, deliverytype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions