You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
File paths resolved from server's cwd instead of client's cwd when using opencode attach #4966
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
Start the server from a parent directory:
cd~/Development
opencode
From another terminal, navigate to a subdirectory and attach:
Try to reference a file that exists in the client's cwd:
@docs/report.md
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
Pass client's cwd to server on attach and use it for path resolution
Add a command like /cd or /workspace to switch the server's working directory context
Support workspace/project switching within a single server session
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.
Activity
github-actions commentedon Dec 2, 2025
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.