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
[Bug]: Re-opening moved/renamed project fails with PlatformError: NotFound: FileSystem.realPath (stale project.worktree in opencode.db) #49817
When a project folder on disk is moved or renamed, OpenCode continues to attempt resolving the old path. Re-opening the new directory in the UI does not refresh the project's root worktree or its active sessions in the database, resulting in a fatal FileSystem.realPath error during prompts and file operations. It only writes new path in 'project_directory' in ~/.local/share/opencode/opencode.db/opencode.db (not worktree)
Plugins
any
OpenCode version
1.18.31
Steps to reproduce
Create and open a project inside a nested directory in OpenCode (e.g., ~/projects/category-a/my-app or C:/projects/old-dir/my-app).
Close OpenCode.
Move or rename the folder structure on disk (e.g., move my-app directly to ~/projects/my-app or C:/projects/my-app, and remove old-dir).
Launch OpenCode and open the project from its new location (C:/projects/my-app).
Send any prompt or trigger an operation that requires workspace access.
Actual Behavior:
OpenCode crashes with an unhandled PlatformError because it still resolves the old path:
level=ERROR message=failed ref=err_... error="PlatformError: NotFound: FileSystem.realPath (C:/projects/old-dir/my-app) (cause: Error: ENOENT: no such file or directory, lstat 'C:\\projects\\old-dir')"
...
level=ERROR message="prompt_async failed" sessionID=ses_... cause="Cause([Die(PlatformError: NotFound: FileSystem.realPath (C:\\projects\\old-dir\\my-app) (cause: Error: ENOENT: no such file or directory, lstat 'C:\\projects\\old-dir'))])"
Run the following SQL updates (using Node.js built-in node:sqlite or any SQLite CLI):
-- 1. Update project worktree and name
UPDATE project
SET worktree = '<NEW_FULL_PATH>',
name = '<PROJECT_NAME>',
time_updated = strftime('%s', 'now') * 1000
WHERE id = '<PROJECT_ID>';
-- 2. Update existing sessions pointing to the old path
UPDATE session
SET directory = REPLACE(directory, '<OLD_PATH>', '<NEW_PATH>'),
path = REPLACE(path, '<OLD_PATH>', '<NEW_PATH>'),
time_updated = strftime('%s', 'now') * 1000
WHERE directory LIKE '%<OLD_PATH>%';
-- 3. Update session parts and event logs
UPDATE part SET data = REPLACE(data, '<OLD_PATH>', '<NEW_PATH>') WHERE data LIKE '%<OLD_PATH>%';
UPDATE event SET data = REPLACE(data, '<OLD_PATH>', '<NEW_PATH>') WHERE data LIKE '%<OLD_PATH>%';
Restart OpenCode and recreate the project with the right path
I checked the current V2 project/session paths. The project-root refresh is already implemented in #45043 and #45735: resolving a renamed repository replaces its canonical directory when the previous directory no longer exists. Existing sessions retain their own Location, so refreshing the project does not itself relocate those sessions. V2 also supports moving an idle session whose source directory is gone.
On V2 commit df51166711, the existing renamed-project and clone-preservation regressions passed (2 tests), and the missing-source session-move regression passed (1 test). This is code-level coverage; I have not reproduced the reported Windows 1.18.31 scenario.
For automatic recovery, I propose using the existing durable Session.Moved path to relocate inactive local sessions under the vanished project root to the new root, preserving their relative subdirectories. Keep live sessions and explicit workspace placements unchanged, and preserve historical parts/events rather than rewriting their text. Could you approve this scoped session-recovery approach?
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.
Activity
Rafal1 commentedon Sep 18, 2026
Workaround (Direct SQLite Database Fix):
Users can manually repair their database by updating the stale paths:
Close OpenCode.
Back up the database
Run the following SQL updates (using Node.js built-in node:sqlite or any SQLite CLI):
Restart OpenCode and recreate the project with the right path
Dante-dan commentedon Sep 30, 2026
I checked the current V2 project/session paths. The project-root refresh is already implemented in #45043 and #45735: resolving a renamed repository replaces its canonical directory when the previous directory no longer exists. Existing sessions retain their own Location, so refreshing the project does not itself relocate those sessions. V2 also supports moving an idle session whose source directory is gone.
On V2 commit
df51166711, the existing renamed-project and clone-preservation regressions passed (2 tests), and the missing-source session-move regression passed (1 test). This is code-level coverage; I have not reproduced the reported Windows 1.18.31 scenario.For automatic recovery, I propose using the existing durable
Session.Movedpath to relocate inactive local sessions under the vanished project root to the new root, preserving their relative subdirectories. Keep live sessions and explicit workspace placements unchanged, and preserve historical parts/events rather than rewriting their text. Could you approve this scoped session-recovery approach?thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