anomalyco / anomalyco/opencode

web: 'opencode web' crashes on headless Linux (ENOENT: xdg-open not found)

Open
#49,446 1 comment 0 reactions 1 assignee View on GitHub

@Hona is already working on this.

Since Sep 17, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Bug

Running opencode web on a headless Linux environment (e.g. a GitHub Codespace / container without a desktop) starts the server, prints the banner, then crashes because it tries to auto-open a browser via xdg-open, which does not exist in the container.

Repro

In a mcr.microsoft.com/devcontainers/base:ubuntu codespace (no xdg-utils installed):

$ opencode web --port 3000 --hostname 0.0.0.0
!  OPENCODE_SERVER_PASSWORD is not set; server is unsecured.

  █▀▀█ █▀▀█ █▀▀█ █▀▀▄ █▀▀▀ █▀▀█ █▀▀█ █▀▀█
  █  █ █  █ █▀▀▀ █  █ █    █  █ █  █ █▀▀▀
  ▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀  ▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀

  Local access:       http://localhost:3000
  Network access:     http://10.0.0.99:3000
error: Executable not found in $PATH: "xdg-open"
      path: "xdg-open",
     errno: -2,
   syscall: "spawn xdg-open",
 spawnargs: [ "http://localhost:3000" ],
      code: "ENOENT"

The whole process exits (exit code 1), taking the web server down with it. The server itself started fine (port responds 200 before the crash).

Expected

  • The server should keep running; opening a browser is a convenience, not a requirement.
  • In headless environments (no DISPLAY/WAYLAND_DISPLAY, or no xdg-open binary), it should skip auto-open gracefully (log a warning) instead of crashing.
  • Bonus: a --no-open/--dont-open flag would help scripts/containers.

Workaround (current)

Install xdg-utils in the container (apt-get install -y xdg-utils) so xdg-open exists.

Env

  • opencode 1.18.31 (also affects latest)
  • Ubuntu 24.04 devcontainer, headless

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.