← Back to PRs

#9154: fix(doctor): resolve symlinks before comparing state directories

by gavinbmoore open 2026-02-04 23:04 View on GitHub →
commands stale
## Summary Fixes false positive "Multiple state directories detected" warning on Fedora Silverblue and other systems where `/home` is a symlink to `/var/home`. ## The Problem On Fedora Silverblue (and other immutable Fedora variants), `/home` is a symlink to `/var/home`. When `findOtherStateDirs()` searches `/home` for `.openclaw` directories, it finds paths like `/home/user/.openclaw`, but the active state dir is `/var/home/user/.openclaw`. The string comparison fails because `path.resolve()` only normalizes paths without resolving symlinks. ## The Fix - Add `safeRealpath()` helper that uses `fs.realpathSync()` to resolve symlinks - Falls back to `path.resolve()` if the path doesn't exist (graceful degradation) - Use `safeRealpath()` in `findOtherStateDirs()` and when comparing default vs configured state dir ## Testing - Added test file `doctor-state-integrity.symlink-resolution.test.ts` with 3 tests - Tests verify symlink resolution behavior for the Silverblue scenario - All tests pass locally Fixes #9136 🤖 Generated by Claw overnight build <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates the doctor “state integrity” checks to resolve symlinks via a new `safeRealpath()` helper before comparing the active state directory against candidates (notably fixing Fedora Silverblue’s `/home -> /var/home` case) in `src/commands/doctor-state-integrity.ts`. It also adds a new Vitest file intended to cover the symlink-resolution scenario. However, the added tests currently only validate Node’s `fs.realpathSync`/`path.resolve` behavior and do not exercise the OpenClaw doctor logic (`findOtherStateDirs()` / `noteStateIntegrity()`), so they won’t actually prevent regressions of the reported warning in future changes. <h3>Confidence Score: 3/5</h3> - This PR is likely safe to merge, but the new tests do not currently enforce the intended behavior change. - The production change is small and targeted (realpath before comparisons), but the accompanying test suite doesn’t exercise the affected doctor code paths, so regressions are not well-guarded. - src/commands/doctor-state-integrity.symlink-resolution.test.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs