brianc / node-libpq

Simple, low level native bindings to PostgreSQL's libpq from node.js
111 stars 41 forks source link

Can't install / build node-libpq on Fedora 36 #85

Open JumpLink opened 2 years ago

JumpLink commented 2 years ago

libpq version: 14.1-2.fc36

Error message:

LANG=en_US.UTF-8 npm install libpq --save
npm ERR! code 1
npm ERR! path /home/jumplink/Projekte/libpq/node_modules/libpq
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! make: Entering directory '/home/jumplink/Projekte/libpq/node_modules/libpq/build'
npm ERR!   CXX(target) Release/obj.target/addon/src/connection.o
npm ERR!   CXX(target) Release/obj.target/addon/src/connect-async-worker.o
npm ERR!   CXX(target) Release/obj.target/addon/src/addon.o
npm ERR!   SOLINK_MODULE(target) Release/obj.target/addon.node
npm ERR! make: Leaving directory '/home/jumplink/Projekte/libpq/node_modules/libpq/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.0.0
npm ERR! gyp info using node@16.16.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.10.5 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/home/jumplink/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/jumplink/Projekte/libpq/node_modules/libpq/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/jumplink/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/jumplink/.cache/node-gyp/16.16.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/home/jumplink/.cache/node-gyp/16.16.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/home/jumplink/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/jumplink/.cache/node-gyp/16.16.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/jumplink/Projekte/libpq/node_modules/libpq',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../../nan/nan.h:60,
npm ERR!                  from ../src/addon.h:4,
npm ERR!                  from ../src/addon.cc:1:
npm ERR! /home/jumplink/.cache/node-gyp/16.16.0/include/node/node.h:847:7: warning: cast between incompatible function types from ‘void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void (*)(v8::Local<v8::Object>)’} to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
npm ERR!   847 |       (node::addon_register_func) (regfunc),                          \
npm ERR!       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! /home/jumplink/.cache/node-gyp/16.16.0/include/node/node.h:881:3: note: in expansion of macro ‘NODE_MODULE_X’
npm ERR!   881 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
npm ERR!       |   ^~~~~~~~~~~~~
npm ERR! ../src/addon.cc:76:1: note: in expansion of macro ‘NODE_MODULE’
npm ERR!    76 | NODE_MODULE(addon, InitAddon)
npm ERR!       | ^~~~~~~~~~~
npm ERR! /usr/bin/ld: cannot open linker script file /builddir/build/BUILD/.package_note-libpq-14.1-2.fc36.x86_64.ld: No such file or directory
npm ERR! collect2: error: ld returned 1 exit status
npm ERR! make: *** [addon.target.mk:164: Release/obj.target/addon.node] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/home/jumplink/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
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:291:12)
npm ERR! gyp ERR! System Linux 5.18.9-200.fc36.x86_64
npm ERR! gyp ERR! command "/home/jumplink/.nvm/versions/node/v16.16.0/bin/node" "/home/jumplink/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /home/jumplink/Projekte/libpq/node_modules/libpq
npm ERR! gyp ERR! node -v v16.16.0
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok
myudhasyuhada commented 2 years ago

I have same issue

crnch commented 1 year ago

can confirm

crnch commented 1 year ago

it's not an issue with libpq but rather an issue with pg_config returning a non-existing path:

% pg_config --ldflags                                                                                                                                                                                                         
-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/.package_note-libpq-14.1-2.fc36.x86_64.ld -Wl,--as-needed
kwokhou commented 1 year ago

I've encounter the same issue, but fixed using the following steps:

sudo dnf install -y gcc-c++ make
sudo dnf install postgresql-server-devel-14.3-2.fc36.x86_66
sudo dnf install redhat-rpm-config

Proceed with yarn / npm install