openclaw - ✅(Solved) Fix [Bug]: `openclaw doctor --fix` creates minimal config at /root/.openclaw/ that silently overrides real config, breaking elevated permissions [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#63265Fetched 2026-04-09 07:56:07
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
referenced ×2cross-referenced ×1

Running openclaw doctor --fix as root (e.g. via SSH on a systemd-managed gateway with Environment=HOME=/home/node) creates /root/.openclaw/openclaw.json with only gateway.auth + wizard + meta. This minimal config silently takes precedence over the actual config at /home/node/.openclaw/openclaw.json, breaking tools.elevated and other sections that are missing from the root copy.

Error Message

  • Warn that it's about to create a config at a different location than the running gateway High. Silent breakage of elevated tool permissions on any systemd-managed deployment where an admin runs openclaw doctor via SSH. No error at doctor time — appears successful. Gateway looks healthy. The failure only surfaces when a user triggers an elevated command, making it very hard to diagnose.

Root Cause

  • #52339 — OPENCLAW_CONFIG_DIR defaults causing write failures (same root cause, different symptom)
  • #58090 — doctor wipes session.resetByType config (doctor overwriting user config pattern)
  • #56671 — config clobbering deduplication (related config integrity work)

Fix Action

Workaround

Set OPENCLAW_CONFIG_PATH explicitly when running doctor as root:

OPENCLAW_CONFIG_PATH=/home/node/.openclaw/openclaw.json openclaw doctor --fix

This prevents the rogue config from being created. Verified working on v2026.4.5.

PR fix notes

PR #63268: fix(doctor): warn when config path diverges from running gateway

Description (problem / solution / changelog)

Summary

Fixes #63265

When openclaw doctor --fix runs as root (e.g. via SSH on a systemd-managed host where the gateway uses Environment=HOME=/home/node), it resolves config to /root/.openclaw/openclaw.json instead of the gateway's actual config. The minimal config it creates silently overrides the real one, breaking tools.elevated and other settings.

Changes

Added a preflight check in doctor-config-preflight.ts that:

  1. Resolves the config path doctor is about to use
  2. Checks common alternative HOME directories (/home/node, /home/openclaw) for existing configs with meaningful content (agents, tools, or channels keys)
  3. If a mismatch is found, emits a warning with the fix:
    ⚠ Config path mismatch
    A config with agents/tools/channels exists at /home/node/.openclaw/openclaw.json
    but doctor is using /root/.openclaw/openclaw.json
    
    Fix: set OPENCLAW_CONFIG_PATH=/home/node/.openclaw/openclaw.json

Design decisions

  • Warning only, not blocking — doctor still runs but the user is informed
  • Additive code only — no changes to resolveHomeDir(), readConfigFileSnapshot(), or any existing path resolution. Avoids conflicts with #56671
  • Content check — only warns if the alternative config has agents, tools, or channels (meaningful gateway config)

Test plan

  • Reproduced the bug on EC2 (Amazon Linux 2023, OpenClaw 2026.4.5)
  • Verified workaround: OPENCLAW_CONFIG_PATH=... openclaw doctor --fix prevents rogue config
  • Verified the warning fires when configs diverge
  • Verified no warning when paths match (normal case)

Related

  • #52339 — OPENCLAW_CONFIG_DIR defaults causing write failures
  • #58090 — doctor wipes config
  • #56671 — config clobbering deduplication

Changed files

  • src/commands/doctor-config-preflight.ts (modified, +64/-0)

Code Example

{
  "gateway": {
    "auth": { "mode": "token", "token": "..." }
  },
  "wizard": { ... },
  "meta": { ... }
}

---

[tools] exec failed: elevated is not available right now (runtime=direct)
Failing gates: enabled (tools.elevated.enabled / agents.list[].tools.elevated.enabled)

---

Config observe anomaly: /root/.openclaw/openclaw.json (size-drop-vs-last-good:940->392, gateway-mode-missing-vs-last-good)

---

OPENCLAW_CONFIG_PATH=/home/node/.openclaw/openclaw.json openclaw doctor --fix

---

A gateway is running with config at /home/node/.openclaw/openclaw.json
  but doctor is about to write to /root/.openclaw/openclaw.json
  Use OPENCLAW_CONFIG_PATH=/home/node/.openclaw/openclaw.json to match.
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug

Summary

Running openclaw doctor --fix as root (e.g. via SSH on a systemd-managed gateway with Environment=HOME=/home/node) creates /root/.openclaw/openclaw.json with only gateway.auth + wizard + meta. This minimal config silently takes precedence over the actual config at /home/node/.openclaw/openclaw.json, breaking tools.elevated and other sections that are missing from the root copy.

Steps to reproduce

  1. Configure OpenClaw with tools.elevated.enabled: true at /home/node/.openclaw/openclaw.json
  2. Run gateway via systemd: User=root, Environment=HOME=/home/node — elevated works fine
  3. SSH into the host as root
  4. Run openclaw doctor --fix (without HOME override — defaults to /root)
  5. Doctor creates /root/.openclaw/openclaw.json (392 bytes)
  6. Restart gateway
  7. All elevated exec commands fail

Expected behavior

doctor --fix should either:

  • Detect the running gateway's config path and use it
  • Warn that it's about to create a config at a different location than the running gateway
  • Respect OPENCLAW_CONFIG_PATH / OPENCLAW_HOME from the systemd environment

Actual behavior

Doctor silently creates a minimal config at /root/.openclaw/openclaw.json:

{
  "gateway": {
    "auth": { "mode": "token", "token": "..." }
  },
  "wizard": { ... },
  "meta": { ... }
}

No tools.elevated, no agents, no channels. The gateway then loads this config (or merges it), and elevated breaks:

[tools] exec failed: elevated is not available right now (runtime=direct)
Failing gates: enabled (tools.elevated.enabled / agents.list[].tools.elevated.enabled)

Doctor itself even detects the anomaly but doesn't prevent it:

Config observe anomaly: /root/.openclaw/openclaw.json (size-drop-vs-last-good:940->392, gateway-mode-missing-vs-last-good)

Workaround

Set OPENCLAW_CONFIG_PATH explicitly when running doctor as root:

OPENCLAW_CONFIG_PATH=/home/node/.openclaw/openclaw.json openclaw doctor --fix

This prevents the rogue config from being created. Verified working on v2026.4.5.

Proposed fix

The lowest-conflict fix would be a guard in doctor-config-preflight.ts that detects a running gateway and warns if config paths diverge:

⚠ A gateway is running with config at /home/node/.openclaw/openclaw.json
  but doctor is about to write to /root/.openclaw/openclaw.json
  Use OPENCLAW_CONFIG_PATH=/home/node/.openclaw/openclaw.json to match.

This is ~10 lines of additive code in one file, no changes to existing path resolution logic, no new CLI flags. Avoids conflicts with #56671.

Environment

  • OpenClaw version: 2026.4.5 (3e72c03)
  • OS: Amazon Linux 2023 (EC2 x86_64)
  • Install method: npm install -g openclaw
  • Node: v22.22.1

Impact

High. Silent breakage of elevated tool permissions on any systemd-managed deployment where an admin runs openclaw doctor via SSH. No error at doctor time — appears successful. Gateway looks healthy. The failure only surfaces when a user triggers an elevated command, making it very hard to diagnose.

Related

  • #52339 — OPENCLAW_CONFIG_DIR defaults causing write failures (same root cause, different symptom)
  • #58090 — doctor wipes session.resetByType config (doctor overwriting user config pattern)
  • #56671 — config clobbering deduplication (related config integrity work)

extent analysis

TL;DR

Set OPENCLAW_CONFIG_PATH explicitly when running openclaw doctor --fix as root to prevent creating a minimal config that overrides the actual config.

Guidance

  • Verify the OPENCLAW_CONFIG_PATH environment variable is set to the correct path (/home/node/.openclaw/openclaw.json) before running openclaw doctor --fix as root.
  • Use the workaround OPENCLAW_CONFIG_PATH=/home/node/.openclaw/openclaw.json openclaw doctor --fix to prevent the rogue config from being created.
  • Consider implementing a guard in doctor-config-preflight.ts to detect a running gateway and warn if config paths diverge.
  • Check for similar issues related to config integrity, such as #52339, #58090, and #56671.

Example

OPENCLAW_CONFIG_PATH=/home/node/.openclaw/openclaw.json openclaw doctor --fix

Notes

The proposed fix requires minimal code changes and avoids conflicts with existing issues. However, it may not be applicable to all scenarios, and further testing is recommended.

Recommendation

Apply the workaround by setting OPENCLAW_CONFIG_PATH explicitly when running openclaw doctor --fix as root, as it is a simple and effective solution to prevent the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

doctor --fix should either:

  • Detect the running gateway's config path and use it
  • Warn that it's about to create a config at a different location than the running gateway
  • Respect OPENCLAW_CONFIG_PATH / OPENCLAW_HOME from the systemd environment

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING