Skip to content

[Bug]: hermes status crashes on Linux runtimes lacking systemctl #3724

@yepyhun

Description

@yepyhun

Bug Description

When running the hermes status command on Linux environments where systemd (specifically the systemctl binary) is not installed or available in the PATH (e.g., minimal Linux distributions, certain WSL distributions, CatchyOS custom configs, or Docker containers), the CLI crashes with a FileNotFoundError.

The current implementation in hermes_cli/status.py blindly assumes that if sys.platform.startswith('linux') evaluates to True, systemctl is available for subprocess.run.

Steps to Reproduce

Run hermes status on a Linux system without systemd/systemctl installed.
The agent attempts to spawn systemctl --user is-active .
An unhandled FileNotFoundError halts the CLI execution.

Expected Behavior

The CLI should check if systemctl exists in the system path. If it does not, it should gracefully fall back, indicating that the service manager is unavailable, and continue displaying the rest of the status output without crashing.

Actual Behavior

It doesn't check just freeze.

Affected Component

Other

Messaging Platform (if gateway-related)

No response

Operating System

linux cathyos

Python Version

3.11.9 dunno

Hermes Version

latest

Relevant Logs / Traceback

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

Use shutil.which("systemctl") to verify the presence of the executable before spawning the subprocess.

Here is the modified logic for hermes_cli/status.py that fixes the issue:

import sys
import shutil
import subprocess

... (inside the show_status function) ...

if sys.platform.startswith('linux'):
    systemctl_path = shutil.which("systemctl")
    if systemctl_path:
        try:
            from hermes_cli.gateway import get_service_name
            _gw_svc = get_service_name()
        except Exception:
            _gw_svc = "hermes-gateway"
        
        result = subprocess.run(
            [systemctl_path, "--user", "is-active", _gw_svc],
            capture_output=True,
            text=True
        )
        is_active = result.stdout.strip() == "active"
        print(f"  Status:       {check_mark(is_active)} {'running' if is_active else 'stopped'}")
        print("  Manager:      systemd (user)")
    else:
        print(f"  Status:       {color('N/A', Colors.DIM)}")
        print("  Manager:      systemd unavailable in this runtime")

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

    type/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