GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — cli: `opencode upgrade` dumps raw npm EACCES when the global prefix is root-owned, and can leave an older v1 binary shadowing the new one on PATH · Issue #63626 · anomalyco/opencode

cli: opencode upgrade dumps raw npm EACCES when the global prefix is root-owned, and can leave an older v1 binary shadowing the new one on PATH #63626

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
cli: opencode upgrade dumps raw npm EACCES when the global prefix is root-owned, and can leave an older v1 binary shadowing the new one on PATH#63626
Copy link
Labels
area/install-upgradeInstalling and upgradingplatform/linuxLinuxtype/featureNew behaviour or an improvementversion/v2OpenCode 2.x

Description

@pmdanton
pmdanton
opened on Nov 12, 2026
Issue body actions

Description

opencode upgrade fails with a raw npm EACCES stack trace when the detected npm global prefix is root-owned and the command runs as an unprivileged user. The UI reports "Upgrade complete"-style progress and then dumps the npm error object; there is no hint that the fix is either "run as the prefix owner / root" or "switch to the curl method".

Separately, after a successful upgrade the previously installed v1 standalone binary at ~/.opencode/bin/opencode still precedes the v2 npm bin on PATH (via a shell rc export PATH=$HOME/.opencode/bin:$PATH), so opencode --version keeps printing the v1 version. Nothing in the upgrade output mentions the shadowing binary, so the upgrade looks like it silently did nothing.

Steps to reproduce

  1. Install OpenCode 2 as root into npm's global prefix (/usr/lib/node_modules, bin at /usr/bin/opencode).
  2. As a non-root user whose npm prefix is that same root-owned prefix (npm prefix -g → /usr, test -w /usr/lib/node_modules → false), run opencode upgrade.
  3. OpenCode detects the npm install, then spawns npm install --global --force @opencode/cli@<latest> as the current user and fails.

Relevant log lines from the CLI (~/.local/share/opencode/log/opencode.log):

message="cli starting" version=2.2.5 channel=latest local=false args="[\"upgrade\"]" role=cli
message="spawning process" command=npm args="[\"list\",\"-g\",\"--depth=0\",\"@opencode/cli\"]" role=cli
message="spawning process" command=npm args="[\"install\",\"--global\",\"--force\",\"@opencode/[email protected]\"]" role=cli

Error surfaced to the user:

npm error code EACCES
npm error syscall rename
npm error path /usr/lib/node_modules/@opencode/cli
npm error dest /usr/lib/node_modules/@opencode/.cli-wGQOdxhc
npm error errno -13
npm error Error: EACCES: permission denied, rename '/usr/lib/node_modules/@opencode/cli' -> '/usr/lib/node_modules/@opencode/.cli-wGQOdxhc'
npm error     at async Object.rename (node:internal/fs/promises:1491:10)
npm error     at async moveFile (/usr/lib/node_modules/npm/node_modules/@npmcli/fs/lib/move-file.js:30:5)
npm error     at async Promise.allSettled (index 0)
npm error     at async #reifyPackages (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:353:11)
npm error     at async Arborist.reify (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist.js:139:7)
npm error     at async Install.exec (/usr/lib/node_modules/npm/lib/commands/install.js:158:5)

Running the same command as root upgrades cleanly to 2.2.7.

Expected behaviour

  • Before choosing the npm method, check that the detected global prefix is writable by the current user (fs.access / process.getuid() vs prefix ownership). If it is not, fail fast with a one-line message: the prefix, its owner, and the two supported remedies (sudo opencode upgrade, or opencode upgrade --method curl to install a user-local build).
  • Do not surface the raw npm errno object as the primary error text for a permissions problem that is fully predictable before spawning npm.
  • After an upgrade, compare the resolved opencode on PATH against the newly installed binary and warn when an older one wins, naming its path.

Impact

Non-root users on shared/root-provisioned hosts cannot upgrade through the documented command, and the failure mode is a Node stack trace rather than guidance. On hosts that were previously on v1 via the curl installer, a second failure mode — the shadowed binary — makes the upgrade appear to succeed while opencode keeps running the old major version.

Environment

  • OpenCode: 2.2.5 → 2.2.7 (upgrade failing on 2.2.5 and 2.2.7)
  • OS: Ubuntu 26.04.1 LTS
  • Node: v24.22.2, npm 11.19.1
  • Install method: npm global as root (/usr/bin/opencode → /usr/lib/node_modules/@opencode/cli/bin/opencode.exe); a v1.19.5 standalone also present at /root/.opencode/bin/opencode from the curl installer
  • Terminal: non-interactive shell over SSH

Activity

  1. opencodejr commented on Nov 12, 2026

    @opencodejr
    opencodejrBot
    on Nov 12, 2026
    Contributor
    More actions

    Thanks for the detailed report, @pmdanton.

    You're asking for two improvements to opencode upgrade:

    1. Before running npm: check whether the current user can write to the npm global prefix. If not, stop right away with a short message naming the prefix and its owner, and the two fixes (sudo opencode upgrade, or opencode upgrade --method curl), instead of showing npm's raw EACCES output.
    2. After the upgrade: check whether an older opencode (such as a v1 binary in ~/.opencode/bin) comes first on PATH, and warn with its path.

    I've labelled this a feature request rather than a bug. The current code expects npm to fail sometimes and reports it as an upgrade error with npm's output. What it doesn't have yet is the earlier permission check or the PATH check you describe. Maintainers will consider it.

    These issues are related, though none of them asks for the same thing:

    • cli: upgrade reports success but the running binary is not replaced when another copy is registered with the package manager #52152 (fixed by fix(cli): update npm installs through their own prefix #63152): upgrade reported success while a different npm copy was updated; npm upgrades now go through the install's own prefix
    • Opencode upgrade swallows actual stderr from the upgrade process #34128: an earlier report that the upgrade hid npm's underlying EACCES error
    • cli: update reports success on Homebrew installs when brew upgrade installs nothing #62723: upgrade reports success on Homebrew when nothing was installed
    • cli: update via bun global install leaves stale entry-point binary; old version keeps running #60183: a stale entry-point binary keeps the old version running after a bun upgrade
  2. opencodejr
    added
    area/install-upgradeInstalling and upgrading
    platform/linuxLinux
    type/featureNew behaviour or an improvement
    version/v2OpenCode 2.x
    on Nov 12, 2026
  3. pmdanton commented on Nov 12, 2026

    @pmdanton
    pmdanton
    on Nov 12, 2026
    Author
    More actions

    Closing: this was filed against the wrong project context by mistake.

  4. pmdanton
    closed this as not plannedon Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/install-upgradeInstalling and upgradingplatform/linuxLinuxtype/featureNew behaviour or an improvementversion/v2OpenCode 2.x

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.