opencode: Error: Unexpected error, check log file at

INFO  2025-06-25T09:09:30 +45ms service=default version=0.1.133 args=run,Explain,the,use,of,context,in,Go opencode
INFO  2025-06-25T09:09:30 +1ms service=app cwd=/Users/zheng-cheng/Documents/MiraclePlus/mp creating
INFO  2025-06-25T09:09:30 +6ms service=app git=/Users/zheng-cheng/Documents/MiraclePlus/mp git
INFO  2025-06-25T09:09:30 +2ms service=app name=share registering service
INFO  2025-06-25T09:09:30 +0ms service=bus type=storage.write subscribing
INFO  2025-06-25T09:09:30 +0ms service=app name=bus registering service
INFO  2025-06-25T09:09:30 +2ms service=session id=ses_859a6870affe2vKYl9mgW0nV1P version=0.1.133 title=New Session - 2025-06-25T09:09:30.998Z time=[object Object] created
INFO  2025-06-25T09:09:30 +0ms service=app name=session registering service
INFO  2025-06-25T09:09:30 +0ms service=app name=storage registering service
INFO  2025-06-25T09:09:30 +0ms service=storage path=/Users/zheng-cheng/.local/share/opencode/project/Users-zheng-cheng-Documents-MiraclePlus-mp/storage init
INFO  2025-06-25T09:09:30 +1ms service=bus type=storage.write publishing
INFO  2025-06-25T09:09:30 +0ms service=app name=config registering service
INFO  2025-06-25T09:09:31 +2ms service=config loaded
INFO  2025-06-25T09:09:31 +0ms service=bus type=session.updated publishing
INFO  2025-06-25T09:09:31 +0ms service=app name=provider registering service
INFO  2025-06-25T09:09:31 +2ms service=models.dev refreshing
INFO  2025-06-25T09:09:31 +1ms service=provider init
ERROR 2025-06-25T09:09:31 +14ms service=default fatal
Image

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 3
  • Comments: 19 (5 by maintainers)

Most upvoted comments

Quick fix for people running into this issue and want to continue using opencode: In the folder ~/.local/share/opencode, delete package.json or the whole folder

Example: rm -rf ~/.local/share/opencode/package.json or ~/.local/share/opencode

–

@thdxr I’ve ran this locally and located the primary issue here:

ERROR 2025-06-27T15:01:16 +2ms service=default name=ResolveMessage message=Cannot find module '/home/wmisiedjan/.cache/opencode/node_modules/@aws-sdk/credential-providers' from '/home/wmisiedjan/Projects/opencode/packages/opencode/src/provider/provider.ts' code=ERR_MODULE_NOT_FOUND specifier=/home/wmisiedjan/.cache/opencode/node_modules/@aws-sdk/credential-providers referrer=/home/wmisiedjan/Projects/opencode/packages/opencode/src/provider/provider.ts importKind=import-statement fatal

I’m preparing a PR to update error handling for these cases.

Here’s a rough analysis of actual issue. I started checking out packages/opencode/src/bun/index.ts (BunProc)'s install function, where it detects @aws-sdk/credential-providers already within the package.json file, it thus skips installation the installation. But it’s not actually installed in the node_modules folder of the cache dir.

After that, I tried always installing all packages (essentially removing the check if it’s listed in package.json), that causes issues with the BunProc’s run, function because how we read stdout and stdin is broken.

We can fix that by doing the following instead:

    const stdout = result.stdout ? typeof result.stdout === "number" ? result.stdout : await readableStreamToText(result.stdout) : undefined
    const stderr = result.stderr ? typeof result.stderr === "number" ? result.stderr : await readableStreamToText(result.stderr) : undefined

Once that is fixed, the following problem happened for me, somehow, also “amazon-bedrock” is listed for me as dependencies in the cache package.json file, but this package doesn’t exist, which causes the installation to occur:

INFO  2025-06-27T15:21:53 +2ms service=bun cmd=/home/wmisiedjan/.bun/bin/bun,install,--registry=https://registry.npmjs.org cwd=/home/wmisiedjan/.cache/opencode running
INFO  2025-06-27T15:21:53 +60ms service=bun code=1 stdout=bun install v1.2.17 (282dda62)
 stderr=Resolving dependencies
Resolved, downloaded and extracted [1]
error: GET https://registry.npmjs.org/amazon-bedrock - 404
error: amazon-bedrock@latest failed to resolve
 done
ERROR 2025-06-27T15:21:53 +1ms service=default pkg=@aws-sdk/credential-providers version=latest name=BunInstallFailedError message=BunInstallFailedError cause=Error: Command failed with exit code 1 fatal

Likely cause is in that there was some mistake in earlier versions that caused the state of the cache’s package.json to be broken, this also uncovered a couple of other bugs mentioned above.

We need strategy to how we deal with a broken package.json state / cache, e.g. automatically delete when broken state occurs, a clean command or something along those lines.

You can use --print-logs to get more info when running opencode.

Latest version is 0.1.135

Image

I am using Warp 2.0 terminal

Image

Thank you for reply! I don’t have config.json or opencode.json file