Skip to content

opencode web on Windows resolves working directory to drive root instead of CWD #26966

Closed as not planned

Description

@SakuraNeko

Description

On Windows, when running opencode web from a directory (e.g. C:\Users\Sakura), the backend server resolves the working directory to the drive root (C:) instead of the actual current working directory. This causes the agent to be unable to access project files and incorrectly sets Working directory: C:.

Notably, the TUI mode (opencode without arguments) does not have this issue — it correctly picks up the current working directory. The bug is specific to opencode web mode.

Expected behavior:

opencode web should use the current working directory where the command was launched, same as the TUI mode does.

Plugins

Non

OpenCode version

1.14.41

Steps to reproduce

  1. On Windows, open a terminal (PowerShell & CMD).
  2. Navigate to a directory: cd C:\Users\Sakura
  3. Run opencode web
  4. Open the web interface at the displayed URL and check the working directory in the session — it will show C:\ instead of C:\Users\Sakura.
  5. For comparison, run opencode (TUI mode) from the same directory — the working directory is correctly C:\Users\Sakura.

Screenshot and/or share link

Image

Operating System

Windows 11 25H2 (26200.8246)

Terminal

Windows Terminal (PowerShell & CMD)

Activity

  1. github-actions commented on May 12, 2026

    @github-actions
    Contributor

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

    If your issue is distinct from the above, feel free to add details clarifying the difference.

  2. francesco-arca commented on Jun 25, 2026

    @francesco-arca

    Same issue on Linux (Docker container). The server is started via opencode web --hostname 0.0.0.0 --port 8080 from /home/ubuntu/workspace (confirmed via working_dir, WORKDIR, and cd ... && exec in CMD), but agent sessions spawn with cwd=/:

    message="creating session" id=pty_... cmd=/usr/bin/bash args="[\"-l\"]" cwd=/
    

    This has two additional consequences beyond the incorrect working directory display:

    1. Project-level skills in .opencode/skills/<name>/SKILL.md are not discovered — OpenCode walks up from CWD to find them, but since CWD is /, they're never found. Only global ~/.config/opencode/skills/ works. Workaround: symlink ~/.config/opencode/skills → /path/to/project/.opencode/skills.

    2. "Create Git repository" button always shown in the web UI — because /.git doesn't exist, even though /home/ubuntu/workspace/.git is a valid git repo.

    The OPENCODE_PROJECT_ROOT=/home/ubuntu/workspace environment variable is set but appears to be unused by the server for CWD resolution. A --dir flag (as proposed in #31473) or respecting OPENCODE_PROJECT_ROOT would resolve all three symptoms.

    Tested on OpenCode 1.17.11, Ubuntu 26.04 container (Docker Desktop on Windows 11 25H2 Professional host).

  3. github-actions commented on Aug 25, 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