Infinite installation loop of @aws-sdk/credential-providers on startup when AWS_BEARER_TOKEN_BEDROCK is set
Description
OpenCode hangs on startup when the AWS_BEARER_TOKEN_BEDROCK environment variable is set. It triggers a re-installation of @aws-sdk/credential-providers on every single launch, even if the package is already successfully installed.
This becomes a blocking issue if the connection to the npm registry is slow or unstable (e.g., when using a custom registry mirror like npmmirror), causing the CLI to hang indefinitely during the network request.
Verification:
I confirmed that manually modifying ~/.cache/opencode/package.json by changing the version of @aws-sdk/credential-providers from the specific version number (e.g., "3.962.0") to "latest" makes the issue disappear immediately.
Root Cause Analysis:
I investigated the source code and identified the issue in packages/opencode/src/bun/index.ts.
-
src/provider/provider.tscallsBunProc.install("@aws-sdk/credential-providers")without a version, defaulting to "latest". -
BunProc.installcompares the installed version inpackage.json(e.g., "3.962.0") against the requested version ("latest"). - Since "3.962.0" !== "latest", it forces a
bun addcommand every time, triggering unnecessary network requests.
Plugins
Default
OpenCode version
1.0.220
Steps to reproduce
- Export
AWS_BEARER_TOKEN_BEDROCK=test_tokenin your shell. - Run
opencode. - The CLI hangs during initialization.
- Running
opencode --print-logsshows it is stuck at:INFO service=bun ... installing package using Bun's default registry resolution pkg=@aws-sdk/credential-providers version=latest
Screenshot and/or share link
No response
Operating System
macOS
Terminal
iTerm2