Skip to content

opencode attach --dir fails because it tries to change directory on the client instead of the server #8933

@nyxkrage

Description

@nyxkrage

Description

When using opencode attach with the --dir flag to connect to a remote server, the command fails because it attempts to change the directory on the local client machine rather than sending the directory path to the server.

The attach command handler calls process.chdir(args.dir) locally before connecting, which fails if the specified directory doesn't exist on the client. Even if it does exist, it passes process.cwd() as the directory to the tui function, so the resolved local path is sent to the server, which is unexpected.

Expected behavior

The --dir flag should be passed to the remote server, which resolves the path relative to where opencode serve was started.

Plugins

N/A

OpenCode version

dev @ 88fd6a2

Steps to reproduce

  1. Start opencode serve on a remote server (e.g., Linux machine in /home/user)
  2. On the remote server, ensure a project directory exists (e.g., my-project)
  3. From a local machine (e.g., macOS), run opencode attach http://:4096 --dir my-project
  4. Observe the error: ENOENT: no such file or directory, chdir '' -> 'my-project'

Screenshot and/or share link

No response

Operating System

N/A

Terminal

N/A

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions