anomalyco / anomalyco/opencode
cli: invalid directory arg shows raw ENOENT chdir stack trace instead of friendly error
@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: disablein config - Active plugins: global MCP servers
context7,exa,kaggleenabled,chrome-devtoolsdisabled; CLI plugin./herdr-opencode; no project-localopencode.json(c)found
Reproduction
- Open a shell in a directory without a
./lsentry (e.g.~). - Run
opencode ls. - Observe the error output.
- Same result with
opencode foobar123andopencode /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 --helplists subcommands:upgrade, uninstall, acp, api, debug, auth, mcp, plugin, models, stats, mini, run, session, service, reload, pair, serve.- Workaround: run
opencode --helpto check valid subcommands; pass only existing directories as positional arg. - No secrets included; MCP API keys redacted from config.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.