Skip to content

desktop: a moved or deleted project directory makes every directory-scoped API endpoint return 500 with no in-app recovery #51465

Closed as duplicate

Description

@alecgib77

Description

The desktop app becomes unusable if its current project directory is moved or deleted. Every directory-scoped API endpoint returns HTTP 500, and the renderer dies during startup with "Échec de la requête au serveur — Le serveur a renvoyé une réponse HTTP 500".

The bundled service itself is healthy (GET /api/info → 200). Server log, role=server:

cause="PlatformError: NotFound: FileSystem.realPath (<old path>)
  [cause]: Error: ENOENT: no such file or directory, lstat '<old path>'"
  http.method=GET http.url=/api/skill http.status=500

Endpoints returning 500: /api/skill, /api/mcp, /api/plugin, /api/provider, /api/model, /api/integration, /api/location. The same call with x-opencode-directory pointing at an existing directory returns 200, so the failure is purely path resolution:

GET /api/skill  x-opencode-directory: <old path>          -> 500
GET /api/skill  x-opencode-directory: <existing path>     -> 200

The error screen offers only Restart, which re-reads the same stale directory and fails identically, so there is no way out from the UI.

Plugins

None declared in ~/.config/opencode/opencode.jsonc.

OpenCode version

2.0.18 (desktop app, with its bundled opencode-cli serve --service)

Steps to reproduce

  1. In the desktop app, open a folder as a project, e.g. $HOME/Documents/Default Project, and use it (one session is enough).
  2. Quit the app.
  3. mv "$HOME/Documents/Default Project" "$HOME/Documents/OpenCode/Default Project"
  4. Launch the app again.

Screenshot and/or share link

Full-window error screen: an "OpenCode" wordmark, the heading "Échec de la requête au serveur", the subtext "Le serveur a renvoyé une réponse HTTP 500", a collapsed stack trace (ClientError: UnexpectedStatus: 500), then the buttons "Redémarrer", "Exporter les journaux" and "Signaler l'erreur".

Operating System

macOS 26 (Darwin 25.6.0, arm64)

Terminal

Not applicable — desktop app (Electron). Shell: /bin/zsh.

Additional context

Same root cause as #50548 (FileSystem service resolving the location directory with realPath(...).pipe(Effect.orDie)) — still present in 2.0.18. Same startup symptom as #30750 (closed, 1.15.11) and same stale-worktree behaviour as #35240 (closed, where clearing client state did not help because the client re-learns the dead path from the server).

Two places persist the dead path and nothing in the product exposes them:

  1. Client state, ~/Library/Application Support/ai.opencode.desktop/drafts.sqlite, table state, document opencode.global.dat: layout.home.selection.directory is what makes startup fatal; server.projects.local[].worktree keeps the dead project in the sidebar.
  2. Server database, ~/.local/share/opencode/opencode.db: project.worktree (and session.directory / session_v2.directory for existing sessions in that project).

Correcting both files while the service is running is not sufficient: GET /api/project still returned the removed project and the server re-inserted the row that had just been deleted, and POST /api/location/reload did not clear it. PATCH /api/project/{projectID} with the new canonical did fix it without a service restart. A full recovery needs the two files edited and the service restarted.

Expected instead: treat a missing project directory as a normal condition and fall back to a valid location, or at least name the missing path in a recoverable message.

Secondary: ~/.local/share/opencode/log/opencode.log has no rotation or size bound — 47 MB in about two days.

Logs above are redacted of prompts, file contents, credentials and absolute paths containing a username.

Activity

  1. added
    needs:complianceThis means the issue will auto-close after 2 hours.
    and removed
    needs:complianceThis means the issue will auto-close after 2 hours.
    on Sep 26, 2026
  2. github-actions commented on Sep 26, 2026

    @github-actions
    Contributor

    Thanks for updating the issue with a clear description, reproduction steps, and system information!

  3. alecgib77 commented on Sep 26, 2026

    @alecgib77
    Author

    Consolidated into #50548, which is open, already identifies the root cause (fs.realPath(...).pipe(Effect.orDie) in packages/core/src/filesystem.ts) and proposes a fix.

    I've moved the details that were not already there into that thread: #50548 (comment)

    Closing this as a duplicate so the same defect isn't split across two reports. The full analysis also lives in the thread above, including why the fs.resolve fix alone won't stop the client from reopening the dead path.

  4. Chudesnov commented on Nov 7, 2026

    @Chudesnov

    Related data point: POST /api/location/reload — the documented recovery path — returns 503 (FileSystem.DirectoryNotFoundError) when any loaded location's directory has been moved or deleted, aborting the rebuild while a phantom path is loaded. The still-valid locations were disposed before the error surfaced, but the endpoint can't complete. Desktop 2.2.6 service, Windows 11.

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