Skip to content

@npmcli/arborist in Bun runtime fails to resolve proxy env vars: proxy.url must be a non-empty string #21472

Closed as not planned

Description

@listen0406

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:

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

  1. 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
  2. Configure any remote npm plugin in ~/.config/opencode/opencode.json:
    { plugin: [some-plugin@latest] }
  3. Clear the plugin cache (or use a plugin not yet cached):
    rm -rf ~/.cache/opencode/packages/some-plugin@latest/*
  4. Start opencode
  5. 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

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 8, 2026
  2. github-actions commented on Apr 8, 2026

    @github-actions
    Contributor

    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.

  3. skywalker-35 commented on Apr 18, 2026

    @skywalker-35

    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:

    Failed to install plugin [email protected]: NpmInstallFailedError
    Failed to install plugin [email protected]: NpmInstallFailedError
    

    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.

  4. skywalker-35 commented on Apr 28, 2026

    @skywalker-35

    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

    1. Plugins were loading fine with cached versions ([email protected], [email protected]) installed via opencode 1.3.17
    2. Updated config to [email protected] (from "oh-my-openagent" without version)
    3. 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.

  5. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  6. github-actions commented on Jul 6, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions