uhop / node-re2

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

Release arm64 linux-musl prebuilts #213

Closed somay closed 2 weeks ago

somay commented 1 month ago

A linux musl for arm64 prebuilt is needed when using docker environment such as Alpine Linux. I use Apple arm64 architecture. This package has linux x64 musl and linux arm64 but linux musl arm64 is missing.

$ cat Dockerfile
FROM node:22-alpine

WORKDIR /home
RUN npm add re2
$ docker build .

[+] Building 13.6s (7/7) FINISHED                                                                                                          docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                       0.0s
 => => transferring dockerfile: 88B                                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/node:22-alpine                                                                                          3.9s
 => [auth] library/node:pull token for registry-1.docker.io                                                                                                0.0s
 => [internal] load .dockerignore                                                                                                                          0.0s
 => => transferring context: 2B                                                                                                                            0.0s
 => [1/3] FROM docker.io/library/node:22-alpine@sha256:ba898e86c2cc720c8cf2ae05f8d2d4697fe0c8ca3e920d6fbf14a6cbf50bb9ca                                    2.5s
 => => resolve docker.io/library/node:22-alpine@sha256:ba898e86c2cc720c8cf2ae05f8d2d4697fe0c8ca3e920d6fbf14a6cbf50bb9ca                                    0.0s
 => => sha256:c84305ef1ecc35c4f9a794fe3c7630082d98bebe1dc5fb9c4f18c2cbbd9f06f1 1.72kB / 1.72kB                                                             0.0s
 => => sha256:4ff9a615714abb8468826b430b1320dbde543628e668e54584601289770db88f 6.38kB / 6.38kB                                                             0.0s
 => => sha256:6499a07b73018333b7e256641e56a3945ea23ceb0182601231c6b9f998270522 47.14MB / 47.14MB                                                           1.6s
 => => sha256:ef51b21b47ac934c71cdecda24bc8b0da212f4d4629559b5e9accff9c062b8d5 1.39MB / 1.39MB                                                             0.4s
 => => sha256:5155adf0195a7bd447a0b0c6317a4d14d274f28339aef1fe7070c9c4b0e553ff 446B / 446B                                                                 0.4s
 => => sha256:ba898e86c2cc720c8cf2ae05f8d2d4697fe0c8ca3e920d6fbf14a6cbf50bb9ca 6.41kB / 6.41kB                                                             0.0s
 => => extracting sha256:6499a07b73018333b7e256641e56a3945ea23ceb0182601231c6b9f998270522                                                                  0.8s
 => => extracting sha256:ef51b21b47ac934c71cdecda24bc8b0da212f4d4629559b5e9accff9c062b8d5                                                                  0.0s
 => => extracting sha256:5155adf0195a7bd447a0b0c6317a4d14d274f28339aef1fe7070c9c4b0e553ff                                                                  0.0s
 => [2/3] WORKDIR /home                                                                                                                                    0.2s
 => ERROR [3/3] RUN npm add re2                                                                                                                            7.0s
------
 > [3/3] RUN npm add re2:
