Skip to content

npm is hardcoded #34

Closed
Closed

Description

@skorphil

Hi, seems like npm is hardcoded somewhere. I do not use npm and with opencoderag installe globally via pnpm, i get:

opencode-rag setup --force

Setting up OpenCodeRAG runtime...

/bin/sh: 1: npm: not found
  Could not check npm for the latest version (offline?).
  Run `opencode-rag update` later to upgrade.

/bin/sh: 1: npm: not found
  ✗ npm is not available on PATH. Cannot determine global package location.

  Setup failed. Please check the errors above or run with --force.

Activity

  1. self-assigned this
    on Oct 2, 2026
  2. MrDoe commented on Oct 2, 2026

    @MrDoe
    Owner

    Fixed in f7e47ef (next release after 2.3.0). \opencode-rag setup\ / \update\ / \init\ now detect the package manager that owns the global install (npm, pnpm, yarn, or bun) instead of shelling out to npm: global roots are resolved per manager (
    pm root -g\ / \pnpm root -g\ / \yarn global dir\ / bun's fixed layout), SDK installs and self-update use that manager's own global-install command, and the latest-version check queries the npm registry over HTTPS. A last-resort fallback even works with no package-manager CLI on PATH by resolving the install location from the running CLI's own realpath. Your scenario — global install via pnpm with npm absent — is covered by unit tests.

  3. MrDoe commented on Oct 2, 2026

    @MrDoe
    Owner

    Thanks for the report — this was a real bug on our side, and it's fixed in 2.3.1 (published to npm, verified live).

    What happened

    setup, update, and init had npm hardcoded in several places: they ran npm root -g, npm install -g, npm view, and npm uninstall -g directly. On a machine like yours — plugin installed globally via pnpm, npm not on PATH — every one of those calls produced exactly the npm: not found failure you saw, and setup aborted before it could do anything useful.

    The fix (f7e47ef, released in 2.3.1)

    All global-package operations now go through a new package-manager detection layer (src/core/package-manager.ts):

    • Manager detection: reads npm_config_user_agent (set by npm/pnpm/yarn/bun when they launch the CLI), falls back to markers of where the plugin is installed (pnpm's .pnpm/pnpm path segments, ~/.bun/install/global, yarn's global dir), then probes each manager's global root (npm root -g, pnpm root -g, yarn global dir, bun's fixed layout).
    • Per-manager commands: the SDK install becomes pnpm add -g @opencode-ai/plugin on your machine (npm's npm install -g when npm owns the install), the uninstall hint shows the right manager's command, and opencode-rag update upgrades through the owning manager (pnpm add -g opencode-rag-plugin@latest).
    • No package-manager CLI needed at all: as a last resort the install location is derived from the running CLI's own real path, so even the junction/symlink step of setup works without any manager binary on PATH.
    • Version check via HTTPS: the "latest version" lookup talks to the npm registry over HTTPS instead of shelling out to npm view, so it never depends on a local npm.

    What you should do now

    opencode-rag update    # will use pnpm, then re-sync the runtime
    # or, if you want a fresh start:
    pnpm add -g opencode-rag-plugin
    opencode-rag setup --force

    Your original command (opencode-rag setup --force) now works as-is on a pnpm-only machine.

    Two notes:

    • Yarn (v2+/Berry) deliberately has no global-install mode — with Yarn do a classic (v1) global install or use pnpm/bun. Detection skips Berry cleanly instead of failing.
    • If anything still misbehaves after updating, reply here or open a new issue with the output of opencode-rag setup --check — that command now works without touching anything and prints the runtime state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions