Skip to content

Windows: TUI silently starts in $HOME when cwd is on a mapped drive whose share root is unreadable (realPath EPERM) #63307

Open

Description

@geblu

Description

Environment

  • Windows 10 Pro 19045
  • opencode 2.2.7 (works on 2.2.1)
  • Project: Z:\work\repos\sample-project, where Z: -> \FILESRV\HomeShare\username (corporate home share)
  • The share root \FILESRV\HomeShare is intentionally not readable by the user

Steps

  1. Map Z: to \FILESRV\HomeShare\username
  2. cd into any directory below Z: and run opencode

Actual (2.2.7)

  • GET /api/fs/list at startup returns 500:
    FileSystem.DirectoryAccessDeniedError: Access denied to directory: Z:\work\repos\sample-project
    [cause] PlatformError: PermissionDenied: FileSystem.realPath (Z:\work\repos\sample-project)
    [cause] Error: EPERM: operation not permitted, realpath 'Z:\work\repos\sample-project'
  • The TUI then boots in C:\Users<user> instead of the requested directory (silent fallback)
  • opencode --standalone aborts: ClientError: UnexpectedStatus: 500
  • Same on 2.2.1? No: 2.2.1 boots the same directory fine

Why it is not an ACL/reparse problem on the target

  • fsutil reparsepoint query "Z:\work\repos\sample-project" -> not a reparse point
  • icacls "Z:\work\repos\sample-project" -> inherited full control for the user
  • node -e "fs.realpathSync('Z:\\work\\repos\\sample-project')" -> succeeds
  • Control: opencode session list works from M: (\FILESRV\Public, readable share root)
  • opencode session list fails from Z: and also from W: mapped deeper (W: -> \FILESRV\HomeShare\username\work, project W:\repos\sample-project), i.e. the failure follows the share, not the path depth
  • Starting from a sibling project on the same drive (Z:\work\repos\other-project) fails the same way

Expected

  • The requested location should be used; a PermissionDenied from realPath should be treated like NotFound (non-fatal), at minimum when establishing the startup location
  • Do not silently fall back to $HOME

Related: #17749, #52458 (macOS equivalent), Kilo-Org/kilocode#9140 (Bun realpath walks UNC parents).

Plugins

none

OpenCode version

opencode 2.2.7 (works on 2.2.1)

Steps to reproduce

No response

Screenshot

No response

Operating System

Windows 10 Pro 19045

Terminal

WezTerm

Activity

  1. opencodejr commented on Nov 11, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report and the diagnostics you already ran. I can't reproduce this in our sandbox: it needs Windows with an SMB share whose root you can't read, mapped to a drive letter, and the sandbox only runs Linux. So this needs a maintainer with a Windows setup.

    From the code: when OpenCode opens a directory, it calls realPath on it and treats a permission-denied error as fatal. That logic is the same in 2.2.1 and 2.2.7, so the change you're seeing probably comes from how realPath itself works on Windows in 2.2.7. One possible cause, not yet confirmed, is a dependency upgrade (#60651). It may have made realPath check the share root above your mapped folder, which you can't read.

    Related issues, most relevant first:

  2. Emmanuel-Develops commented on Nov 13, 2026

    @Emmanuel-Develops

    Same silent fallback on macOS, so adding a data point — this isn't Windows-specific.

    Environment

    • opencode 2.3.0, macOS 15.5 (24F74), arm64
    • TUI launched from the VS Code integrated terminal (TERM_PROGRAM=vscode) in ~/Desktop/dev/<project>
    • The OpenCode desktop app was also running, so the TUI connected to its shared service:
      .../ai.opencode.desktop/cli/2.3.0-arm64/opencode-cli serve --service, whose parent is
      /Applications/OpenCode.app/Contents/MacOS/OpenCode

    Actual behavior

    1. Typing @ in the prompt lists my home-directory files instead of the project files.
    2. GET /api/debug/location returns [{"directory":"/Users/me"}, ...]; the project location never appears.
    3. GET /api/fs/list for the launch directory returns 500 (198 times between 11:52 and 12:11 UTC):
    cause="FileSystem.DirectoryAccessDeniedError: Access denied to directory: /Users/me/Desktop/dev/<project>
      [cause]: PlatformError: PermissionDenied: FileSystem.realPath (/Users/me/Desktop/dev/<project>)
        [cause]: Error: EPERM: operation not permitted, lstat '/Users/me/Desktop/dev/<project>'"
    http.method=GET http.url=/api/fs/list http.status=500
    
    1. No error is shown in the TUI. The session is created with directory=/Users/me, so it starts in $HOME.

    Cause in my case
    The folder is under ~/Desktop, which macOS protects with TCC. The shared server is a child of OpenCode.app, so it inherits that app's privacy grants, and this folder was never granted. The TUI process itself has cwd set to the project and its terminal can read it; only the server can't.

    Impact
    Same as the report, different trigger: location boot fails and the TUI silently continues in $HOME, so @ searches home instead of the project. It also doesn't recover later — every request for the project location keeps 500ing while the UI gives no indication that the launch directory was rejected.

    Suggestions

    1. Don't fall back when the requested location fails to boot; surface the typed error and keep the session in an error/retry state. This is the server side of desktop: missing or inaccessible project folder breaks project requests #50951, addressed by fix(server): report blocked location folders as 403 #60510 / fix(server): return 403 when listing an unreadable directory #61225 for fs/list.
    2. Name the process/app that owns the service in that error, since access is granted per responsible app for a shared service.
    3. Offer --standalone (or a server per location) at the point of failure, because a private server inherits the terminal's permissions.

    Confirmed workaround: running the TUI with opencode --standalone from the same project works — the private server inherits the terminal's permissions and reads the folder. Granting the desktop app Full Disk Access and restarting the service is the alternative for keeping the shared service.

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

Metadata

Metadata

Assignees

No one assigned

    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