GeezerVison is showing github.com — @npmcli/arborist in Bun runtime fails to resolve proxy env vars: proxy.url must be a non-empty string · Issue #21472 · anomalyco/opencode
@npmcli/arborist in Bun runtime fails to resolve proxy env vars: proxy.url must be a non-empty string #21472DescriptionDescription
Starting from opencode 1.4.0, the plugin installer was switched from spawning bun add as a subprocess to using @npmcli/arborist directly inside the Bun runtime. When proxy environment variables (HTTP_PROXY/HTTPS_PROXY) are set, Arborist.reify() triggers an internal fetch that crashes with:
TypeError: proxy.url must be a non-empty string
This makes all remote npm plugins fail to install on startup. The issue does not occur when:
- Running bun add or npm install as a standalone subprocess (they correctly read proxy env vars)
- No proxy env vars are set
The proxy environment is valid and functional — curl -x http://127.0.0.1:7897 https://registry.npmjs.org/ returns 200 OK. The issue is specific to Arborist running inside Bun's fetch implementation, which fails to parse the proxy variables correctly.
Root Cause Analysis
In packages/opencode/src/npm/index.ts, Npm.add() creates an Arborist instance and calls reify(), which internally uses fetch() to download packages from the npm registry. Bun's fetch() has a known issue with proxy environment variable handling — it reads the variables but fails to construct a valid proxy URL internally, resulting in the "non-empty string" error.
Regression
This is a regression from opencode 1.3.x which used service=bun (bun add subprocess) for plugin installation. The subprocess correctly inherited and used proxy env vars.
Plugins
- oh-my-openagent@latest (v3.15.3, 16 dependencies) - opencode-antigravity-auth@latest (v1.6.0) - openviking-opencode@latest (v0.3.3)
OpenCode version
v1.4.0
Steps to reproduce
- Set proxy environment variables in a WSL2 or Linux environment:
export HTTP_PROXY=http://127.0.0.1:7897
export HTTPS_PROXY=http://127.0.0.1:7897
2. Ensure proxy is reachable: curl -x http://127.0.0.1:7897 https://registry.npmjs.org/ returns 200
- Configure any remote npm plugin in ~/.config/opencode/opencode.json:
{ plugin: [some-plugin@latest] }
- Clear the plugin cache (or use a plugin not yet cached):
rm -rf ~/.cache/opencode/packages/some-plugin@latest/*
- Start opencode
- Observe error in log (~/.local/share/opencode/log/.log):
"service":"npm" error: "NpmInstallFailedError: ... cause: TypeError: proxy.url must be a non-empty string"
Screenshot and/or share link
No response
Operating System
ubuntu22.04 wsl in win 11
Terminal
No response Reacted by johnsonsleo, lehhair, Yi and JiWei Activityadded coreAnything pertaining to core functionality of the application (opencode server stuff) on Apr 8, 2026github-actions commented on Apr 8, 2026 This issue might be a duplicate of existing issues. Please check:
Please review those threads before continuing — especially #21098 which has active discussion and 13 comments. skywalker-35 commented on Apr 18, 2026 Additional report: Windows 11 without any proxy — same error
Environment
|
|
| OS |
Windows 11 Pro |
| opencode |
1.4.11 |
| Node |
v22.22.2 |
| npm |
10.9.7 |
| Proxy |
None — HTTP_PROXY / HTTPS_PROXY not set, no system proxy |
Symptom
Every startup reports:
This bug is not proxy-specific. It reproduces on Windows with no proxy configured at all.
Root cause narrowed down
Through direct testing:
- Running
@npmcli/arborist loadVirtual() against the same cache directory under Node.js v22: succeeds — edgesOut is populated, reify is correctly skipped
- Same call inside 1.4.11's embedded Bun runtime:
loadVirtual() throws (silently swallowed by .catch(() => {})), falls through to reify(), which then fails and raises NpmInstallFailedError
The root cause is Bun runtime incompatibility with @npmcli/arborist's loadVirtual(), not proxy handling.
Regression confirmed
Workaround
Downgrade to 1.3.17, install plugins with explicit versions (opencode plugin [email protected] --global), then upgrade back to 1.4.11. The warning banners still appear on startup but plugins may still load depending on timing — not a reliable fix.
Hope this helps narrow down the Bun-side compatibility issue. skywalker-35 commented on Apr 28, 2026 Still reproducing on v1.14.28 (Windows 11, no proxy)
Environment
|
|
| OS |
Windows 11 Pro |
| opencode |
v1.14.28 |
| Node |
v22.22.2 (via fnm) |
| Bun |
v1.3.10 |
| Proxy |
None |
Reproduction steps
- Plugins were loading fine with cached versions (
[email protected], [email protected]) installed via opencode 1.3.17
- Updated config to
[email protected] (from "oh-my-openagent" without version)
- Restarted opencode →
NpmInstallFailedError returned
Workaround that worked
Changed opencode.jsonc to pin the exact version: "[email protected]" (instead of bare "oh-my-openagent"). After that, opencode resolved the already-cached oh-my-openagent@latest directory (which contained 3.17.6) successfully.
Key insight: The bug only manifests when opencode needs to install/reify a new plugin version. If the cache already exists and loadVirtual() succeeds against it (returns populated edgesOut), the buggy reify() path is skipped and everything works. This is why some users report "it works for me" — they happen to have a compatible cache from a previous install.
Additional issue: resolveEntryPoint() without a version number doesn't reliably resolve to @latest. It sometimes picks up an older fixed-version cache (@3.17.4) instead of @latest (@3.17.6). Pinning the version in config is necessary. removed bugSomething isn't working coreAnything pertaining to core functionality of the application (opencode server stuff) on May 3, 2026github-actions commented on Jul 6, 2026 To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|