Skip to content

Desktop App sends UNC paths to WSL-hosted server, breaking all bash tool calls [WORKAROUND ✅ ] #19473

Closed as not planned

Description

@am-diff

Description

When the OpenCode Desktop App (Windows) connects to an OpenCode server running inside WSL2, the project widget stores Windows UNC paths (\\wsl.localhost\Debian) in opencode.global.dat. The server concatenates this with its own CWD, producing a non-existent path that breaks all bash tool calls with a misleading error.

First — compliments to the team for considering and implementing the Windows + WSL use-case. The ability to run the server in WSL and connect from the Desktop App on Windows is genuinely useful and appreciated.

Error message:

ENOENT: no such file or directory, posix_spawn '/bin/bash'

/bin/bash exists. The real failure is that posix_spawn cannot chdir to the non-existent mangled working directory before spawning the process, and reports ENOENT against the executable path instead.

How the path gets mangled:

  1. OpenCode server launched from /home/me/OpenCode/ via opencode serve --hostname 0.0.0.0 --port 4096
  2. Desktop App connects to http://localhost:4096
  3. Desktop App sends the project widget value \\wsl.localhost\Debian as the session directory
  4. Server resolves it relative to its CWD: /home/me/OpenCode + \\wsl.localhost\Debian = /home/me/OpenCode/\\wsl.localhost\Debian
  5. This becomes the default workdir for all tool calls in the session
  6. Bash calls without explicit workdir fail because the directory doesn't exist

Server log evidence (~/.local/share/opencode/log/):

service=default directory=/home/me/OpenCode creating instance
service=default directory=/home/me/OpenCode/\\wsl.localhost\Debian\home\me\Projects\... creating instance
service=default directory=/home/me/OpenCode/\\wsl.localhost\Debian creating instance

Desktop App state file (%APPDATA%\ai.opencode.desktop\opencode.global.dat):

{
  "projects": {
    "local": [{ "worktree": "\\\\wsl.localhost\\Debian", "expanded": true }]
  },
  "lastProject": { "local": "\\\\wsl.localhost\\Debian" }
}

Note: this file uses stringified JSON inside JSON — top-level keys map to string values that are themselves JSON.

Session database (~/.local/share/opencode/opencode.db) persists the mangled paths:

directory=/home/me/OpenCode/\\wsl.localhost\Debian

Additional observations:

  • Launching the server from ~/ causes worse mangling: /home/me/\\wsl.localhost\Debian\home\me\...
  • A dedicated ~/OpenCode/ directory was created as a workaround

Suggested fixes:

Server-side:

  • Detect UNC paths on Linux (never valid on a Linux filesystem) and reject or auto-translate \\wsl.localhost\<distro>\... to /...
  • Fall back to server's own CWD if the resolved working directory does not exist
  • Log a clear warning instead of letting posix_spawn produce a misleading ENOENT

Desktop App:

  • Do not send raw Windows UNC paths to a Linux-hosted server
  • Translate \\wsl.localhost\<distro>\... to /... before sending

Plugins

None

OpenCode Server version

1.3.3

OpenCode Desktop version

v1.3.3

Steps to reproduce

  1. Install OpenCode Desktop on Windows
  2. Start opencode serve inside WSL2
  3. Connect the Desktop App to the WSL server
  4. Use the project widget to open \\wsl.localhost\Debian (the WSL root)
  5. Start a session and run any bash command without an explicit workdir parameter

Screenshot and/or share link

N/A — error is in server logs and tool output, not visual.

Operating System

  • Windows 10.0.26200.8037
  • WSL2 2.6.1.0 (upgrade to 2.6.3 pending)
  • WSL2 kernel 6.6.87.2-microsoft-standard-WSL2
  • Debian GNU/Linux 13 (trixie)
  • Bash 5.2.37(1)-release

Terminal

  • Windows Terminal 1.23.20211.0
  • OpenCode Desktop App 1.3.3 (installed from official instructions), connected to WSL-hosted OpenCode server 1.3.3

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 28, 2026
  2. github-actions commented on Mar 28, 2026

    @github-actions
    Contributor

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

  3. am-diff commented on Mar 29, 2026

    @am-diff
    Author

    Thanks for flagging the potential overlap. I've reviewed #17418 and these are distinct issues with different root causes and severity levels.

    #17418 is a UI regression in the project file picker — it shows Windows local paths instead of remote Linux paths when connected to a remote server. The user can't navigate to the right directory. Inconvenient, but the session itself still functions if you work around the picker.

    This issue (#19473) is a breakage in the path resolution pipeline. The Desktop App sends a raw Windows UNC path (\\wsl.localhost\Debian) to the WSL-hosted server, which concatenates it with its own CWD to produce a non-existent path like /home/me/OpenCode/\\wsl.localhost\Debian. This becomes the default workdir for all tool calls in the session. Every bash invocation fails with a misleading ENOENT. The session is non-functional.

    Key differences:

    #17418 #19473
    Symptom File picker shows wrong filesystem All tool calls fail
    Severity Inconvenience — workaround possible Breakage — session is unusable
    Root cause File picker browses local filesystem instead of remote Server concatenates UNC path with Linux CWD, producing an invalid path
    Project picker Shows wrong paths I used the project picker once; interacting with it breaks shell integration (this bug)

    The fix areas are also different: #17418 needs the file picker to query the remote filesystem. This issue needs the server to either reject or translate UNC paths on Linux, and the Desktop App to not send them to a Linux-hosted server in the first place.

  4. SsparKluo commented on Apr 5, 2026

    @SsparKluo

    Also met this problem, and currently you can enable mdns and mdns-domain (by --mdns --mdns-domain), and connect the wsl2 server those the mdns-domain (instead of localhost) to bypass the issue.

  5. am-diff commented on Apr 6, 2026

    @am-diff
    Author

    @SsparKluo this is great, thanks for sharing. Requires mirrored networking in WSL2.

  6. changed the title [-]Desktop App sends UNC paths to WSL-hosted server, breaking all bash tool calls[/-] [+]Desktop App sends UNC paths to WSL-hosted server, breaking all bash tool calls [WORKAROUND ✅ ][/+] on Apr 6, 2026
  7. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  8. Bilge commented on May 22, 2026

    @Bilge

    I also have this issue but do not understand the workaround at all. How do you work around it?

  9. snarkipus commented on Jun 13, 2026

    @snarkipus

    I also have this issue but do not understand the workaround at all. How do you work around it?

    Workaround (v1.17.5)

    opencode serve \
      --hostname 0.0.0.0 \
      --port 4096 \
      --mdns \
      --mdns-domain mywsldev.local
  10. romanilyin commented on Jun 27, 2026

    @romanilyin

    This appears to share the same server-boundary failure described in #33107: a Windows/UNC path is treated as relative by the POSIX server.

    The first PR (#34256) rejects that path before instance loading with a clear 400. Explicit UNC-to-WSL translation is intentionally out of scope until the client/server path relationship is known.

  11. am-diff commented on Jul 1, 2026

    @am-diff
    Author

    @SsparKluo this is great, thanks for sharing. Requires mirrored networking in WSL2.

    Clarifying my previous response. Does not require mirrored networking in .wslconfig; mirrored was required on only one machine, since then I've been using nat on a few other machines.

  12. github-actions commented on Aug 31, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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