evanw / esbuild

An extremely fast bundler for the web
https://esbuild.github.io/
MIT License
37.92k stars 1.13k forks source link

Install fails on OpenBSD #3523

Open kiwec opened 9 months ago

kiwec commented 9 months ago

Using OpenBSD 7.4, latest patches installed.

package.json has "esbuild": "^0.19.5".

$ yarn
yarn install v1.22.18
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
error /home/kiwec/code/kiwec/test/node_modules/esbuild: Command failed.
Exit code: 1
Command: node install.js
Arguments: 
Directory: /home/kiwec/code/kiwec/test/node_modules/esbuild
Output:
node:internal/errors:865
  const err = new Error(message);
              ^

Error: Command failed: /usr/local/bin/node /home/kiwec/code/kiwec/test/node_modules/esbuild/bin/esbuild --version
node:child_process:929
    throw err;
    ^

Error: Command failed: /home/kiwec/code/kiwec/test/node_modules/@esbuild/openbsd-x64/bin/esbuild --version
    at checkExecSyncError (node:child_process:890:11)
    at Object.execFileSync (node:child_process:926:15)
    at Object.<anonymous> (/home/kiwec/code/kiwec/test/node_modules/esbuild/bin/esbuild:220:28)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
    at node:internal/main/run_main_module:23:47 {
  status: null,
  signal: 'SIGILL',
  output: [ null, null, null ],
  pid: 58518,
  stdout: null,
  stderr: null
}

Node.js v18.18.0

    at checkExecSyncError (node:child_process:890:11)
    at Object.execFileSync (node:child_process:926:15)
    at validateBinaryVersion (/home/kiwec/code/kiwec/test/node_modules/esbuild/install.js:98:28)
    at /home/kiwec/code/kiwec/test/node_modules/esbuild/install.js:283:5 {
  status: 1,
  signal: null,
  output: [
    null,
    Buffer(0) [Uint8Array] [],
    Buffer(919) [Uint8Array] [
      110, 111, 100, 101,  58,  99, 104, 105, 108, 100,  95, 112,
      114, 111,  99, 101, 115, 115,  58,  57,  50,  57,  10,  32,
       32,  32,  32, 116, 104, 114, 111, 119,  32, 101, 114, 114,
       59,  10,  32,  32,  32,  32,  94,  10,  10,  69, 114, 114,
      111, 114,  58,  32,  67, 111, 109, 109,  97, 110, 100,  32,
      102,  97, 105, 108, 101, 100,  58,  32,  47, 104, 111, 109,
      101,  47, 107, 105, 119, 101,  99,  47,  99, 111, 100, 101,
       47, 107, 105, 119, 101,  99,  47, 101, 120, 111,  98, 114,
       97, 105, 110,  47,
      ... 819 more items
    ]
  ],
  pid: 31177,
  stdout: Buffer(0) [Uint8Array] [],
  stderr: Buffer(919) [Uint8Array] [
    110, 111, 100, 101,  58,  99, 104, 105, 108, 100,  95, 112,
    114, 111,  99, 101, 115, 115,  58,  57,  50,  57,  10,  32,
     32,  32,  32, 116, 104, 114, 111, 119,  32, 101, 114, 114,
     59,  10,  32,  32,  32,  32,  94,  10,  10,  69, 114, 114,
    111, 114,  58,  32,  67, 111, 109, 109,  97, 110, 100,  32,
    102,  97, 105, 108, 101, 100,  58,  32,  47, 104, 111, 109,
    101,  47, 107, 105, 119, 101,  99,  47,  99, 111, 100, 101,
     47, 107, 105, 119, 101,  99,  47, 101, 120, 111,  98, 114,
     97, 105, 110,  47,
    ... 819 more items
  ]
}

Node.js v18.18.0
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
$
kiwec commented 9 months ago

Downloading the binary directly doesn't work either - running it just returns Illegal instruction (core dumped). Github doesn't allow you to attach .core files sadly...

WASM version works as a workaround.

evanw commented 9 months ago

I see. I’m sorry to hear that. What processor are you using, and how did you install node? Another question: if you don’t mind, can you install the Go compiler and run this?

git clone https://github.com/evanw/esbuild
cd esbuild
go test ./internal/...

Basically I’m trying to determine if it’s an mis-configuration in the node package or if the Go compiler has a bug when targeting OpenBSD. In the second case, the “fix” for this would be to remove esbuild’s OpenBSD support (if it’s known to not work). I don’t have access to OpenBSD myself so I am unable to do engineering work to support OpenBSD.

kiwec commented 9 months ago

After putting the executable made from gmake esbuild in PATH, it works just fine.

evanw commented 9 months ago
  • Tests pass (some have no test files, which I assume is ok)

After putting the executable made from gmake esbuild in PATH, it works just fine.

That sounds like it's not a problem with the Go compiler. Now I'm wondering if the esbuild executable that was installed is somehow different than what it should be. The executable that should have been installed is the one from @esbuild/openbsd-x64@0.19.5 with hash b673cf4cb77cac0fa5e7662e6e5bf62396190fe8, as you can see here:

$ curl -O https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.5.tgz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 3865k  100 3865k    0     0  6094k      0 --:--:-- --:--:-- --:--:-- 6154k

$ tar xf openbsd-x64-0.19.5.tgz

$ file package/bin/esbuild
package/bin/esbuild: ELF 64-bit LSB executable, x86-64, version 1 (OpenBSD), dynamically linked, interpreter /usr/libexec/ld.so, for OpenBSD, Go BuildID=XnYgCSarTaj8kE1lRO7g/qy62QapPhwD5Td3kJgqs/llvMaMNAk8T6HOVrNEL9/induGlCALmy2PktrMRA8, stripped

$ shasum package/bin/esbuild
b673cf4cb77cac0fa5e7662e6e5bf62396190fe8  package/bin/esbuild

It would be very strange if that was different, since that's what npm should be downloading. Another thing to check is whether this is the same executable that the go compiler is generating on your system or not. Building esbuild locally should result in the exact same binary executable as the one that was published (with hash b673cf4cb77cac0fa5e7662e6e5bf62396190fe8), since esbuild's builds are deterministic:

$ git clone https://github.com/evanw/esbuild

$ cd esbuild

$ git checkout v0.19.5
HEAD is now at a7fcc43f publish 0.19.5 to npm

$ CGO_ENABLED=0 GOOS=openbsd GOARCH=amd64 go build "-ldflags=-s -w" -trimpath ./cmd/esbuild

$ file ./esbuild 
./esbuild: ELF 64-bit LSB executable, x86-64, version 1 (OpenBSD), dynamically linked, interpreter /usr/libexec/ld.so, for OpenBSD, Go BuildID=XnYgCSarTaj8kE1lRO7g/qy62QapPhwD5Td3kJgqs/llvMaMNAk8T6HOVrNEL9/induGlCALmy2PktrMRA8, stripped

$ shasum ./esbuild 
b673cf4cb77cac0fa5e7662e6e5bf62396190fe8  ./esbuild

It would also be very strange if that were different, or if that executable didn't run on your system (e.g. if ./esbuild --version on that executable gives you Illegal instruction).

kiwec commented 9 months ago

Downloaded 0.19.5:

$ ./package/bin/esbuild --version                                                                                                
Illegal instruction (core dumped)
$ file package/bin/esbuild                                                                                                        
package/bin/esbuild: ELF 64-bit LSB executable, x86-64, version 1
$ sha1 package/bin/esbuild                                                                                                        
SHA1 (package/bin/esbuild) = b673cf4cb77cac0fa5e7662e6e5bf62396190fe8

Built version (using v0.19.5 git tag):

$ go version
go version go1.21.1 openbsd/amd64
$ ./esbuild --version                                                                                                             
0.19.5
$ file esbuild                                                                                                                    
esbuild: ELF 64-bit LSB executable, x86-64, version 1
$ sha1 esbuild                                                                                                                    
SHA1 (esbuild) = 1dcce1d923f082bda3b650cda498cb7d3a231a25

Maybe the go compiler version is different, or there's an issue with cross-platform building? Since I'm building it on OpenBSD directly.

evanw commented 8 months ago

Ah, sorry. The version of Go that esbuild 0.19.5 used was Go 1.20.10, not 1.21.1.

sthen commented 6 months ago

You'll need a go compiler with https://go-review.googlesource.com/c/go/+/568435 to be able to build OpenBSD binaries that will run on recent intel CPUs. It hasn't landed upstream yet, but has been in the version in OpenBSD packages for a while now.