6.957 npm error code 1
6.957 npm error path /home/node_modules/re2
6.957 npm error command failed
6.957 npm error command sh -c install-from-cache --artifact build/Release/re2.node --host-var RE2_DOWNLOAD_MIRROR --skip-path-var RE2_DOWNLOAD_SKIP_PATH --skip-ver-var RE2_DOWNLOAD_SKIP_VER || node-gyp -j max rebuild
6.957 npm error Trying https://github.com/uhop/node-re2/releases/download/1.21.3/linux-musl-arm64-127.br ...
6.957 npm error Trying https://github.com/uhop/node-re2/releases/download/1.21.3/linux-musl-arm64-127.gz ...
6.957 npm error Building locally ...
6.957 npm error
6.957 npm error > re2@1.21.3 rebuild
6.957 npm error > node-gyp -j max rebuild
6.957 npm error gyp info it worked if it ends with ok
6.957 npm error gyp info using node-gyp@10.2.0
6.957 npm error gyp info using node@22.4.1 | linux | arm64
6.957 npm error gyp ERR! find Python
6.957 npm error gyp ERR! find Python Python is not set from command line or npm configuration
6.957 npm error gyp ERR! find Python Python is not set from environment variable PYTHON
6.957 npm error gyp ERR! find Python checking if "python3" can be used
6.957 npm error gyp ERR! find Python - executable path is ""
6.957 npm error gyp ERR! find Python - "" could not be run
6.957 npm error gyp ERR! find Python checking if "python" can be used
6.957 npm error gyp ERR! find Python - executable path is ""
6.957 npm error gyp ERR! find Python - "" could not be run
6.957 npm error gyp ERR! find Python
6.957 npm error gyp ERR! find Python **********************************************************
6.957 npm error gyp ERR! find Python You need to install the latest version of Python.
6.957 npm error gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
6.957 npm error gyp ERR! find Python you can try one of the following options:
6.957 npm error gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
6.957 npm error gyp ERR! find Python (accepted by both node-gyp and npm)
6.957 npm error gyp ERR! find Python - Set the environment variable PYTHON
6.957 npm error gyp ERR! find Python - Set the npm configuration variable python:
6.957 npm error gyp ERR! find Python npm config set python "/path/to/pythonexecutable"
6.957 npm error gyp ERR! find Python For more information consult the documentation at:
6.957 npm error gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
6.957 npm error gyp ERR! find Python **********************************************************
6.957 npm error gyp ERR! find Python
6.957 npm error gyp ERR! configure error
6.957 npm error gyp ERR! stack Error: Could not find any Python installation to use
6.957 npm error gyp ERR! stack at PythonFinder.fail (/home/node_modules/node-gyp/lib/find-python.js:306:11)
6.957 npm error gyp ERR! stack at PythonFinder.findPython (/home/node_modules/node-gyp/lib/find-python.js:164:17)
6.957 npm error gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
6.957 npm error gyp ERR! stack at async configure (/home/node_modules/node-gyp/lib/configure.js:27:18)
6.957 npm error gyp ERR! stack at async run (/home/node_modules/node-gyp/bin/node-gyp.js:81:18)
6.957 npm error gyp ERR! System Linux 6.6.32-linuxkit
6.957 npm error gyp ERR! command "/usr/local/bin/node" "/home/node_modules/.bin/node-gyp" "-j" "max" "rebuild"
6.957 npm error gyp ERR! cwd /home/node_modules/re2
6.957 npm error gyp ERR! node -v v22.4.1
6.957 npm error gyp ERR! node-gyp -v v10.2.0
6.957 npm error gyp ERR! not ok
6.957 npm error node:internal/process/promises:389
6.957 npm error       new UnhandledPromiseRejection(reason);
6.957 npm error       ^
6.957 npm error
6.957 npm error UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "1".
6.957 npm error     at throwUnhandledRejectionsMode (node:internal/process/promises:389:7)
6.957 npm error     at processPromiseRejections (node:internal/process/promises:470:17)
6.957 npm error     at process.processTicksAndRejections (node:internal/process/task_queues:96:32) {
6.957 npm error   code: 'ERR_UNHANDLED_REJECTION'
6.957 npm error }
6.957 npm error
6.957 npm error Node.js v22.4.1
6.957 npm error gyp info it worked if it ends with ok
6.957 npm error gyp info using node-gyp@10.2.0
6.957 npm error gyp info using node@22.4.1 | linux | arm64
6.957 npm error gyp ERR! find Python
6.957 npm error gyp ERR! find Python Python is not set from command line or npm configuration
6.957 npm error gyp ERR! find Python Python is not set from environment variable PYTHON
6.957 npm error gyp ERR! find Python checking if "python3" can be used
6.957 npm error gyp ERR! find Python - executable path is ""
6.957 npm error gyp ERR! find Python - "" could not be run
6.957 npm error gyp ERR! find Python checking if "python" can be used
6.957 npm error gyp ERR! find Python - executable path is ""
6.957 npm error gyp ERR! find Python - "" could not be run
6.957 npm error gyp ERR! find Python
6.957 npm error gyp ERR! find Python **********************************************************
6.957 npm error gyp ERR! find Python You need to install the latest version of Python.
6.957 npm error gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
6.957 npm error gyp ERR! find Python you can try one of the following options:
6.957 npm error gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
6.957 npm error gyp ERR! find Python (accepted by both node-gyp and npm)
6.957 npm error gyp ERR! find Python - Set the environment variable PYTHON
6.957 npm error gyp ERR! find Python - Set the npm configuration variable python:
6.957 npm error gyp ERR! find Python npm config set python "/path/to/pythonexecutable"
6.957 npm error gyp ERR! find Python For more information consult the documentation at:
6.957 npm error gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
6.957 npm error gyp ERR! find Python **********************************************************
6.957 npm error gyp ERR! find Python
6.957 npm error gyp ERR! configure error
6.957 npm error gyp ERR! stack Error: Could not find any Python installation to use
6.957 npm error gyp ERR! stack at PythonFinder.fail (/home/node_modules/node-gyp/lib/find-python.js:306:11)
6.957 npm error gyp ERR! stack at PythonFinder.findPython (/home/node_modules/node-gyp/lib/find-python.js:164:17)
6.957 npm error gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
6.957 npm error gyp ERR! stack at async configure (/home/node_modules/node-gyp/lib/configure.js:27:18)
6.957 npm error gyp ERR! stack at async run (/home/node_modules/node-gyp/bin/node-gyp.js:81:18)
6.957 npm error gyp ERR! System Linux 6.6.32-linuxkit
6.957 npm error gyp ERR! command "/usr/local/bin/node" "/home/node_modules/.bin/node-gyp" "-j" "max" "rebuild"
6.957 npm error gyp ERR! cwd /home/node_modules/re2
6.957 npm error gyp ERR! node -v v22.4.1
6.957 npm error gyp ERR! node-gyp -v v10.2.0
6.957 npm error gyp ERR! not ok
6.958 npm notice
6.958 npm notice New patch version of npm available! 10.8.1 -> 10.8.2
6.958 npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.2
6.958 npm notice To update run: npm install -g npm@10.8.2
6.958 npm notice
6.958 npm error A complete log of this run can be found in: /root/.npm/_logs/2024-07-18T02_36_48_704Z-debug-0.log
------
Dockerfile:4
--------------------
   2 |
   3 |     WORKDIR /home
   4 | >>> RUN npm add re2
   5 |
--------------------
ERROR: failed to solve: process "/bin/sh -c npm add re2" did not complete successfully: exit code: 1

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/m3mk7tbkn5mux9hkbbgcxu61e
$ npx envinfo --system

  System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M2
    Memory: 175.06 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
somay commented 1 month ago

Anyway thank you for releasing this package for Apple arm64 architecture! It helps our development team. It would be greater if we could have it also for Alpine Linux on Apple M1.

uhop commented 1 month ago

You can fix the problem by installing Python and other dependencies required by node-gyp.

I'll look into building binaries you asked for. Unless somebody submits a patch before me. :-)

devkokov commented 1 month ago

+1 for adding this in please

uhop commented 2 weeks ago

Added the feature in ba014d0d58b2840be0a52433a5f1754c2aba2c19 + b928038181a5e020d3387feff56d286836b00aec

uhop commented 2 weeks ago

The trial run has worked. It'll be released with the next version (1.21.4).