opencode icon indicating copy to clipboard operation
opencode copied to clipboard

pnpm install causes crash

Open agladysh opened this issue 1 month ago • 4 comments

Description

$ opencode
/home/agladysh/. local/share/pnpm/global/5/-pnpm/[email protected]/node_modules/opencode-linux-ar
m64/bin/opencode: 1
ELF
SyntaxError: Invalid or unexpected token
at wrapSafe (node: internal/modules/cjs/loader: 1378:20)
at Module._compile (node: internal/modules/cjs/loader: 1428:41)
at Module,_extensions..js (node: internal/modules/cjs/loader: 1548:10)
at Module. load (node: internal/modules/cjs/loader: 1288:32) at Module._load (node: internal/modules/cjs/loader:1104:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:173:12)
at node: internal/main/run_main_module: 28:49
Node-js v20.18.1
$ uname -a
Linux THAI-1 6.17.4-orbstack-00308-g195e9689a04f #1 SMP PREEMPT Fri Oct 24
64 aarch64 GNU/Linux
07:22:34 UTC 2025 aarch64 aarch
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:
Ubuntu
25.04
Release:
25.04
Codename:
plucky
$ pnpm --version
10.20.0

OpenCode version

1.0.72

Steps to reproduce

  1. Install Ubuntu 25.04 server VM (Host is OS X 15.6, OrbStack 2.0.4), install nodejs, npm, pnpm via npm.
  2. pnpm i -g opencode-ai
  3. pnpm approve-builds -g, select and approve opencode
  4. Launching opencode leads to crash

Screenshot and/or share link

No response

Operating System

Ubuntu 25.04 (VM in the OS X 15.6 host)

Terminal

Stock OS X Terminal.app

agladysh avatar Nov 18 '25 15:11 agladysh

hmm ill check it out

rekram1-node avatar Nov 18 '25 19:11 rekram1-node

The issue appears to stem from the entrypoint shell script attempting to run a binary with Node.js. As a workaround, I modified lines 18 and 20 of ~/.local/share/pnpm/opencode, removing node from the command and running the binary directly.

Interestingly, reinstalling with pnpm worked without the need to modify the shell script (OpenCode version 1.0.110).

wgumenyuk avatar Nov 25 '25 15:11 wgumenyuk

Same here on MacOS and pnpm. opencode 1.0.122. These lines aren't right:

if [ -x "$basedir/node" ]; then
  exec "$basedir/node"  "$basedir/global/5/.pnpm/[email protected]/node_modules/opencode-ai/bin/opencode" "$@"
else
  exec node  "$basedir/global/5/.pnpm/[email protected]/node_modules/opencode-ai/bin/opencode" "$@"
fi

bartschuller avatar Nov 30 '25 09:11 bartschuller

Another one here, In my case was that it was deleted from the system I couldn't find opencode then I reinstalled it like @wgumenyuk did but it didn't work... and run into the same problem it seems the script is trying to call a binary hence the ELF error so we need to test for ELF or JS and exec accordingly

so by removing **node ** from this line (20)

if [ -x "$basedir/node" ]; then
  exec "$basedir/node" "$basedir/global/5/.pnpm/[email protected]/node_modules/opencode-ai/bin/opencode" "$@"
else
  **exec node  "$basedir/global/5/.pnpm/[email protected]/node_modules/opencode-ai/bin/opencode" "$@"**
fi

and just using

if [ -x "$basedir/node" ]; then
  exec "$basedir/node" "$basedir/global/5/.pnpm/[email protected]/node_modules/opencode-ai/bin/opencode" "$@"
else
  **exec "$basedir/global/5/.pnpm/[email protected]/node_modules/opencode-ai/bin/opencode" "$@"**
fi

yokodev avatar Dec 09 '25 17:12 yokodev