Skip to content

CLI fails with unrecognized flag --port when launched from editor extension #49085

Closed as duplicate

Description

@uyencss

Description

When launching OpenCode from editor extensions (such as sdks/vscode/src/extension.ts which invokes opencode --port <port>), the CLI exits with:

ERROR
  Unrecognized flag: --port in command opencode

Additionally, the legacy shims in install and packages/cli/script/publish-aur.ts use exec "$(dirname "$0")/opencode" "$@". When the shim is invoked through a symlink (e.g. from ~/.local/bin or /usr/local/bin), $(dirname "$0") points to the directory containing the symlink rather than the installed binary, resulting in:

exec: .../opencode: cannot execute: No such file or directory

Steps to reproduce

  1. Run opencode --port 40879
  2. Observe Unrecognized flag: --port in command opencode
  3. Symlink opencode2 shim into ~/.local/bin/opencode2 and run opencode2
  4. Observe cannot execute: No such file or directory

OpenCode version

v2.0.3

Operating System

macOS / Linux

Activity

  1. nestorFigliuolo commented on Oct 7, 2026

    @nestorFigliuolo

    Any update on this isseu?

  2. Omar-Elmassry commented on Oct 9, 2026

    @Omar-Elmassry

    facing the same issue

  3. xxl4tomxu98 commented on Oct 12, 2026

    @xxl4tomxu98

    @nestorFigliuolo @uyencss @palmamartin @neriousy @Omar-Elmassry May I ask if this issue had been resolved? I am waiting for the resolution!!

  4. rekram1-node commented on Oct 14, 2026

    @rekram1-node
    Contributor

    Fixed in the VS Code extension v1.0.0, now on the Marketplace and Open VSX. It launches opencode without --port, so it works with the V2 CLI. Update the extension to get it.

  5. opencodejr commented on Oct 28, 2026

    @opencodejr

    Thanks for the report! I think the --port part is a duplicate of #49992, which your own PR #49084 already fixed: the VS Code extension now launches plain opencode without --port. Please update to the latest v2 release (v2.1.0 or later) and the extension should start normally.

    Possible duplicates and related issues, ordered by likelihood:

    On the opencode2 shim: the install script puts it in the same folder as the opencode binary, and it works when run from there. It only fails if you symlink it into a different folder. (packages/cli/script/publish-aur.ts has also been removed since v2.0.3.) If the shim also fails with the standard install, please say so here with the steps.

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.

  6. opencodejr commented on Oct 29, 2026

    @opencodejr

    Closing this as a duplicate of #49992, since there's been no reply in the day since the duplicate notice. The --port error from the VS Code extension was fixed by #49084, which launches plain opencode, so updating to v2.1.0 or later should fix it. If you still see the error after updating, or the opencode2 shim fails with the standard install (not symlinked elsewhere), please comment here with the steps and we can reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions