anomalyco / anomalyco/opencode
[Bug]: Re-opening moved/renamed project fails with PlatformError: NotFound: FileSystem.realPath (stale project.worktree in opencode.db)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
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'))])"
Screenshot and/or share link
Similar issue to this: https://github.com/anomalyco/opencode/issues/48349
Operating System
Windows 11 (latest)
Terminal
powershell
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how project_directory, the root worktree, and active sessions are persisted and refreshed in opencode.db, then reproduce the move-and-reopen flow on Windows. Done means reopening the project at its new location updates the stale worktree and sessions so prompts and file operations no longer resolve the old path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100