#2862: fix: set WorkingDirectory in systemd service for control UI assets
gateway
Cluster:
Cross-Platform Fixes
## Summary
- Fixes control UI failing with "Control UI assets not found" when gateway runs via systemd
- The systemd service was generated without WorkingDirectory, causing cwd to be user's home directory
- Now derives workingDirectory from the CLI entrypoint path for all production runtimes
## Test plan
- [x] Run `moltbot gateway install` and verify service file contains `WorkingDirectory`
- [x] Restart gateway and verify control UI loads at `http://127.0.0.1:18789/`
- [x] Run `moltbot doctor --repair` and verify WorkingDirectory persists
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates gateway service argument resolution to also compute a `workingDirectory` for production runtimes (node/bun/auto) by deriving it from the built CLI entrypoint path under `dist/`. That working directory then propagates into systemd unit generation so the gateway runs with a predictable CWD and can find Control UI assets (which otherwise may fall back to `process.cwd()`).
<h3>Confidence Score: 4/5</h3>
- This PR is generally safe to merge; it adds a straightforward working-directory derivation for service generation.
- Change scope is small and localized to service argument construction; behavior is additive and gated to production/runtime service paths. Main residual concern is edge-case path parsing when `dist` appears multiple times in the entrypoint path, which could mis-derive the directory in uncommonLine layouts.
- src/daemon/program-args.ts
<!-- greptile_other_comments_section -->
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#5496: Fix: Windows path separators stripped in Gateway scheduled task
by giuliozelante · 2026-01-31
77.6%
#16016: fix: update systemd unit version on gateway restart
by jbold · 2026-02-14
75.6%
#15345: fix(daemon): doctor --fix pollutes service PATH with dirs that don'...
by yinghaosang · 2026-02-13
75.5%
#23584: fix(daemon): improve gateway service detection to avoid false posit...
by mohandshamada · 2026-02-22
74.6%
#18498: daemon: load systemd EnvironmentFile and drop-ins so gateway status...
by saurav470 · 2026-02-16
74.1%
#6352: fix(ux): update gateway token error message UI location
by Glucksberg · 2026-02-01
73.4%
#15981: fix: include --profile in systemd service ExecStart
by MisterGuy420 · 2026-02-14
73.3%
#6638: fix: make Dockerfile work on container platforms (Render, Railway, ...
by kaizen403 · 2026-02-01
73.3%
#13084: fix(daemon): multi-layer defense against zombie gateway processes
by openperf · 2026-02-10
72.9%
#4695: Fixed the default CLI image to use published GHCR image
by TASMAYU · 2026-01-30
72.7%