Repository navigation
fix(tools): report missing working directory instead of fork/exec shell ENOENT (#457) - #458
Conversation
…ll ENOENT Issue #457: when a session cwd is deleted (machine migration, worktree cleanup, tmp reclamation), every Shell call failed with sandbox exec: fork/exec /usr/bin/zsh: no such file or directory os/exec performs chdir in the child, so the failure is reported against the shell path and hides the real cause; the agent cannot recover via Shell. - cmdbuilder.Build validates Dir before assigning cmd.Dir and returns an actionable error naming the directory + the Cd recovery path. - setupPipes keeps the cwd (and executable) in Start errors so races and permission failures that stat cannot detect are still attributable. - Regression tests at Exec / async / Shell-tool level; existing-dir path stays green. No silent fallback to home/ancestor dirs: running git/rm in the wrong directory is worse than an explicit failure.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3c5b5211d7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
问题
Closes #457.
会话 cwd 被删除/移走(开发机迁移、git worktree 清理、临时目录回收)后,所有 Shell 调用都报:
把原因指向 shell 二进制,真实原因是
cmd.Dir已不存在;agent 无法通过 Shell 自恢复,只能先Cd到存在目录。根因
os/exec在子进程里做 chdir,失败时返回*os.PathError{Op:"fork/exec", Path:<shell>, Err:ENOENT}—— Path 是 shell 路径,cwd 完全不出现。本地 none sandbox 在internal/cmdbuilder/cmdbuilder.go直接cmd.Dir = dir,没有存在性校验;远程 runner 反而有resolveWorkDir兜底,两端行为不一致。修复
internal/cmdbuilder/cmdbuilder.go:赋值cmd.Dir前os.Stat校验;缺失/非目录 ⇒working directory %q is not accessible: ...; use the Cd tool to change to an existing directorytools/none_sandbox.gosetupPipes:cmd.Start()失败且cmd.Dir != ""时把 cwd + 可执行文件写进错误,保留 stat 检测不到的竞态/权限类 chdir 原因git/rm比明确失败危险;Cd是设计好的恢复路径docs/agent/gotchas-tools.md记录该 gotcha验证
新增
tools/none_sandbox_missing_dir_test.go(修复前红灯,报fork/exec /bin/sh: ...):Exec缺失目录 ⇒ 明确 cwd 错误 +Cd提示、不含fork/execnoneSandboxExecAsync(后台/流式路径)同上