Skip to content

Desktop: moving a project directory leaves stale worktree in project table — project shows "no git" and all prompts fail with ENOENT #46330

Closed

Description

@Anyeler

Environment

  • opencode Desktop 1.18.25 (macOS, Apple Silicon)
  • Data dir: ~/.local/share/opencode (server sidecar SQLite opencode.db), Desktop state in ~/Library/Application Support/ai.opencode.desktop/

What happened

I moved a project directory from:
~/Projects/scripts/java/brand-portal-system → ~/Projects/scripts/java/brand-portal/brand-portal-system

After the move, opening that project in Desktop showed no git and every prompt failed silently (no response in the UI). All other projects kept working. Server log (~/.local/share/opencode/log/opencode.log) showed repeated:

level=ERROR message="prompt_async failed" cause="Cause([Die(PlatformError: NotFound:
FileSystem.realPath (/Users/.../brand-portal-system)
(cause: Error: ENOENT: no such file or directory, lstat '/Users/.../brand-portal-system'))])"

Root cause

The move-migration path is only half-complete in opencode.db:

  • project.id (root-commit based, stable across moves — good) was reused.
  • project_directory rows and new sessions correctly pointed at the new path.
  • But project.worktree still contained the old path, and the Desktop project list resolves/opens projects via that column → it tries to open a directory that no longer exists → ENOENT, "no git", dead prompts.

Because the server DB is the source of truth, cleaning Desktop-side state (opencode.global.dat, opencode.window.*.dat, Electron caches) does not help — the stale entry is re-synced back on every launch.

Repro

  1. Add a git project to Desktop, use it normally.
  2. Quit Desktop; mv the project directory elsewhere.
  3. Relaunch Desktop and open the project from the list.

Expected

project.worktree should be updated when the directory move is detected (the migration already touches project_directory/sessions), or the Desktop should resolve the project through project_directory instead of the stale worktree.

Workaround (for anyone hitting this)

Quit Desktop, then:

-- ~/.local/share/opencode/opencode.db
UPDATE project SET worktree='<new-path>' WHERE id='<project-id>';

then reset the stale tabs in ~/Library/Application Support/ai.opencode.desktop/opencode.window.*.dat and clear Cache/ + Code Cache/. Relaunch — project, git detection and full session history are restored.

Activity

  1. github-actions commented on Aug 31, 2026

    @github-actions
    Contributor

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

  2. Anyeler commented on Aug 31, 2026

    @Anyeler
    Author

    Additional detail that narrows the reproduction: closing the project in Desktop and re-opening the directory at its new path does not recover either.

    As far as I can tell this is because Project.fromDirectory resolves the project via the stable id cached in .git/opencode. Opening the new path hits that cache, resolves to the existing project row, and returns it with its stale worktree (old path) — so the freshly re-added project maps straight back to the broken row and keeps failing with the same ENOENT. There is no UI-only path to recovery; the stale worktree column has to be corrected (or the row removed) in the DB.

    So the move-migration gap is: id resolution and project_directory/sessions get updated/reused on a move, but project.worktree never does, and it's the column the Desktop uses to open the repo.

  3. 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

  4. seiji142 commented on Oct 15, 2026

    @seiji142

    Same symptom on Windows (Desktop, moved folder one level deeper). Log shows the same FileSystem.realPath + ENOENT, plus one extra evidence I didn't see mentioned: opening the new folder boots two instances seconds apart (new path + stale path), so the dead reference is consulted even on fresh opens — deleting dead sessions alone loops forever.

    Workaround that worked here (reversible, no data loss): create a directory junction old-path → new-path (New-Item -ItemType Junction). Every stale reference (tabs, sidebar entry, sessions) resolves again; explorer lists, prompts work. Rollback: rmdir the link. OneDrive didn't complain in my case.

    Side findings: in opencode.global.dat the stale paths use four backslashes (double-nested JSON) — patterns with two match nothing; and project_directory already pointed at the new path, so the stale source is the frontend/window state, not the server DB mapping.

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