nix-community / napalm

Support for building npm packages in Nix and lightweight npm registry [maintainer=?]
MIT License
104 stars 17 forks source link

Installing `sqlite3` ir `better-sqlite3` fails #60

Open arximboldi opened 8 months ago

arximboldi commented 8 months ago

Installing this dependency fails with something along these lines. I have tried multiple workarounds with customPatchPackages and patchPackages with no luck. I am also having no luck with alternatives like npmlock2nix or nix-npm-buildpackage. Anyone has success with these?

npm info run better-sqlite3@9.2.2 install node_modules/better-sqlite3 prebuild-install || node-gyp rebuild --release
npm info run better-sqlite3@9.2.2 install { code: 1, signal: null }nst
npm timing reify:rollback:createSparse Completed in 30mste3@9.2.2 inst
npm timing reify:rollback:retireShallow Completed in 0ms
npm timing command:install Completed in 1104ms
npm verb stack Error: command failed
npm verb stack     at ChildProcess.<anonymous> (/nix/store/6g5y6hq3npg9gy04q4ya1xzz9nj0bh59-nodejs-16.15.0/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
npm verb stack     at ChildProcess.emit (node:events:527:28)
npm verb stack     at maybeClose (node:internal/child_process:1092:16)
npm verb stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm verb pkgid better-sqlite3@9.2.2
npm verb cwd /build/server
npm verb Linux 6.1.34
npm verb argv "/nix/store/6g5y6hq3npg9gy04q4ya1xzz9nj0bh59-nodejs-16.15.0/bin/node" "/nix/store/6g5y6hq3npg9gy04q4ya1xzz9nj0bh59-nodejs-16.15.0/bin/npm" "install" "--loglevel" "verbose" "--nodedir=/nix/store/6g5y6hq3npg9gy04q4ya1xzz9nj0bh59-nodejs-16.15.0/include/node"
npm verb node v16.15.0
npm verb npm  v8.5.5
npm ERR! code 1
npm ERR! path /build/server/node_modules/better-sqlite3
npm ERR! command failed
npm ERR! command sh -c prebuild-install || node-gyp rebuild --release
npm ERR! sh: /build/server/node_modules/.bin/prebuild-install: /usr/bin/env: bad interpreter: No such file or directory
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   '/nix/store/6g5y6hq3npg9gy04q4ya1xzz9nj0bh59-nodejs-16.15.0/bin/node',
npm ERR! gyp verb cli   '/nix/store/6g5y6hq3npg9gy04q4ya1xzz9nj0bh59-nodejs-16.15.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--release'
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@9.0.0
npm ERR! gyp info using node@16.15.0 | linux | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb find Python Python is not set from command line or npm configuration
npm ERR! gyp verb find Python Python is not set from environment variable PYTHON
npm ERR! gyp verb find Python checking if "python3" can be used
npm ERR! gyp verb find Python - executing "python3" to get executable path
npm ERR! gyp verb find Python - "python3" is not in PATH or produced an error
npm ERR! gyp verb find Python checking if "python" can be used
npm ERR! gyp verb find Python - executing "python" to get executable path
npm ERR! gyp verb find Python - "python" is not in PATH or produced an error
npm ERR! gyp ERR! find Python 
npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
npm ERR! gyp ERR! find Python checking if "python3" can be used
npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
npm ERR! gyp ERR! find Python checking if "python" can be used
npm ERR! gyp ERR! find Python - "python" is not in PATH or produced an error
npm ERR! gyp ERR! find Python 
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python You need to install the latest version of Python.
npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
npm ERR! gyp ERR! find Python you can try one of the following options:
npm ERR! gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
npm ERR! gyp ERR! find Python   (accepted by both node-gyp and npm)
npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
npm ERR! gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
npm ERR! gyp ERR! find Python For more information consult the documentation at:
npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python 
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
npm ERR! gyp ERR! stack     at PythonFinder.fail (/nix/store/6g5y6hq3npg9gy04q4ya1xzz9nj0bh59-nodejs-16.15.0/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:330:47)
npm ERR! gyp ERR! stack     at PythonFinder.runChecks (/nix/store/6g5y6hq3npg9gy04q4ya1xzz9nj0bh59-nodejs-16.15.0/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:159:21)
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (/nix/store/6g5y6hq3npg9gy04q4ya1xzz9nj0bh59-nodejs-16.15.0/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:202:16)
npm ERR! gyp ERR! stack     at PythonFinder.execFileCallback (/nix/store/6g5y6hq3npg9gy04q4ya1xzz9nj0bh59-nodejs-16.15.0/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:294:16)
npm ERR! gyp ERR! stack     at exithandler (node:child_process:406:5)
npm ERR! gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:418:5)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
npm ERR! gyp ERR! stack     at onErrorNT (node:internal/child_process:478:16)
npm ERR! gyp ERR! stack     at processTicksAndRejections (node:internal/process/task_queues:83:21)
npm ERR! gyp ERR! System Linux 6.1.34
npm ERR! gyp ERR! command "/nix/store/6g5y6hq3npg9gy04q4ya1xzz9nj0bh59-nodejs-16.15.0/bin/node" "/nix/store/6g5y6hq3npg9gy04q4ya1xzz9nj0bh59-nodejs-16.15.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
npm ERR! gyp ERR! cwd /build/server/node_modules/better-sqlite3
npm ERR! gyp ERR! node -v v16.15.0
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok
npm verb exit 1
npm timing npm Completed in 1223ms
npm verb unfinished npm timer reify 1702399506617
npm verb unfinished npm timer reify:build 1702399507602
npm verb unfinished npm timer build 1702399507603
npm verb unfinished npm timer build:deps 1702399507603
npm verb unfinished npm timer build:run:install 1702399507606
npm verb unfinished npm timer build:run:install:node_modules/better-sqlite3 1702399507606
npm verb code 1

npm ERR! A complete log of this run can be found in:
npm ERR!     /build/tmp.nRE4fM60rN/.npm/_logs/2023-12-12T16_45_06_500Z-debug-0.log

error: builder for '/nix/store/wphiq151fwzf09b2n75nh2rrbcn01dxb-server-0.0.0.drv' failed with exit code 1;
       last 10 log lines:
       > npm verb unfinished npm timer reify:build 1702399507602
       > npm verb unfinished npm timer build 1702399507603
       > npm verb unfinished npm timer build:deps 1702399507603
       > npm verb unfinished npm timer build:run:install 1702399507606
       > npm verb unfinished npm timer build:run:install:node_modules/better-sqlite3 1702399507606
       > npm verb code 1
       > 
       > npm ERR! A complete log of this run can be found in:
       > npm ERR!     /build/tmp.nRE4fM60rN/.npm/_logs/2023-12-12T16_45_06_500Z-debug-0.log
       > 
       For full logs, run 'nix log /nix/store/wphiq151fwzf09b2n75nh2rrbcn01dxb-server-0.0.0.drv'.
error: build of '/nix/store/gjiifk5hh2q9xg7gjl0nrfw7vl2qvzvr-client-0.1.0.drv', '/nix/store/wphiq151fwzf09b2n75nh2rrbcn01dxb-server-0.0.0.drv' failed
jtojnar commented 8 months ago

For node-gyp, you need to pass the following to napalm.buildPackage:

  nativeBuildInputs = [
    # For node-gyp
    pkgs.python3
  ];