You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(filesystem): crash when project directory does not exist #50548
OpenCode Desktop opens but does not return any answers when a previously-used project directory no longer exists on disk.
Root Cause
In packages/core/src/filesystem.ts:65, the FileSystem service layer calls fs.realPath(location.directory).pipe(Effect.orDie). When the location directory (e.g. a deleted project directory) no longer exists, fs.realPath throws a PlatformError(NotFound) which is turned into a fatal defect by .orDie. This kills the entire FileSystem service, making all tools (read, list, glob, grep) and prompts fail silently.
The same issue exists on line 70 for path resolution within resolve().
Fix
Replace the two fs.realPath(...).pipe(Effect.orDie) calls with fs.resolve(...), which already handles NotFound gracefully (see packages/core/src/fs-util.ts:94-99):
- const real = yield* fs.realPath(absolute).pipe(Effect.orDie)+ const real = yield* fs.resolve(absolute)
The FSUtil.resolve method catches PlatformError(NotFound) and returns the normalized path string as-is, while still failing on other errors via Effect.orDie. This prevents a deleted project directory from crashing the entire service.
This issue might be a duplicate of an existing issue. Please check:
Model selector unavailable when reopening a session whose project directory was deleted #50137: Same symptom — when a project directory is deleted from disk, OpenCode breaks. That issue reports the model selector becoming unavailable; this issue identifies the underlying root cause (Effect.orDie on fs.realPath) and proposes a fix. These may be the same defect reported at different levels.
Adding evidence from a full reproduction on 2.0.18 (desktop, macOS 26, arm64) — same root cause as described here, plus a second layer that the fs.resolve fix alone does not cover.
The symptom here is a hard failure, not a silent one. The desktop renderer dies during startup with a "server request failed — HTTP 500" screen, and the bundled service returns 500 on every directory-scoped endpoint:
cause="PlatformError: NotFound: FileSystem.realPath (<deleted dir>)
[cause]: Error: ENOENT: no such file or directory, lstat '<deleted dir>'"
http.url=/api/skill http.status=500
/api/skill, /api/mcp, /api/plugin, /api/provider, /api/model, /api/integration, /api/location all returned 500. The same request with x-opencode-directory pointing at an existing directory returns 200, so the failure is purely location resolution.
The deleted path is persisted in two places, and nothing in the product surfaces them:
Client — ~/Library/Application Support/ai.opencode.desktop/drafts.sqlite, table state, document opencode.global.dat, key layout → home.selection.directory. This is what makes startup fatal. server.projects.local[].worktree in the same document also keeps the dead project in the sidebar.
Server — opencode.db, table project, column worktree (plus session.directory / session_v2.directory for that project's sessions).
So fixing the crash is necessary but not sufficient: the client still reopens the dead path on every launch — the same conclusion as the closed #35240 — and the error screen only offers Restart, which loops back into the identical failure. Expected instead: fall back to a valid location, or at minimum name the missing path in a recoverable message.
Server-side registry cache. Even with both files corrected while the service was running, GET /api/project still returned the deleted project and the server re-inserted the row I had just deleted. POST /api/location/reload did not clear it. PATCH /api/project/{projectID} with a corrected canonical did, without restarting the service.
Still reproduces on 2.0.18. The closed #30750 reported the same startup symptom on 1.15.11, so this looks like a regression or an unfixed path rather than a one-off.
Unrelated aside noticed while investigating: ~/.local/share/opencode/log/opencode.log has no rotation or size bound — it reached 47 MB in about two days.
(Consolidating my duplicate report #51465 into this issue.)
Thanks for the report and the detailed investigation. We're tracking this same failure when a project's directory has been deleted in #50137, so I'm closing this as a duplicate. Please follow that issue for updates.
Activity
github-actions commentedon Sep 22, 2026
This issue might be a duplicate of an existing issue. Please check:
Effect.orDieonfs.realPath) and proposes a fix. These may be the same defect reported at different levels.alecgib77 commentedon Sep 26, 2026
Adding evidence from a full reproduction on 2.0.18 (desktop, macOS 26, arm64) — same root cause as described here, plus a second layer that the
fs.resolvefix alone does not cover.The symptom here is a hard failure, not a silent one. The desktop renderer dies during startup with a "server request failed — HTTP 500" screen, and the bundled service returns 500 on every directory-scoped endpoint:
/api/skill,/api/mcp,/api/plugin,/api/provider,/api/model,/api/integration,/api/locationall returned 500. The same request withx-opencode-directorypointing at an existing directory returns 200, so the failure is purely location resolution.The deleted path is persisted in two places, and nothing in the product surfaces them:
~/Library/Application Support/ai.opencode.desktop/drafts.sqlite, tablestate, documentopencode.global.dat, keylayout→home.selection.directory. This is what makes startup fatal.server.projects.local[].worktreein the same document also keeps the dead project in the sidebar.opencode.db, tableproject, columnworktree(plussession.directory/session_v2.directoryfor that project's sessions).So fixing the crash is necessary but not sufficient: the client still reopens the dead path on every launch — the same conclusion as the closed #35240 — and the error screen only offers Restart, which loops back into the identical failure. Expected instead: fall back to a valid location, or at minimum name the missing path in a recoverable message.
Server-side registry cache. Even with both files corrected while the service was running,
GET /api/projectstill returned the deleted project and the server re-inserted the row I had just deleted.POST /api/location/reloaddid not clear it.PATCH /api/project/{projectID}with a correctedcanonicaldid, without restarting the service.Still reproduces on 2.0.18. The closed #30750 reported the same startup symptom on 1.15.11, so this looks like a regression or an unfixed path rather than a one-off.
Unrelated aside noticed while investigating:
~/.local/share/opencode/log/opencode.loghas no rotation or size bound — it reached 47 MB in about two days.(Consolidating my duplicate report #51465 into this issue.)
neriousy commentedon Oct 20, 2026
Thanks for the report and the detailed investigation. We're tracking this same failure when a project's directory has been deleted in #50137, so I'm closing this as a duplicate. Please follow that issue for updates.