Skip to content

fix(core): keep shell commands working after their output directory is removed - #64889

Merged
neriousy merged 1 commit into
devfrom
shell-output-dir
Nov 19, 2026
Merged

neriousy merged 1 commit into
devfrom
shell-output-dir

Conversation

@neriousy

@neriousy neriousy commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Issue for this PR

Closes #64752

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The shell service created <data>/shell/<project-id>/ once, when the Location's shell layer was built. If that directory disappeared while the Location stayed open, every later command failed with failed to open output file ... No such file or directory until a restart (the daemon refuses to create the pipe; the spawner's write stream fails).

Shell.create now ensures the directory exists before each command, on both the daemon and spawner paths. If it cannot be created (for example a file sits at that path), the command fails with an AppProcessError before anything runs. No flag: this is a fix.

Same approach as @r266-tech's patch in the issue thread.

How did you verify your code works?

  • New tests in packages/core/test/shell-daemon.test.ts remove the shell directory between two commands, for the daemon path and the spawner fallback. Both fail on dev and pass here (--rerun-each 10).
  • Existing shell tests (shell-daemon, shell-retention, shell-cleanup, shell-restart, session-shell, tool-shell) still pass. The two tool-shell "conditional substitutions" failures happen on dev too.
  • bun run check passes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #59817, #62763

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix works. I reproduced #64752 on the base with opencode-drive and the simulated model: deleting <data>/opencode/shell while the server runs makes the next ls fail with failed to open output file … No such file or directory. With this PR the same ls runs and returns its listing. The two new tests fail on the base and pass here. The nearby shell tests pass, and typecheck:tsc passes for packages/core.

Public API: unchanged.

One side effect, for the record: since the mkdir no longer runs when the service is built, a blocked path (as in #59817) no longer breaks setting up the whole project location. Only shell commands fail, with an AppProcessError. No concerns.

Related: #59817, #62763

Before

After

@neriousy neriousy changed the title fix(core): recreate the shell output directory before each command fix(core): keep shell commands working after their output directory is removed Nov 19, 2026
@neriousy
neriousy merged commit c740f6d into dev Nov 19, 2026
15 checks passed
@neriousy
neriousy deleted the shell-output-dir branch November 19, 2026 14:40
joe-ieta pushed a commit to joe-ieta/OpenCode.My that referenced this pull request Nov 19, 2026
@amrkmn amrkmn mentioned this pull request Nov 23, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shell: output capture fails - missing ~/.local/share/opencode/shell directory

1 participant