Skip to content

doctor --fix shows "Run doctor --fix" hint when no changes needed #24566

@bhalliburton

Description

@bhalliburton

Description

When running openclaw doctor --fix and there are no pending changes to apply, the output ends with:

Run "openclaw doctor --fix" to apply changes.

This is confusing since we just ran --fix and there's nothing to fix.

Expected behavior

When no changes are needed, show something like:

  • "No changes needed." or
  • "Doctor complete." (without the --fix hint)

The "--fix" hint should only appear when running doctor (without --fix) and changes are detected but not applied.

Root cause

In src/commands/doctor.ts around line 299:

if (configResult.shouldWriteConfig || JSON.stringify(cfg) !== JSON.stringify(cfgForPersistence)) {
    // ... write config ...
} else {
    runtime.log(`Run "${formatCliCommand("openclaw doctor --fix")}" to apply changes.`);
}

The else branch fires when nothing changed, but the message implies there ARE changes to apply.

When this was introduced

Commit d1e9490 (fix: enforce strict config validation, 2026-01-19) changed the behavior from always writing config to only writing when --fix is passed. The intent was correct, but the else branch unconditionally prints the hint even when there's nothing to fix:

-  cfg = applyWizardMetadata(cfg, { command: "doctor", mode: resolveMode(cfg) });
-  await writeConfigFile(cfg);
-  runtime.log(`Updated ${CONFIG_PATH_CLAWDBOT}`);
+  if (prompter.shouldRepair) {
+    cfg = applyWizardMetadata(cfg, { command: "doctor", mode: resolveMode(cfg) });
+    await writeConfigFile(cfg);
+    runtime.log(`Updated ${CONFIG_PATH_CLAWDBOT}`);
+  } else {
+    runtime.log('Run "clawdbot doctor --fix" to apply changes.');
+  }

Suggested fix

Only show the hint when there are actually pending changes:

if (configResult.shouldWriteConfig || JSON.stringify(cfg) !== JSON.stringify(cfgForPersistence)) {
    cfg = applyWizardMetadata(cfg, { command: "doctor", mode: resolveMode(cfg) });
    await writeConfigFile(cfg);
    logConfigUpdated(runtime);
    const backupPath = `${CONFIG_PATH}.bak`;
    if (fs.existsSync(backupPath)) runtime.log(`Backup: ${shortenHomePath(backupPath)}`);
} else if (hasPendingChanges) {
    // Only show hint when NOT in fix mode and changes were detected
    runtime.log(`Run "${formatCliCommand("openclaw doctor --fix")}" to apply changes.`);
}
// Otherwise: stay silent or show "No changes needed"

Environment

  • openclaw version: latest (installed via Homebrew)
  • OS: macOS 15.3 (arm64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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