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
Renaming a project's local folder leaves stale worktree path in project DB, causing persistent 500 errors on relaunch #41420
When a project's local directory is renamed on disk (e.g. via File Explorer or mv), opencode desktop does not update the worktree column in the project table of its SQLite database (~/.local/share/opencode/opencode.db). This causes every subsequent request to /api/... and /file/... for that project to fail with a 500 Internal Server Error, since the sidecar tries to resolve a path that no longer exists.
Interestingly, the name and sandboxes columns for the project do get updated to reflect the new folder name/path, but worktree does not — leaving the row in an inconsistent state.
Steps to Reproduce
Open a project folder in opencode desktop.
Rename the folder on disk, while opencode is closed, or via an external tool.
Reopen opencode and try to access the renamed project (either via a restored tab/session, or by opening the new folder path).
Expected Behavior
opencode should either:
Detect that the worktree path no longer exists and prompt the user to relink/reselect the folder, or
Correctly update the worktree value when the project is reopened at its new location (consistent with how name/sandboxes already get updated).
Actual Behavior
Requests to GET /file?path=&directory=<old_path> and /api/... fail with 500 Internal Server Error.
Renderer console shows repeated errors like: PlatformError: NotFound: FileSystem.realPath, [cause]: Error: ENOENT: no such file or directory, lstat
This happens even after fully quitting and relaunching the app, since the stale path is persisted, not just cached in memory.
Root Cause (found via manual DB inspection)
In ~/.local/share/opencode/opencode.db, table project:
The row for the renamed project has name and sandboxes updated to the new path, but worktree still contains the old, deleted path:
SELECT id, worktree, name, sandboxes FROM project WHERE id ='<project_id>';
-- worktree: C:/project-name (stale)-- name: project-name1 (updated)-- sandboxes: ["C:/project-name1"] (updated)
Additionally, stale references to the old path were found in several other places that also needed manual cleanup before the fix took full effect:
Electron store files (opencode.global.dat, opencode.window.<id>.dat in %APPDATA%\ai.opencode.desktop\) — server.projects, layout.home.selection.directory, tabs.info[].directory, etc.
These didn't cause the 500s directly, but did cause stale tabs/sessions to keep attempting to reopen the old path on launch.
Activity
github-actions commentedon Aug 9, 2026
This issue might be a duplicate of existing issues. Please check:
project.worktreeafter project folder is renamed on disk; remote clients keep reopening the dead path #35240: Server keeps staleproject.worktreeafter project folder is renamed on disk; remote clients keep reopening the dead pathopencode -cfails with "Unexpected server error" after project directory is renamed/deleted #40677:opencode -cfails with "Unexpected server error" after project directory is renamed/deletedPlease review the above issues to see if your report is already covered before this is triaged further.
Hona commentedon Sep 2, 2026
Fixed for opencode2 launch via #46713
You can try the desktop beta here: https://github.com/anomalyco/opencode-beta