fix(doctor): shell completion install fails doctor when profile is read-only#99540
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 3, 2026, 8:30 PM ET / 00:30 UTC. Summary PR surface: Source +30, Tests +100. Total +130 across 3 files. Reproducibility: yes. The linked issue gives a concrete read-only Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land one canonical doctor-boundary fix for the linked bug after exact-head CI finishes, then close the sibling duplicate PRs and linked issue through the normal merge flow. Do we have a high-confidence way to reproduce the issue? Yes. The linked issue gives a concrete read-only Is this the best way to solve the issue? Yes. The patch keeps explicit completion installation strict and downgrades only profile permission failures in the doctor-owned optional repair path, with non-permission errors still rethrown. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 24dba4b44a5b. Label changesLabel justifications:
Evidence reviewedPR surface: Source +30, Tests +100. Total +130 across 3 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
7f964da to
3cbb06f
Compare
|
Maintainer rewrite + validation complete at What improved:
Proof:
GitHub CI on the exact pushed SHA remains the final merge gate. No provider key is relevant to this filesystem-only doctor path. |
3cbb06f to
b8a2eb2
Compare
Treat wrapped shell-profile permission failures as an optional doctor repair, while preserving non-permission failures and the actual failing profile path. Cover install and upgrade flows across EACCES, EPERM, and EROFS. Fixes openclaw#99237 Co-authored-by: Ceng Xin <[email protected]>
b8a2eb2 to
1a055ee
Compare
|
Merged via squash.
|
Treat wrapped shell-profile permission failures as an optional doctor repair, while preserving non-permission failures and the actual failing profile path. Cover install and upgrade flows across EACCES, EPERM, and EROFS. Fixes openclaw#99237 Co-authored-by: Peter Steinberger <[email protected]>
When ~/.bashrc or other shell profile is not writable (e.g., read-only files in sandboxes with root-owned rc files), doctor --fix previously failed with exit code 1 due to unhandled permission errors. This change treats shell completion installation as optional, similar to how other doctor sub-steps degrade gracefully. On EACCES/EPERM/EROFS, a warning note is shown instead of throwing, and doctor exits 0. Non-permission errors (e.g., ENOSPC) are still re-thrown.
Fixes #99237
What Problem This Solves
Fixes an issue where users running
openclaw doctor --fixin environments with read-only shell profiles would experience a hard exit with code 1, even though all other doctor checks completed successfully.The affected workflow is the
doctor --fixcommand, which runs multiple health checks and repairs. When shell completion installation attempts to write to a read-only~/.bashrcfile (common in containerized or sandboxed environments like NVIDIA NemoClaw), the entire doctor run fails instead of treating this as an optional convenience step.Why This Change Was Made
Shell completion is a convenience feature, not a critical health check. The fix aligns behavior with
doctor --fix --non-interactive, which already skips this step entirely. By wrappinginstallCompletion()calls in try-catch blocks that only handle permission errors (EACCES, EPERM, EROFS), the code now shows a warning note instead of throwing an error, allowing the doctor process to exit with code 0.The implementation adds:
isProfileWriteError()helper function that detects permission errors (EACCES, EPERM, EROFS), including those wrapped in a cause chainUser Impact
Users with read-only shell profiles will now see a clear warning message instead of a fatal error:
Shell completion not upgraded: /sandbox/.bashrc is not writable. Run openclaw completion --install against a writable profile file.
The doctor command will exit with code 0, allowing automation scripts and CI pipelines to complete successfully. Users can manually install completion later when they have write access to their shell profile.
Evidence
Test cases added: doctor-completion.test.ts now includes:
handles EACCES gracefully when installing completion- verifies permission errors are downgraded to warningsre-throws non-permission errors from installCompletion- verifies ENOSPC and other errors are still re-thrownAll existing tests pass:
src/commands/doctor-completion.test.ts: 6 tests passedsrc/flows/doctor-health-contributions.test.ts: 61 tests passedsrc/cli/completion-runtime.test.ts+src/cli/update-cli.test.ts: 168 tests passedAfter-fix terminal output (EACCES gracefully handled):
◇ Shell completion ────────────────────────────────────────────────╮
│ │
│ Your bash profile uses slow dynamic completion (source <(...)). │
│ Upgrading to cached completion for faster shell startup... │
│ │
├───────────────────────────────────────────────────────────────────╯
│
◇ Shell completion ─────────────────────────────────────────────────╮
│ │
│ Shell completion not upgraded: │
│ /tmp/openclaw-doctor-home-xZe3IJ/.bashrc is not writable. Run │
│ openclaw completion --install against a writable profile file. │
│ │
├────────────────────────────────────────────────────────────────────╯
Error coverage: