fix(infra): tolerate deleted cwd across startup, PATH, home-dir, and TUI [AI-assisted]#93636
Conversation
|
Maintainer review found this does not yet fix the reported deleted-cwd TUI path. runTui and tui-local-shell still call bare process.cwd(), so openclaw tui can still crash after startup. Mapping a missing cwd to HOME also changes project-local PATH trust semantics by treating $HOME/node_modules/.bin as the deleted project path; dotenv, PATH, required-home, and TUI need caller-specific fallback behavior instead of one generic HOME fallback. PR #93034 is the stronger repair base because it uses nullable cwd handling, skips project-local PATH lookup, and covers TUI, though it still needs rebase/conflict repair and removal of its tmpdir required-home fallback. Keeping this PR open rather than landing the current incomplete shape. |
Rework per maintainer review on openclaw#93636: drop the generic safeCwd()->HOME fallback in favor of nullable cwd handling (tryProcessCwd), with each caller choosing its own behavior: - dotenv: skip workspace .env (already done) - PATH: skip project-local bin lookup when cwd is null (was wrongly remapping to $HOME/node_modules/.bin, changing PATH trust semantics) - required-home: fall back to the running Node binary dir (not os.tmpdir shared-temp, not a generic HOME that is already empty in this branch) - TUI: cover runTui, resolveLocalAuthSpawnCwd, and resolveInitialTuiAgentId (previously unguarded bare process.cwd()) - tui-local-shell: fall back to os.homedir() for !cmd spawn cwd Adopts the nullable-cwd design from PR openclaw#93034 (the endorsed repair base), diverging on the required-home fallback (execPath dir instead of tmpdir). Closes openclaw#73676.
|
@vincentkoc Thanks for the review — reworked this PR to address all four points. Pushed in 1. TUI coverage — 2. Nullable cwd instead of one generic HOME fallback — dropped
3. required-home fallback — deliberately not 4. Alignment with #93034 — adopted its nullable-cwd design, Verification: Would appreciate your read on the required-home fallback choice. |
|
Codex review: needs maintainer review before merge. Reviewed July 5, 2026, 2:59 PM ET / 18:59 UTC. Summary PR surface: Source +44, Tests +96. Total +140 across 14 files. Reproducibility: yes. from source: current main still calls bare Review metrics: 1 noteworthy metric.
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 this caller-specific deleted-cwd fix after exact-head required checks pass, then close #73676 and retire or supersede overlapping fix attempts such as #93034. Do we have a high-confidence way to reproduce the issue? Yes from source: current main still calls bare Is this the best way to solve the issue? Yes. The caller-specific nullable-cwd shape is better than a generic HOME or temp fallback because dotenv, PATH, required-home, TUI auth/autocomplete, and local shell each preserve their own trust boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c730d8f1f1bb. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +44, Tests +96. Total +140 across 14 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
Review history (6 earlier review cycles)
|
Rework per maintainer review on openclaw#93636: drop the generic safeCwd()->HOME fallback in favor of nullable cwd handling (tryProcessCwd), with each caller choosing its own behavior: - dotenv: skip workspace .env (already done) - PATH: skip project-local bin lookup when cwd is null (was wrongly remapping to $HOME/node_modules/.bin, changing PATH trust semantics) - required-home: fall back to the running Node binary dir (not os.tmpdir shared-temp, not a generic HOME that is already empty in this branch) - TUI: cover runTui, resolveLocalAuthSpawnCwd, and resolveInitialTuiAgentId (previously unguarded bare process.cwd()) - tui-local-shell: fall back to os.homedir() for !cmd spawn cwd Adopts the nullable-cwd design from PR openclaw#93034 (the endorsed repair base), diverging on the required-home fallback (execPath dir instead of tmpdir). Closes openclaw#73676.
|
Land-ready on clean exact head
|
Co-authored-by: ml12580 <long.xinyuan3@xydigit.com>
|
Merged via squash.
|
What Problem This Solves
Closes #73676. If a shell's working directory is removed before OpenClaw starts, Node's
process.cwd()throwsENOENT: uv_cwd. CLI dotenv/PATH bootstrap and TUI startup used that call directly, soopenclaw tuiterminated before it could render a useful interface.Why This Change Was Made
Introduce one small nullable-CWD primitive, then keep the decision at each owner boundary:
!commands refuse instead of silently running somewhere else.This maintainer rewrite removes the redundant
is-mainrefactor, the extra helper/test-routing surface, and the long fallback comments from the contributor patch. Normal cwd-present behavior is unchanged.User Impact
The CLI and full-screen TUI can start after their launch directory has been deleted. Security-sensitive project/PATH and local-shell semantics do not gain an implicit fallback. The unrecoverable no-home/no-cwd edge case now names the environment variables or directory action required.
Evidence
tbx_01kwsmjrh13za4ghjn0kcrhfjt, run 28748684029: 147 focused boundary/dotenv/TUI tests passed on the final rebased source.tbx_01kwskqhr1tm4d5r3g5vwh7ce8, run 28748286393:corepack pnpm check:changedpassed for the exact 14-file core/coreTests scope, including full core lint/typecheck/guards.gateway disconnected, and observed nouv_cwd; command exited 0.git diff --checkpassed.Release note: Fixed CLI and TUI startup crashes when the current working directory is deleted, while preserving project-local PATH and local-shell safety boundaries.