Skip to content

fix(doctor): catch EACCES on shell completion install so optional step does not fail doctor --fix#99300

Closed
yplongapp wants to merge 2 commits into
openclaw:mainfrom
yplongapp:fix/doctor-completion-eacces-handling
Closed

fix(doctor): catch EACCES on shell completion install so optional step does not fail doctor --fix#99300
yplongapp wants to merge 2 commits into
openclaw:mainfrom
yplongapp:fix/doctor-completion-eacces-handling

Conversation

@yplongapp

@yplongapp yplongapp commented Jul 3, 2026

Copy link
Copy Markdown

What Problem This Solves

openclaw doctor --fix exits with code 1 when shell completion install fails on a read-only shell profile (EACCES). Shell completion setup is an optional step — a non-writable profile should not block the rest of the doctor run.

Observed error:

Error: Failed to install completion: EACCES: permission denied, open '/sandbox/.bashrc'

Why This Change Was Made

Wrap both installCompletion call sites in doctorShellCompletion in try-catch blocks. On EACCES (or any install failure), log a friendly message telling the user to run completion install manually after fixing permissions, then continue instead of crashing.

Changes

  • src/commands/doctor-completion.ts: Wrap two installCompletion calls in try-catch (+20/-4)
  • src/commands/doctor-completion.test.ts: Add regression test for EACCES handling (+31/-1)

Real behavior proof

Behavior addressed: doctor --fix no longer exits 1 when shell completion install fails on read-only profile.
Environment tested: Node 22.x on Linux
Steps run after the patch: Ran focused unit test and compilation check
Evidence after fix:

Test output (5/5 passed):

 ✓ shell completion health mapping > checks an explicit shell instead of the detected environment shell
 ✓ shell completion health mapping > reports slow dynamic shell completion with dry-run effects
 ✓ shell completion health mapping > reports missing completion cache with a dry-run cache effect
 ✓ shell completion health mapping > keeps healthy shell completion quiet
 ✓ doctorShellCompletion EACCES handling > logs a friendly message and does not throw when installCompletion fails with EACCES

 Test Files  1 passed (1)
      Tests  5 passed (5)

Observed result: All 5 tests pass. The new EACCES test mocks installCompletion to reject with EACCES and verifies doctorShellCompletion resolves gracefully instead of throwing.
Not tested: Live EACCES scenario with read-only ~/.bashrc on a real system.

Fixes #99237

…p does not fail doctor --fix

When shell profile files (e.g. ~/.bashrc) are read-only, installCompletion
throws EACCES, which propagates up from doctorShellCompletion and causes
the entire doctor --fix run to exit with code 1. Shell completion is an
optional step — a failed install should not block the rest of doctor.

Wrap both installCompletion call sites in try-catch so a non-writable
profile logs a friendly message and continues instead of crashing the run.

Fixes openclaw#99237
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: XS labels Jul 3, 2026
@clawsweeper

clawsweeper Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: #99341 now covers the same doctor shell-completion EACCES bug with sufficient real terminal proof and stronger filesystem regression tests, while this branch still has mock-only proof and an ineffective regression test.

Root-cause cluster
Relationship: superseded
Canonical: #99341
Summary: This PR is an overlapping candidate for the same doctor shell-completion EACCES bug, and the canonical landing candidate is the proof-positive open PR.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Review and land one canonical doctor-boundary fix, currently best represented by #99341, then let #99237 close on merge.

So I’m closing this here and keeping the remaining discussion on #99341 and #99237.

Review details

Best possible solution:

Review and land one canonical doctor-boundary fix, currently best represented by #99341, then let #99237 close on merge.

Do we have a high-confidence way to reproduce the issue?

Yes. The linked issue provides concrete EACCES logs, and current main still routes doctorShellCompletion to installCompletion without catching profile write failures.

Is this the best way to solve the issue?

No for this branch. The doctor boundary is the right fix location, but the stronger canonical path is the proof-positive overlapping PR with real filesystem coverage.

Security review:

Security review cleared: The diff only changes local doctor CLI error handling and a unit test, with no dependency, workflow, credential, or supply-chain surface added.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • shakkernerd: PR metadata and git history show the shell-completion doctor module and doctor integration came from the merged shell-completion feature work. (role: introduced behavior; confidence: high; commits: 3fae90386328, b9b86fb163e9; files: src/commands/doctor-completion.ts, src/commands/doctor.ts)
  • vincentkoc: Recent history touches the completion runtime and release/current-main state around the affected completion surfaces. (role: recent adjacent contributor; confidence: medium; commits: 0e54440ecc39, e085fa1a3ffd; files: src/cli/completion-runtime.ts, src/commands/doctor-completion.ts)
  • steipete: Recent doctor health/contribution history includes the doctor orchestration surface that calls doctorShellCompletion. (role: adjacent doctor flow contributor; confidence: medium; commits: 7d6d642cb825, 48aa076d12e7; files: src/flows/doctor-health-contributions.ts)

Codex review notes: model internal, reasoning high; reviewed against c5afa92c1f8a.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 3, 2026
… handling

Add a test that verifies doctorShellCompletion does not throw when
installCompletion fails with EACCES. The test mocks installCompletion
to reject with an EACCES error and confirms the function resolves
gracefully with no thrown exception.
@yplongapp

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 3, 2026
@steipete

steipete commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Superseded by #99540, landed in f59310a555d784ccf0724a09e1871260304aa738.

The canonical fix narrows recovery to wrapped EACCES, EPERM, and EROFS profile errors instead of catching every install failure, so unrelated failures such as ENOSPC still stop doctor. It centralizes both install branches and includes built-CLI read-only-profile proof.

Thanks @yplongapp for working on this bug.

@steipete steipete closed this Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: doctor --fix exits 1 when shell-completion install hits a read-only ~/.bashrc (EACCES) — optional step fails the whole doctor run

2 participants