anomalyco / anomalyco/opencode

cli: invalid directory arg shows raw ENOENT chdir stack trace instead of friendly error

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

@jlongster is already working on this.

Since Sep 18, 2026.

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

Description

Summary

Running opencode <unknown-arg> treats the arg as <directory> and prints a raw ENOENT ... chdir error with an internal Bun stack trace (/$bunfs/root/chunk-*.js) instead of a friendly validation error. Exit code is still 0.

Environment

  • opencode version: 2.0.7
  • OS: Linux arch 6.18.49-3-lts #1 SMP PREEMPT_DYNAMIC Sun, 06 Sep 2026 13:22:39 +0000 x86_64 GNU/Linux
  • Terminal: TERM=xterm-256color, COLORTERM=truecolor, TERM_PROGRAM=unset
  • Shell: /bin/bash
  • Install/channel: latest (npm-opencode-cli via mise: ~/.local/share/mise/installs/npm-opencode-cli/latest), update: disable in config
  • Active plugins: global MCP servers context7, exa, kaggle enabled, chrome-devtools disabled; CLI plugin ./herdr-opencode; no project-local opencode.json(c) found

Reproduction

  1. Open a shell in a directory without a ./ls entry (e.g. ~).
  2. Run opencode ls.
  3. Observe the error output.
  4. Same result with opencode foobar123 and opencode /nonexistent-dir-xyz.

Expected Behavior

Friendly validation error such as directory 'ls' does not exist plus usage hint (opencode <subcommand> [flags] [<directory>] / opencode --help), with non-zero exit code. No internal paths in output.

Actual Behavior

Raw error log with internal stack frame, exit 0:

~ ❯ opencode ls
[08:36:57.084] ERROR (#1): Error: ENOENT: no such file or directory, chdir '/home/broto' -> 'ls'
    at chdir (unknown)
    at <anonymous> (/$bunfs/root/chunk-3vv35md2.js:96:6419)

opencode --help confirms USAGE: opencode <subcommand> [flags] [<directory>] with no ls subcommand, so the arg falls through to <directory> and fails in chdir.

Additional Context

  • Consistently reproducible (3/3 tries: ls, foobar123, /nonexistent-dir-xyz).
  • opencode --help lists subcommands: upgrade, uninstall, acp, api, debug, auth, mcp, plugin, models, stats, mini, run, session, service, reload, pair, serve.
  • Workaround: run opencode --help to check valid subcommands; pass only existing directories as positional arg.
  • No secrets included; MCP API keys redacted from config.

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.