Skip to content

opencode web does not inherit terminal's current working directory #35326

Closed as not planned

Description

@Zhentao-He

Description

When starting opencode web from a terminal, the working directory should default to the terminal's current working directory (where the command was invoked). However, it currently defaults to the system root / instead.

Plugins

No response

OpenCode version

1.17.13

Steps to reproduce

  1. cd /Users/zhentao/Desktop/AI/Opencode
  2. Run opencode web

The app's working directory is / instead of the project directory
Expected behavior: opencode web should inherit $PWD from the shell session where it was launched.

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. github-actions commented on Jul 4, 2026

    @github-actions
    Contributor

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

  2. Zhentao-He commented on Jul 5, 2026

    @Zhentao-He
    Author

    I chat with deepseek v4 flash, and it finds that
    Root Cause:

    1. The web and serve commands set instance: false in effectCmd, which skips all directory resolution logic that the tui and run commands use.
    2. The TUI command explicitly calls process.chdir() using process.env.PWD (the shell's original CWD), but web/serve do not.
    3. When the web frontend makes API requests without a directory param or x-opencode-directory header, the server falls back to process.cwd(), which is / if the process was started from a GUI or service manager.
  3. ninetyfive666 commented on Jul 6, 2026

    @ninetyfive666

    Same for me on Fedora KDE 44 with opencode installed via curl.

  4. airvzxf commented on Jul 8, 2026

    @airvzxf

    Submitted PR #35976 with the fix (rebase of the previously auto-closed #31473, with the conflict in core/project.ts resolved against the current git.repo.discover API). Awaiting review from a maintainer.

  5. github-actions commented on Sep 7, 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