Skip to content

opencode serve uses / as workspace root when CWD has no git repository #36858

Closed as duplicate

Description

@szymor

Description

When running opencode serve from a directory that is not a git repository (or the git discovery fails), the server reports the workspace root folder as / (filesystem root) instead of the current working directory. This causes the AI model to see all files from the entire filesystem, not just the intended project.

The root cause is in packages/core/src/project.ts:112. When no git repo is found, the fallback uses path.parse(input).root which for any absolute path like /home/user/project returns just /. The input is already a resolved absolute path and should be used directly.

Plugins

No response

OpenCode version

1.17.20

Steps to reproduce

  1. mkdir /tmp/test-project && cd /tmp/test-project
  2. opencode serve (note: directory has no git repo)
  3. Observe that the workspace root is / instead of /tmp/test-project

Screenshot and/or share link

No response

Operating System

Debian 6.12.86-1 (2026-05-08) x86_64 GNU/Linux; debian_version 13.6

Terminal

PuTTY

Activity

  1. github-actions commented on Jul 14, 2026

    @github-actions
    Contributor

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

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