jcrabapple/hermes-skills/systemd-service-crash-loop-fix

Claude Code and agent skill by jcrabapple/hermes-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Diagnose and fix systemd user service crash loops where the service binary can't find its runtime (node, python, etc.) because systemd doesn't inherit the user's shell environment (nvm, pyenv, volta, brew). Use when a service shows status 127 or "No such file or directory" from env, or when journalctl shows repeated restarts every ~5-10s.

Install

npx vskill@latest install jcrabapple/hermes-skills/systemd-service-crash-loop-fix

SKILL.md

The same SKILL.md was published earlier as jcrabapple/hermes-skills/systemd-service-crash-loop-fix.

Fix Systemd User Service Crash Loops from Missing Runtime PATH

Diagnosis

1. Check service status and restart counter
bash
systemctl --user status <service>.service

Look for:

  • Result: exit-code with status 127 (command not found)
  • High restart counter (thousands = crash looping for hours/days)
  • activating (auto-restart) state
2. Check journal logs for the root cause
bash
journalctl --user -u <service>.service --since "1 hour ago" --no-pager | tail -20

Common errors:

  • env: 'node': No such file or directory — nvm-installed node not in PATH
  • env: 'python3': No such file or directory — pyenv-installed python not in PATH
  • No such file or directory on a script that exists — shebang interpreter missing from PATH
3. Verify the runtime exists but isn't in systemd's PATH
bash
# Check where the runtime actually is
which node python3 # from your shell (works)
# Check what PATH systemd sees
cat ~.config/systemd/user/<service>.service | grep -i path
# Confirm the binary exists
ls -la ~.nvm/versions/node/*/bin/node
ls -la ~.pyenv/shims/python3
ls -la /home/linuxbrew/.linuxbrew/bin/*

Fix

Add explicit PATH to the service file

Edit the service file and add an Environment="PATH=..." line in the [Service] section:

bash
cat > ~/.config/systemd/user/<service>.service << 'EOF'
[Unit]
Description=<description>
After=network.target
[Service]
Type=simple
WorkingDirectory=<app-dir>
Environment="PATH=~.nvm/versions/node/v22.21.1/bin:/usr/local/bin:/usr/bin:/bin"
ExecStart=<full-path-to-binary> <args>
Restart=on-failure
RestartSec=10
[Install]
WantedBy=default.target
EOF

Then reload and restart:

bash
systemctl --user daemon-reload
systemctl --user restart <service>.service
systemctl --user status <service>.service
Common PATH values by runtime manager
ManagerRuntimePATH entry
nvmnode~.nvm/versions/node/vXX.XX.X/bin
pyenvpython~.pyenv/shims:~.pyenv/bin
voltanode/npm~.volta/bin
linuxbrewany/home/linuxbrew/.linuxbrew/bin

Pitfalls

  • Restart counter in tens of thousands: A service restarting every 10s for 24+ hours accumulates 8,000+ restarts. Fix immediately — it wastes resources and clutters logs.
  • Don't just disable the service: If the user wants it running, fix the PATH. Only disable if the service is genuinely unused.
  • `serve` and other npx-installed tools: Tools installed via npm install -g or bunx use #!/usr/bin/env node shebangs. They break under systemd for the same reason — node isn't in PATH.
  • RestartSec=10 is aggressive: For services that legitimately crash-loop during startup (e.g., waiting for a dependency), consider increasing to 30-60s or adding a ExecStartPre health check.
  • Hardcoded node version: If the service file references a specific nvm node version (e.g., v22.21.1), it will break when node is upgraded. Consider using a symlink or volta instead.

Verification

bash
# Should show "active (running)"
systemctl --user is-active <service>.service
# Check logs for clean startup
journalctl --user -u <service>.service --since "1 min ago" --no-pager
# Verify the service is actually listening
curl -s http://localhost:<port> | head -5

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/jcrabapple/hermes-skills/systemd-service-crash-loop-fix/badge)](https://verified-skill.com/skills/jcrabapple/hermes-skills/systemd-service-crash-loop-fix)

Something wrong with this skill or its page? Tell us.