OpenClaw bug report: gateway install inlines .env secrets into systemd unit while doctor flags inline OPENCLAW_GATEWAY_TOKEN as stale
Summary
On Linux/systemd user installs, openclaw gateway install in OpenClaw 2026.3.23-2 writes secrets from ~/.openclaw/.env directly into ~/.config/systemd/user/openclaw-gateway.service as inline Environment=... lines.
In the same build, openclaw doctor / service audit flags an inline OPENCLAW_GATEWAY_TOKEN as stale/non-standard and recommends:
openclaw gateway install --force
That appears internally inconsistent, because reinstall uses the same installer path that serializes the service environment into the unit.
Environment
- OpenClaw version:
2026.3.23-2
- Installed from npm package
[email protected]
- OS: Linux
- Supervisor: systemd user service
- Date observed: 2026-03-25
Symptoms
openclaw doctor / status reported:
Service config looks out of date or non-standard.
Service config issue: Gateway service embeds OPENCLAW_GATEWAY_TOKEN and should be reinstalled.
Run openclaw gateway install --force to remove embedded service token.
Actual installed unit contained:
Environment=OPENCLAW_GATEWAY_TOKEN=...
- many other inline secret
Environment= lines sourced from ~/.openclaw/.env
At the same time, a drop-in also existed:
~/.config/systemd/user/openclaw-gateway.service.d/env.conf
- containing
EnvironmentFile=%h/.openclaw/.env
So the live setup had both:
- inline secrets in the main unit
- an
EnvironmentFile drop-in
Repro
- Put gateway token and provider API keys in
~/.openclaw/.env
- Configure gateway auth to use
${OPENCLAW_GATEWAY_TOKEN} in openclaw.json
- Run:
- Inspect:
systemctl --user cat openclaw-gateway.service
- Observe inline
Environment=OPENCLAW_GATEWAY_TOKEN=... in the main unit
- Run:
openclaw doctor --non-interactive
- Observe doctor warns that embedded
OPENCLAW_GATEWAY_TOKEN should be removed via reinstall
Expected behavior
One of these should be true:
- The installer should prefer
EnvironmentFile=%h/.openclaw/.env and avoid serializing secrets into the main systemd unit.
- Or doctor should not recommend reinstall as a fix if reinstall will reproduce the same inline-token layout.
Actual behavior
- Installer path persists
.env values into the main unit as inline Environment=...
- Audit path treats inline
OPENCLAW_GATEWAY_TOKEN as stale/non-standard and recommends reinstall
- Result: reinstall advice appears to point back to the same behavior
Relevant code paths in 2026.3.23-2
Installer side:
dist/gateway-install-token-De_pFluK.js
buildGatewayInstallPlan(...)
dist/io-y3Az_Onx.js
collectDurableServiceEnvVars(...)
readStateDirDotEnvVars(...)
dist/systemd-bGhJCG6J.js
renderEnvLines(...)
buildSystemdUnit(...)
installSystemdService(...)
Observed behavior:
collectDurableServiceEnvVars(...) reads ~/.openclaw/.env
buildGatewayInstallPlan(...) includes those env vars in the generated service environment
installSystemdService(...) writes them into the main unit as inline Environment=... lines
Audit side:
dist/systemd-hints-DvBn5bxv.js
auditGatewayToken(...)
readEmbeddedGatewayToken(...)
Observed behavior:
- if
OPENCLAW_GATEWAY_TOKEN is present inline in the parsed service environment and not marked as file-sourced, doctor emits:
Gateway service embeds OPENCLAW_GATEWAY_TOKEN and should be reinstalled.
Local workaround that worked
Manual cleanup of the main unit:
- Keep the non-secret service lines in
~/.config/systemd/user/openclaw-gateway.service
- Remove inline secret
Environment= lines from the main unit
- Keep
~/.config/systemd/user/openclaw-gateway.service.d/env.conf with:
[Service]
EnvironmentFile=%h/.openclaw/.env
- Reload and restart:
systemctl --user daemon-reload
systemctl --user restart openclaw-gateway.service
After that:
- gateway stayed running
- merged unit still had
EnvironmentFile=%h/.openclaw/.env
openclaw doctor --non-interactive completed without the embedded-token warning
Impact
- Secrets are copied into the main systemd unit file
- Service backups such as
openclaw-gateway.service.bak also retain secrets
- Doctor guidance is misleading because reinstall may recreate the flagged state
Suggested fix
Preferred:
- On Linux/systemd, persist secrets via
EnvironmentFile=%h/.openclaw/.env only, not inline Environment= lines in the main unit
Minimum:
- Align doctor/audit recommendations with actual installer behavior
- Do not recommend reinstall as a fix unless reinstall produces a non-inline-token result
Notes
- This was observed on the latest stable npm release available on 2026-03-25:
2026.3.23-2
- GitHub prerelease
2026.3.24-beta.1 existed on 2026-03-25, but no release note found for this specific issue
OpenClaw bug report: gateway install inlines
.envsecrets into systemd unit while doctor flags inlineOPENCLAW_GATEWAY_TOKENas staleSummary
On Linux/systemd user installs,
openclaw gateway installin OpenClaw2026.3.23-2writes secrets from~/.openclaw/.envdirectly into~/.config/systemd/user/openclaw-gateway.serviceas inlineEnvironment=...lines.In the same build,
openclaw doctor/ service audit flags an inlineOPENCLAW_GATEWAY_TOKENas stale/non-standard and recommends:openclaw gateway install --forceThat appears internally inconsistent, because reinstall uses the same installer path that serializes the service environment into the unit.
Environment
2026.3.23-2[email protected]Symptoms
openclaw doctor/ status reported:Service config looks out of date or non-standard.Service config issue: Gateway service embeds OPENCLAW_GATEWAY_TOKEN and should be reinstalled.Run openclaw gateway install --force to remove embedded service token.Actual installed unit contained:
Environment=OPENCLAW_GATEWAY_TOKEN=...Environment=lines sourced from~/.openclaw/.envAt the same time, a drop-in also existed:
~/.config/systemd/user/openclaw-gateway.service.d/env.confEnvironmentFile=%h/.openclaw/.envSo the live setup had both:
EnvironmentFiledrop-inRepro
~/.openclaw/.env${OPENCLAW_GATEWAY_TOKEN}inopenclaw.jsonEnvironment=OPENCLAW_GATEWAY_TOKEN=...in the main unitOPENCLAW_GATEWAY_TOKENshould be removed via reinstallExpected behavior
One of these should be true:
EnvironmentFile=%h/.openclaw/.envand avoid serializing secrets into the main systemd unit.Actual behavior
.envvalues into the main unit as inlineEnvironment=...OPENCLAW_GATEWAY_TOKENas stale/non-standard and recommends reinstallRelevant code paths in
2026.3.23-2Installer side:
dist/gateway-install-token-De_pFluK.jsbuildGatewayInstallPlan(...)dist/io-y3Az_Onx.jscollectDurableServiceEnvVars(...)readStateDirDotEnvVars(...)dist/systemd-bGhJCG6J.jsrenderEnvLines(...)buildSystemdUnit(...)installSystemdService(...)Observed behavior:
collectDurableServiceEnvVars(...)reads~/.openclaw/.envbuildGatewayInstallPlan(...)includes those env vars in the generated service environmentinstallSystemdService(...)writes them into the main unit as inlineEnvironment=...linesAudit side:
dist/systemd-hints-DvBn5bxv.jsauditGatewayToken(...)readEmbeddedGatewayToken(...)Observed behavior:
OPENCLAW_GATEWAY_TOKENis present inline in the parsed service environment and not marked as file-sourced, doctor emits:Gateway service embeds OPENCLAW_GATEWAY_TOKEN and should be reinstalled.Local workaround that worked
Manual cleanup of the main unit:
~/.config/systemd/user/openclaw-gateway.serviceEnvironment=lines from the main unit~/.config/systemd/user/openclaw-gateway.service.d/env.confwith:After that:
EnvironmentFile=%h/.openclaw/.envopenclaw doctor --non-interactivecompleted without the embedded-token warningImpact
openclaw-gateway.service.bakalso retain secretsSuggested fix
Preferred:
EnvironmentFile=%h/.openclaw/.envonly, not inlineEnvironment=lines in the main unitMinimum:
Notes
2026.3.23-22026.3.24-beta.1existed on 2026-03-25, but no release note found for this specific issue