opencode attach: File path duplicates client's relative directory, causing ENOENT #3242

Open
opened 2026-02-16 17:39:17 -05:00 by yindo · 2 comments
Owner

Originally created by @ZergRocks on GitHub (Dec 1, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

When using opencode attach from a subdirectory of the server's workspace, file references using @ syntax cause the client's relative path to be duplicated in the final resolved path.

Steps to reproduce

  1. Start the server from a parent directory:

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

    cd ~/Development/saturdays
    opencode attach http://localhost:9999
    
  3. Reference a file using @ that exists in ~/Development/saturdays/docs/:

    @docs/report.md
    
  4. Server throws ENOENT with a duplicated path:

    ENOENT: no such file or directory, stat '/Users/an/Development/saturdays/saturdays/docs/report.md'
    

Expected behavior

The file should be resolved to:

/Users/an/Development/saturdays/docs/report.md

Actual behavior

The path becomes:

/Users/an/Development/saturdays/saturdays/docs/report.md

The subdirectory saturdays appears twice - once from the client's cwd context and once from the path resolution.

Environment

  • OpenCode version: 1.0.126
  • OS: macOS
  • Server location: ~/Development (via opencode serve --port 9999)
  • Client attach location: ~/Development/saturdays (via opencode attach http://localhost:9999)
Originally created by @ZergRocks on GitHub (Dec 1, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description When using `opencode attach` from a subdirectory of the server's workspace, file references using `@` syntax cause the client's relative path to be **duplicated** in the final resolved path. ### Steps to reproduce 1. Start the server from a parent directory: ```bash cd ~/Development opencode serve --port 9999 ``` 2. From another terminal, navigate to a subdirectory and attach: ```bash cd ~/Development/saturdays opencode attach http://localhost:9999 ``` 3. Reference a file using `@` that exists in `~/Development/saturdays/docs/`: ``` @docs/report.md ``` 4. Server throws ENOENT with a **duplicated path**: ``` ENOENT: no such file or directory, stat '/Users/an/Development/saturdays/saturdays/docs/report.md' ``` ### Expected behavior The file should be resolved to: ``` /Users/an/Development/saturdays/docs/report.md ``` ### Actual behavior The path becomes: ``` /Users/an/Development/saturdays/saturdays/docs/report.md ``` The subdirectory `saturdays` appears twice - once from the client's cwd context and once from the path resolution. ### Environment - **OpenCode version**: 1.0.126 - **OS**: macOS - **Server location**: `~/Development` (via `opencode serve --port 9999`) - **Client attach location**: `~/Development/saturdays` (via `opencode attach http://localhost:9999`)
yindo added the opentui label 2026-02-16 17:39:17 -05:00
Author
Owner

@rekram1-node commented on GitHub (Dec 1, 2025):

good find we will fix

@rekram1-node commented on GitHub (Dec 1, 2025): good find we will fix
Author
Owner

@oussamadouhou commented on GitHub (Dec 29, 2025):

PR #6413 fixes --dir parameter handling by sending x-opencode-directory header to the server. This should prevent path duplication when attaching from subdirectories.

@oussamadouhou commented on GitHub (Dec 29, 2025): PR #6413 fixes `--dir` parameter handling by sending `x-opencode-directory` header to the server. This should prevent path duplication when attaching from subdirectories.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3242