Skip to content

fix(gateway): avoid systemctl crashes in Linux environments without systemd - #7437

Closed
dlkakbs wants to merge 1 commit into
NousResearch:mainfrom
dlkakbs:fix/gateway-no-systemctl
Closed

fix(gateway): avoid systemctl crashes in Linux environments without systemd#7437
dlkakbs wants to merge 1 commit into
NousResearch:mainfrom
dlkakbs:fix/gateway-no-systemctl

Conversation

@dlkakbs

@dlkakbs dlkakbs commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Summary

#7420

Fix gateway setup on Linux environments where systemctl is unavailable, such as Docker containers without systemd.

Previously, Hermes treated any non-Termux Linux environment as systemd-capable. During hermes setup, that led to direct systemctl calls in gateway service checks, which crashed with:

FileNotFoundError: [Errno 2] No such file or directory: 'systemctl'

What changed

  • tightened supports_systemd_services() so it only returns true when:
    • the platform is Linux
    • the environment is not Termux
    • systemctl is actually available on PATH
  • updated _is_service_running() to safely handle missing systemctl
  • updated setup_gateway() to only offer systemd service flows when systemd is actually supported
  • preserved the existing fallback path so unsupported environments show manual gateway startup guidance instead of crashing

Why

Some Linux environments, especially Docker images, do not include systemctl or run without systemd as PID 1.

Hermes was previously using a Linux-only check as a proxy for systemd availability, which caused setup to attempt service-manager operations that the environment could not support.

Result

In Linux environments without systemctl:

  • hermes setup no longer crashes
  • Hermes no longer assumes systemd support
  • the wizard falls back to manual gateway instructions such as hermes gateway

Tests

Added regression coverage for:

  • Linux environments without a systemctl binary
  • _is_service_running() when systemctl is missing
  • setup_gateway() fallback behavior when messaging is configured but no service manager is available

Verified locally with:

  • python3 -m pytest tests/hermes_cli/test_gateway_service.py -q
  • python3 -m pytest tests/hermes_cli/test_setup.py -q

@dlkakbs
dlkakbs force-pushed the fix/gateway-no-systemctl branch from 63043fa to ff3e438 Compare April 10, 2026 23:09
@teknium1

Copy link
Copy Markdown
Contributor

Closing as duplicate — this issue is fixed in #8614 (salvaged from @alt-glitch's comprehensive #8573). Thanks for the contribution!

@teknium1 teknium1 closed this Apr 12, 2026
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.

2 participants