Repository navigation
Closed as not planned
Closed as not planned
Copy link
Description
Description
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
Metadata
Metadata
Assignees
Labels
No labels
Activity
github-actions commentedon 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 commentedon Apr 18, 2026
Additional report: Windows 11 without any proxy — same error
Environment
HTTP_PROXY/HTTPS_PROXYnot set, no system proxySymptom
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:
@npmcli/arboristloadVirtual()against the same cache directory under Node.js v22: succeeds —edgesOutis populated, reify is correctly skippedloadVirtual()throws (silently swallowed by.catch(() => {})), falls through toreify(), which then fails and raisesNpmInstallFailedErrorThe root cause is Bun runtime incompatibility with
@npmcli/arborist'sloadVirtual(), not proxy handling.Regression confirmed
[email protected](usesbun addsubprocess): works fine[email protected](uses embedded arborist): fails on every startupWorkaround
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 commentedon Apr 28, 2026
Still reproducing on v1.14.28 (Windows 11, no proxy)
Environment
Reproduction steps
[email protected],[email protected]) installed via opencode 1.3.17[email protected](from"oh-my-openagent"without version)NpmInstallFailedErrorreturnedWorkaround that worked
Changed
opencode.jsoncto pin the exact version:"[email protected]"(instead of bare"oh-my-openagent"). After that, opencode resolved the already-cachedoh-my-openagent@latestdirectory (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 populatededgesOut), the buggyreify()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.github-actions commentedon 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.