Skip to content

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

Description

@hunglp6d

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

On OpenClaw 2026.5.27, openclaw doctor --fix run in an environment where ~/.bashrc is
read-only (root-owned, mode 444) completes every doctor check green, then throws
Error: Failed to install completion: EACCES: permission denied, open '/sandbox/.bashrc'
and exits 1; reproduced deterministically on two machines.

Steps to reproduce

  1. Install OpenClaw and use a user account whose ~/.bashrc has no openclaw
    completion line yet.
  2. Make the rc file read-only: chmod 444 ~/.bashrc
    (equivalently: any environment where ~/.bashrc is root-owned mode 444 — this is
    how NVIDIA NemoClaw sandboxes ship by design, where the bug was found).
  3. Run: openclaw doctor --fix; echo "exit:$?"
  4. Observe all doctor sections complete, then the trailing
    Error: Failed to install completion: EACCES … and exit:1.
    (Restore afterwards: chmod 644 ~/.bashrc.)

Expected behavior

Doctor treats shell-completion install as optional: on an unwritable rc file it prints a
one-line warning (e.g. "Shell completion not installed: ~/.bashrc is not writable — run
openclaw completion install against a writable rc file") and exits 0, consistent with
how other doctor sub-steps degrade to notes. doctor --fix --non-interactive already
skips this step entirely, so a hard failure on bare --fix is inconsistent.

Actual behavior

All doctor sections complete (config cleanup, skills, plugins, state integrity,
HEARTBEAT template repair), then:

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

and the process exits 1. No "Shell completion" note or prompt is shown before the error.
Full log in the Logs section.

OpenClaw version

2026.5.27 (27ae826)

Operating system

Ubuntu 24.04 inside a Docker container (NVIDIA NemoClaw sandbox); hosts: DGX Spark (aarch64, Linux 6.17.0-1014-nvidia) and a B300 server — identical result on both.

Install method

npm global, inside the Docker sandbox image (NVIDIA NemoClaw)

Model

N/A — bug is in the doctor CLI path; no model/inference involved.

Provider / routing chain

N/A — no request is made; failure is a local filesystem write in the completion installer.

Additional provider/model setup details

N/A

Logs

$ ls -la /sandbox/.bashrc
-r--r--r-- 1 root root 30 Jul  2 17:03 /sandbox/.bashrc

$ cat /sandbox/.bashrc
# NemoClaw sandbox shell init

$ openclaw doctor --fix; echo "doctor_exit:$?"
[... all sections green: Config warnings, Doctor changes, Command owner, Plugin
registry, State integrity, Security, Skills status (Eligible: 15), Plugins
(Loaded: 57, Errors: 0), HEARTBEAT template replaced ...]
Error: Failed to install completion: EACCES: permission denied, open '/sandbox/.bashrc'
doctor_exit:1

Screenshots, recordings, and evidence

N/A — text logs above.

Impact and severity

  • Affected: anyone running openclaw doctor --fix where the shell rc file is not
    writable. Observed across all NVIDIA NemoClaw sandboxes, which intentionally lock
    ~/.bashrc to root:444 as security hardening (rc-file persistence prevention) —
    making the file writable is not an option there.
  • Severity: doctor's exit code becomes unusable as a health signal in these
    environments; routine maintenance reports failure while every check actually passed.
  • Frequency: deterministic — 100% of doctor --fix runs in such an environment
    (multiple runs, two machines).
  • Consequence: CI/automation flags healthy sandboxes as broken; users debug a
    non-existent problem.

Additional information

Found via NVIDIA/NemoClaw#6048. Not claiming a regression — older versions not tested.

Code path (read at commit be94853; function names should be stable):

  1. --fix auto-approves every doctor confirm without rendering it
    (shouldAutoApproveDoctorFix, src/commands/doctor-prompter.ts), so
    doctorShellCompletion (src/commands/doctor-completion.ts) proceeds into the
    "Enable shell completion?" path unprompted — this also explains why no prompt or
    "Shell completion" note appears in the output (installCompletion is called with
    yes=true, which suppresses its logging).
  2. installCompletion (src/cli/completion-runtime.ts) hits EACCES writing the
    profile and throws Failed to install completion: ….
  3. The doctor caller runShellCompletionHealth
    (src/flows/doctor-health-contributions.ts) has no try/catch, so the error
    escapes the pipeline and sets exit 1.

Suggested fix: wrap the completion step in try/catch and downgrade to a "Shell
completion" warning note; optionally pre-check writability
(fs.access(profilePath, W_OK)) and skip with the same note.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.bugSomething isn't workingclawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.no-staleExclude from stale automation

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions