Skip to content

Workspace working directory not updated after moving project to new location #30005

Closed

Description

@lgcenen

Description

When a project is moved from its original location to a new path (e.g., an external drive), closing the old workspace in opencode GUI and re-adding it at the new path does not update the working directory. The environment still uses the original workspace path, which no longer exists.

Steps to Reproduce

  1. Open a project at location A
  2. Move/copy the project to location B
  3. In opencode GUI, close the workspace and add location B
  4. Start a session
  5. Try to use any file system tool

Expected Behavior

The working directory should reflect the current workspace path (location B).

Actual Behavior

The environment still uses the original path (location A), causing file system tools to fail with NotFound: FileSystem.access errors.

Environment

  • macOS
  • opencode GUI

Notes

  • The workspace path is stored in the GUI's data file, but even after updating it, the working directory is fixed at process launch time.

Activity

  1. github-actions commented on May 30, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your issue is distinct (specifically around macOS external drives mounted at /Volumes/), it would be helpful to cross-reference these issues.

  2. changed the title [-]GUI sets wrong working directory when project is on external drive[/-] [+]Workspace working directory not updated after moving project to new location[/+] on May 30, 2026
  3. lgcenen commented on May 30, 2026

    @lgcenen
    Author

    Fixed in #30007

  4. nitipit commented on Jun 1, 2026

    @nitipit

    I can reproduce this on Linux with the web UI/server using opencode v1.15.13.

    After moving a project to a new base directory and reopening it from the new location, opencode still used stale path data from ~/.local/share/opencode/opencode.db:

    • project.worktree still pointed to the old missing path
    • one session.directory also pointed to the old missing path
    • project.sandboxes already contained the new path

    So opencode seems to partially detect the new location, but the UI/tool environment still relies on stale project/session paths. I saw the same pattern with another moved project too.

    Manually editing SQLite is not user-friendly. It would be helpful if the UI detected missing project paths and offered a safe "Relink" / "Refresh missing project" action that preserves sessions and updates path pointers like project.worktree and session.directory.

    Related: #27822 and #23248.

  5. wesoho commented on Jun 6, 2026

    @wesoho

    我遇到了同样的问题

  6. WhiteGiverMa commented on Jun 21, 2026

    @WhiteGiverMa

    +1 — same root cause on Windows 11 + WSL2, Desktop v1.17.9. Renamed project folder, workspace working directory never updated. Desktop keeps falling back to the old path despite all cache clearing attempts. See my detailed comment on #30697 for the full list of workarounds tried.

  7. andjelicsasa commented on Jun 26, 2026

    @andjelicsasa

    Same issue here.. Windows 11. Not sure if reinstalling OpenCode would solve the issue, but it's kind of a hassle to set everything back up. Is there a file or a location where a project can be deleted so we can open it from scratch?

    Update: I went nuclear on the cache. (WARNING) This deleted all my project's data but I didn't mind. Closed the project in OpenCode app and closed the app itself, deleted opencode file in project .git directory, deleted opencode dirs in [user]/.cache and [user]/.local. Started OpenCode app and added the project from scratch.

  8. Stf-F commented on Jul 30, 2026

    @Stf-F

    Confirmed on macOS with OpenCode Desktop 1.18.9 after renaming a Git repository and using Close
    project → Add project
    with the new path.

    Old path:

    /Users/xx/Sites/projects/content

    New path:

    /Users/xx/Sites/projects/blog

    OpenCode retained the session history, but new sessions would not launch.

    A read-only inspection of ~/.local/share/opencode/opencode.db showed:

    • project.worktree still referenced the deleted old path
    • project_directory.directory contained the correct new path
    • project.sandboxes contained the new path
    • both paths were associated with the same project ID
    • PRAGMA integrity_check returned ok

    The logs showed repeated failures resolving the deleted path:

    PlatformError: NotFound: FileSystem.realPath (...), caused by ENOENT.

    This matches the root cause described in #39056: Project.fromDirectory() retains existing.worktree
    even when that path no longer exists, while the new path is added as a sandbox. Desktop navigation then
    resolves the sandbox back to the stale primary worktree.

    This is still reproducible in 1.18.9.

  9. TheSummer001 commented on Aug 31, 2026

    @TheSummer001

    I’m experiencing what appears to be the same underlying issue, but on Windows and with a directory rename rather than moving the project to a different location.

    Reproduction:

    1. Add D:\Projects\my-project as a workspace in OpenCode.
    2. Rename the directory externally using Windows File Explorer:
      my-project → my-project-renamed
    3. The existing workspace becomes unusable.
    4. Remove the old workspace from OpenCode.
    5. Add D:\Projects\my-project-renamed as a new workspace.
    6. The newly added workspace is still unusable.
    7. Rename the directory back to my-project.
    8. The workspace immediately works again.

    So even after removing the old workspace and adding the new path, OpenCode appears to retain or resolve some state against the original path/name.

    This seems closely related to this issue, although in my case the path only changes because the directory is renamed, not moved to another location.

    Environment:

    • Windows
    • OpenCode GUI
  10. Hona commented on Sep 2, 2026

    @Hona
    Member

    Fixed for opencode2 launch via #46713
    You can try the desktop beta here: https://github.com/anomalyco/opencode-beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions