uhop / node-re2

node.js bindings for RE2: fast, safe alternative to backtracking regular expression engines.
Other
479 stars 53 forks source link

Can't install package with bun #204

Closed BannerBomb closed 5 months ago

BannerBomb commented 6 months ago

I'm not sure if you want to add support for bun if possible. But I thought to bring this to your attention in case. So I was looking into using bun over nodejs for package management reasons. I get the error gyp: name 'llvm_version' is not defined while evaluating condition 'llvm_version=="0.0"' in binding.gyp while trying to load binding.gyp when running bun install re2.

bun add v1.0.23 (83f2432d)
 Resolving dependencies
 Resolved, downloaded and extracted [1435]
 Saved lockfile
Trying https://github.com/G3-Bots/StratoBotElite/releases/download/1.0.0/linux-x64-115.br ...
Trying https://github.com/G3-Bots/StratoBotElite/releases/download/1.0.0/linux-x64-115.gz ...
Building locally ...

error: 127
$ node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@10.0.1
gyp info using node@21.6.0 | linux | x64
gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3"
gyp http GET https://nodejs.org/dist/v21.6.0/node-v21.6.0-headers.tar.gz
gyp http 200 https://nodejs.org/dist/v21.6.0/node-v21.6.0-headers.tar.gz
gyp http GET https://nodejs.org/dist/v21.6.0/SHASUMS256.txt
gyp http 200 https://nodejs.org/dist/v21.6.0/SHASUMS256.txt
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args '/opt/stratobotelite/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/opt/stratobotelite/node_modules/re2/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/opt/stratobotelite/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/root/.cache/node-gyp/21.6.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/21.6.0',
gyp info spawn args '-Dnode_gyp_dir=/opt/stratobotelite/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/21.6.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/opt/stratobotelite/node_modules/re2',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp: name 'llvm_version' is not defined while evaluating condition 'llvm_version=="0.0"' in binding.gyp while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at <anonymous> (/opt/stratobotelite/node_modules/node-gyp/lib/configure.js:270:66)
gyp ERR! stack at emit (node:events:154:48)
gyp ERR! stack at #handleOnExit (node:child_process:537:16)
gyp ERR! stack at processTicksAndRejections (:12:39)
gyp ERR! System Linux 4.15.0-167-generic
gyp ERR! command "/usr/local/bin/bun" "/opt/stratobotelite/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /opt/stratobotelite/node_modules/re2
gyp ERR! node -v v21.6.0
gyp ERR! node-gyp -v v10.0.1
gyp ERR! not ok
error: script "rebuild" exited with code 1
uhop commented 6 months ago

Some time ago I tried to use bun and it didn’t support binary extensions at all. Has the situation changed?

BannerBomb commented 6 months ago

I'll look into that when I get off work. I have a package that uses a binary canvas. And it was able to install it fine. I'll test it to see if it's able to actually use it in code when I get home tonight. I'll update you then.

BannerBomb commented 6 months ago

yeah You're right, I don't think it supports binaries. It seems to install the packages just fine but when trying to require the module. Like canvas which is written in C++ it errors with /usr/local/bin/bun: symbol lookup error: /opt/testbot/node_modules/canvas/build/Release/canvas.node: undefined symbol: node_module_register image

uhop commented 6 months ago

Admittedly it is better than when I tried — bun ignored binary modules completely. It looks like now it aims to support Node-API: https://bun.sh/docs/api/node-api

The problem is that node-re2 uses a different way to compile an extension: https://nodejs.org/api/addons.html — all other ways did not exist when that choice was made. It means we cannot support binary modules for bun without a major reworking. The same goes for deno — AFAIK it uses Rust for their binary modules.

Nowadays, I would consider WASM first as a portable target for binary extensions.