Skip to content

File paths resolved from server's cwd instead of client's cwd when using opencode attach #4966

Closed as not planned

Description

@ZergRocks

Description

When running opencode server in one directory and using opencode attach from a different directory, file references (using @ syntax) are resolved relative to the server's working directory instead of the client's current working directory.

This makes it difficult to work with multiple projects while running a single server instance.

Steps to reproduce

  1. Start the server from a parent directory:

    cd ~/Development
    opencode
  2. From another terminal, navigate to a subdirectory and attach:

    cd ~/Development/saturdays/saturdays
    opencode attach
  3. Try to reference a file that exists in the client's cwd:

    @docs/report.md
    
  4. Server throws ENOENT because it looks for the file at ~/Development/docs/report.md instead of ~/Development/saturdays/saturdays/docs/report.md

Error

ENOENT: no such file or directory, stat '/Users/an/Development/saturdays/saturdays/docs/1_report.md'
    path: "/Users/an/Development/saturdays/saturdays/docs/1_report.md",
 syscall: "stat",
   errno: -2,
    code: "ENOENT"

Expected behavior

When using opencode attach, the client should pass its current working directory to the server, and file paths should be resolved relative to the client's cwd (or allow switching workspace context).

Use case

Running a single OpenCode server instance and attaching from different project directories without needing to restart the server or use absolute paths for every file reference.

Possible solutions

  1. Pass client's cwd to server on attach and use it for path resolution
  2. Add a command like /cd or /workspace to switch the server's working directory context
  3. Support workspace/project switching within a single server session

Related

Environment

  • OpenCode version: 1.0.x
  • OS: macOS
  • Terminal: Any

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Dec 2, 2025
  2. github-actions commented on Dec 2, 2025

    @github-actions
    Contributor

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

    Both issues describe the same root problem: file paths are resolved relative to the wrong working directory context (server's cwd instead of client's cwd) when using remote/attach scenarios. While #4686 specifically addresses Windows→Linux remote connections, the underlying path resolution logic is shared.

    Feel free to ignore if your specific case differs from the existing issues.

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

    opentuiThis relates to changes in v1.0, now that opencode uses opentui

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions