netlify / build-image

This is the build image used for running automated builds
MIT License
497 stars 196 forks source link

Issues with `node-libpq` #393

Open ehmicky opened 4 years ago

ehmicky commented 4 years ago

A user reported the following build error:

gyp info it worked if it ends with ok
gyp info using node-gyp@5.1.0
gyp info using node@10.20.1 | linux | x64
gyp info find Python using Python version 2.7.12 found at "/opt/buildhome/python2.7/bin/python"
gyp http GET https://nodejs.org/download/release/v10.20.1/node-v10.20.1-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v10.20.1/node-v10.20.1-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v10.20.1/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v10.20.1/SHASUMS256.txt
gyp info spawn /opt/buildhome/python2.7/bin/python
gyp info spawn args [ '/opt/buildhome/.nvm/versions/node/v10.20.1/lib/node_modules/npm/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/build/repo/node_modules/libpq/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/opt/buildhome/.nvm/versions/node/v10.20.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/opt/buildhome/.cache/node-gyp/10.20.1/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/opt/buildhome/.cache/node-gyp/10.20.1',
gyp info spawn args '-Dnode_gyp_dir=/opt/buildhome/.nvm/versions/node/v10.20.1/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/opt/buildhome/.cache/node-gyp/10.20.1/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/opt/build/repo/node_modules/libpq',
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=.' ]
find: ‘/usr/pg*’: No such file or directory
gyp: Call to 'which pg_config || find /usr/bin /usr/local/bin /usr/pg* /opt -executable -name pg_config -print -quit' returned exit status 1 while 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 ChildProcess.onCpExit (/opt/buildhome/.nvm/versions/node/v10.20.1/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 4.14.138+
gyp ERR! command "/opt/buildhome/.nvm/versions/node/v10.20.1/bin/node" "/opt/buildhome/.nvm/versions/node/v10.20.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /opt/build/repo/node_modules/libpq
gyp ERR! node -v v10.20.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Error during Yarn install
Error running command: Build script returned non-zero exit code: 1

This happens when using node-libpq. That library does not mention requiring it but other users are reporting this problem.

Checking their binding.gyp, the problem is that they are looking for Postgres executable in /usr/bin, /usr/local/bin, /opt or /usr/pg*. However if /usr/pg* does not exist, it errors. I am not sure if this is a bug in their binding.gyp or whether that library expects postgresql-dev to be installed.

mraerino commented 4 years ago

with #411 this could be installed via a Brewfile: https://formulae.brew.sh/formula-linux/libpq

borispov commented 3 years ago

Installing libpq via Brewfile didn't solve the problem for me as it required libpq to exist inside node_modules.

I ended up using this postgres postgres driver that has 0 dependencies and builds on netlify without issues (so far).