node-sqlite3 icon indicating copy to clipboard operation
node-sqlite3 copied to clipboard

Can't install in node on linux/arm64 on Apple Silicon ARM64 M1 - because of missing binary

Open gpetrov opened this issue 5 years ago • 22 comments

Trying to install node-sqlite4 on linux/arm64 fails because of the missing precompiled binary.

#12 16.06 > [email protected] install /opt/node_app/node_modules/sqlite3
#12 16.06 > node-pre-gyp install --fallback-to-build
#12 16.06 
#12 16.21 node-pre-gyp WARN Using request for node-pre-gyp https download 
#12 16.66 node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.0/napi-v3-linux-arm64.tar.gz 
#12 16.66 node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v83 ABI, glibc) (falling back to source compile with node-gyp) 
#12 16.83 gyp ERR! find Python 
#12 16.83 gyp ERR! find Python Python is not set from command line or npm configuration
#12 16.83 gyp ERR! find Python Python is not set from environment variable PYTHON

gpetrov avatar Dec 18 '20 12:12 gpetrov

yup.

I'm running Ubuntu 20.04 for ARM in parallels and I get this when installing apps referring to sqlite3

[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > [email protected]" has incorrect peer dependency "react@^16.8.0".
warning " > [email protected]" has incorrect peer dependency "react-dom@^16.8.0".
warning " > @babel/[email protected]" has unmet peer dependency "@babel/core@^7.0.0-0".
warning " > [email protected]" has incorrect peer dependency "semantic-release@>=11.0.0 <16.0.0".
[4/4] Building fresh packages...
[-/7] ⠐ waiting...
[2/7] ⠐ sharp
[3/7] ⠐ sqlite3
[-/7] ⠐ waiting...
error /opt/overseerr/node_modules/sqlite3: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build
Arguments:
Directory: /opt/overseerr/node_modules/sqlite3
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | linux | arm64
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp info check checked for "/opt/overseerr/node_modules/sqlite3/lib/binding/napi-v3-linux-arm64/node_sqlite3.node" (not found)
node-pre-gyp http GET https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.0/napi-v3-linux-arm64.tar.gz
node-pre-gyp http 403 https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.0/napi-v3-linux-arm64.tar.gz
node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.0/napi-v3-linux-arm64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v72 ABI, glibc) (falling back to source compile with node-gyp)
node-pre-gyp http 403 status code downloading tarball https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.0/napi-v3-linux-arm64.tar.gz
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | arm64
gyp info ok
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | arm64
gyp info find Python using Python version 2.7.18 found at "/usr/bin/python2"
gyp info spawn /usr/bin/python2
gyp info spawn args [
gyp info spawn args   '/opt/overseerr/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/overseerr/node_modules/sqlite3/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/opt/overseerr/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/root/.cache/node-gyp/12.20.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/12.20.0',
gyp info spawn args   '-Dnode_gyp_dir=/opt/overseerr/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/12.20.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/opt/overseerr/node_modules/sqlite3',
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 info ok
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | arm64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/opt/overseerr/node_modules/sqlite3/build'
  CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o
  AR(target) Release/obj.target/../node-addon-api/src/nothing.a
  COPY Release/nothing.a
  ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3310100/sqlite3.c
/bin/sh: 1: python: not found
make: *** [deps/action_before_build.target.mk:13: Release/obj/gen/sqlite-autoconf-3310100/sqlite3.c] Error 127
make: Leaving directory '/opt/overseerr/node_modules/sqlite3/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/opt/overseerr/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Linux 5.4.0-58-generic
gyp ERR! command "/usr/bin/node" "/opt/overseerr/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/opt/overseerr/node_modules/sqlite3/lib/binding/napi-v3-linux-arm64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/opt/overseerr/node_modules/sqlite3/lib/binding/napi-v3-linux-arm64" "--napi_version=7" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
gyp ERR! cwd /opt/overseerr/node_modules/sqlite3
gyp ERR! node -v v12.20.0
gyp ERR! node-gyp -v v5.1.1
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /opt/overseerr/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/opt/overseerr/node_modules/sqlite3/lib/binding/napi-v3-linux-arm64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/opt/overseerr/node_modules/sqlite3/lib/binding/napi-v3-linux-arm64 --napi_version=7 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/opt/overseerr/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1022:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
node-pre-gyp ERR! System Linux 5.4.0-58-generic
node-pre-gyp ERR! command "/usr/bin/node" "/opt/overseerr/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /opt/overseerr/node_modules/sqlite3
node-pre-gyp ERR! node -v v12.20.0
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok

flying-sausages avatar Jan 01 '21 14:01 flying-sausages

Looks like if you set the python variable before, you're able to build it from source just right. e.g.:

npm config set python "$(which python3)" # or whichever version you use

flying-sausages avatar Jan 01 '21 15:01 flying-sausages

This went back to needing python 2.x since the v5.0.1 update (relevant issue: https://github.com/mapbox/node-sqlite3/issues/1415), but previously it indeed could be built with python 3.x, and in fact refused to build in python 2.x. Or at least I've confirmed I couldn't build with python 3.6.x since the update, due to a python2-only syntax in the build script, being regarded as invalid in python3.

BobbyWibowo avatar Jan 08 '21 20:01 BobbyWibowo

Can we please have a precompiled arm64 version of:

https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-linux-arm64.tar.gz

just like the x64:

https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-linux-x64.tar.gz

gpetrov avatar Mar 29 '21 16:03 gpetrov

Same issue here, a precompiled version would be useful!

TheDanielMoli avatar May 24 '21 13:05 TheDanielMoli

Meanwhile I've switched to this fork, which has it working: https://github.com/microsoft/vscode-node-sqlite3

kirillgroshkov avatar Dec 11 '21 19:12 kirillgroshkov

This should now be fixed in sqlite3 v5.0.3 🙂

daniellockyer avatar Apr 13 '22 16:04 daniellockyer

@daniellockyer I don't see any Arm64 binaries in the github release binaries of 5.0.3 .. Are those coming? It will be great if there are binaries for linux arm7/8 and Mac (darwin) arm64

gpetrov avatar Apr 13 '22 18:04 gpetrov

@gpetrov I'm working on updating https://github.com/TryGhost/node-sqlite3/pull/1362 so we can get Linux ARM builds, and I'm might have a solution to get Mac ones too 🙂 Watch this space ✨

daniellockyer avatar Apr 13 '22 18:04 daniellockyer

Awesome @daniellockyer ! Maybe also separate Electron builds? Or should the current ones already work?

Very glad you picked up the project - was going on a dead end otherwise!

gpetrov avatar Apr 13 '22 19:04 gpetrov

I just want to share that I solved my issue by doubly making sure XCode was fully installed on my new-ish M1 MBP and letting the installation script build the binary as its back-up.

(So, if anyone is still running into this issue please be sure XCode is installed and you've opened it at least once to be sure things are in a good initial state for your ARM Macbook).

But before that happened I suffered from a surprising 404 error. When I visited the release page and downloaded the file directly it worked fine. But if I plugged the URL for the tarball into my browser it would throw an error back at you. It appears that GitHub is blocking hot linking like we're back in the days of ImageShack or something.

If I attempted the naive fix of just placing my manually downloaded node_sqlite3.node file into node_modules/sqlite3/lib/binding/napi-v6-darwin-unknown-arm64/ directory the install process would still fail and (as an extra slap) delete the binary file.

See the "ERR!" line below:

[...]
error /Users/kyleg/git/flashtract-full-stack-code-challenge/node_modules/sqlite3: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build
Arguments: 
Directory: /Users/kyleg/git/flashtract-full-stack-code-challenge/node_modules/sqlite3
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | darwin | arm64
node-pre-gyp info check checked for "/Users/kyleg/git/flashtract-full-stack-code-challenge/node_modules/sqlite3/lib/binding/napi-v6-darwin-unknown-arm64/node_sqlite3.node" (not found)
node-pre-gyp http GET https://github.com/TryGhost/node-sqlite3/releases/download/v5.0.5/napi-v6-darwin-unknown-arm64.tar.gz
node-pre-gyp ERR! install response status 404 Not Found on https://github.com/TryGhost/node-sqlite3/releases/download/v5.0.5/napi-v6-darwin-unknown-arm64.tar.gz 
node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v93 ABI, unknown) (falling back to source compile with node-gyp) 
node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/TryGhost/node-sqlite3/releases/download/v5.0.5/napi-v6-darwin-unknown-arm64.tar.gz 
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | arm64
[...]

TiE23 avatar Apr 27 '22 14:04 TiE23

@TiE23 We don't currently provide arm64 darwin binaries though 🤔

daniellockyer avatar Apr 27 '22 14:04 daniellockyer

@TiE23 We don't currently provide arm64 darwin binaries though 🤔

Uhhhgggggg, yep. That says x64, not arm64. Gotta get my eyes checked.

My life as an ARM MacOS user continues to be a journey of embarrassments. Last month it was dealing with Docker fruitlessly trying to find arm64 images until I forced it to find x64 and run them through Rosetta.

Sorry about that.

TiE23 avatar Apr 27 '22 15:04 TiE23

No worries 😁 I'm working on prebuilt binaries for arm64 darwin but it needs some CI machines 🙂

daniellockyer avatar Apr 27 '22 15:04 daniellockyer

@daniellockyer - you should really compile also arm64 images for Darwin (Mac). It is possible to compile those on intel easy with cross compilation.

Check some of the other projects that does that already, like: https://github.com/lovell/sharp-libvips/blob/main/.github/workflows/build-release.yml

How it is done: https://github.com/lovell/sharp-libvips/pull/74

gpetrov avatar Apr 27 '22 15:04 gpetrov

Very interesting 👀

daniellockyer avatar Apr 27 '22 15:04 daniellockyer

Very interesting 👀

I have solved, and I could cry. My problem was due to the name of one of the directories, which it contains a space.

For instance, my directory was named "Software Engineering", but renaming as "Software_Engineering" I can install sqlite3 perfectly. Jeez.

Peipi98 avatar May 06 '22 21:05 Peipi98

Yes I also noticed the space in the path problem and the failure due to not escaping. I think it is in one of the more global components node-gyp or the pre-build, can't recall

gpetrov avatar May 07 '22 09:05 gpetrov

I think the cause of the build failure when the directory path contains spaces is https://github.com/nodejs/node-gyp/issues/65 (over 10 years old!).

gjsjohnmurray avatar Sep 07 '22 21:09 gjsjohnmurray

FYI v5.1.1 now comes with prebuilt Darwin ARM64 binaries 🙂 https://github.com/TryGhost/node-sqlite3/releases/tag/v5.1.1

daniellockyer avatar Sep 15 '22 14:09 daniellockyer