node-pg-native icon indicating copy to clipboard operation
node-pg-native copied to clipboard

Error when trying to install on Graviton EC2

Open nrathi opened this issue 1 year ago • 7 comments

HI,

I have a c7g EC2 running Linux. Postgres 15, Node 19. I keep getting this error when trying to install pg-native:

node_modules/.pnpm/[email protected]/node_modules/libpq: Running install script, failed in 3.5s
.../[email protected]/node_modules/libpq install$ node-gyp rebuild
│ 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 3.9.16 found at "/usr/bin/python3"
│ gyp info spawn /usr/bin/python3
│ gyp info spawn args [
│ gyp info spawn args   '/home/ec2-user/.nvm/versions/node/v19.9.0/lib/node_modules/pnpm/dist/node_modul
│ 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   '/home/ec2-user/node_modules/.pnpm/[email protected]/node_modules/libpq/build/config.
│ gyp info spawn args   '-I',
│ gyp info spawn args   '/home/ec2-user/.nvm/versions/node/v19.9.0/lib/node_modules/pnpm/dist/node_modul
│ gyp info spawn args   '-I',
│ gyp info spawn args   '/home/ec2-user/.cache/node-gyp/19.9.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=/home/ec2-user/.cache/node-gyp/19.9.0',
│ gyp info spawn args   '-Dnode_gyp_dir=/home/ec2-user/.nvm/versions/node/v19.9.0/lib/node_modules/pnpm/
│ gyp info spawn args   '-Dnode_lib_file=/home/ec2-user/.cache/node-gyp/19.9.0/<(target_arch)/node.lib',
│ gyp info spawn args   '-Dmodule_root_dir=/home/ec2-user/node_modules/.pnpm/[email protected]/node_modules/l
│ 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 spawn make
│ gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
│ make: Entering directory '/home/ec2-user/node_modules/.pnpm/[email protected]/node_modules/libpq/build'
│   CXX(target) Release/obj.target/addon/src/connection.o
│   CXX(target) Release/obj.target/addon/src/connect-async-worker.o
│   CXX(target) Release/obj.target/addon/src/addon.o
│ In file included from ../../../../[email protected]/node_modules/nan/nan.h:62,
│                  from ../src/addon.h:4,
│                  from ../src/addon.cc:1:
│ /home/ec2-user/.cache/node-gyp/19.9.0/include/node/node.h:1169:7: warning: cast between incompatible f
│  1169 |       (node::addon_register_func) (regfunc),                          \
│       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│ /home/ec2-user/.cache/node-gyp/19.9.0/include/node/node.h:1203:3: note: in expansion of macro ‘NODE_MO
│  1203 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
│       |   ^~~~~~~~~~~~~
│ ../src/addon.cc:76:1: note: in expansion of macro ‘NODE_MODULE’
│    76 | NODE_MODULE(addon, InitAddon)
│       | ^~~~~~~~~~~
│   SOLINK_MODULE(target) Release/obj.target/addon.node
│ /usr/bin/ld: cannot open linker script file /builddir/build/BUILD/postgresql-15.0/.package_note-libpq-
│ collect2: error: ld returned 1 exit status
│ make: *** [addon.target.mk:160: Release/obj.target/addon.node] Error 1
│ make: Leaving directory '/home/ec2-user/node_modules/.pnpm/[email protected]/node_modules/libpq/build'
│ gyp ERR! build error 
│ gyp ERR! stack Error: `make` failed with exit code: 2
│ gyp ERR! stack     at ChildProcess.onExit (/home/ec2-user/.nvm/versions/node/v19.9.0/lib/node_modules/
│ gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
│ gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:293:12)
│ gyp ERR! System Linux 6.1.79-99.164.amzn2023.aarch64
│ gyp ERR! command "/home/ec2-user/.nvm/versions/node/v19.9.0/bin/node" "/home/ec2-user/.nvm/versions/no
│ gyp ERR! cwd /home/ec2-user/node_modules/.pnpm/[email protected]/node_modules/libpq
│ gyp ERR! node -v v19.9.0
│ gyp ERR! node-gyp -v v9.3.1
│ gyp ERR! not ok 

Other info:

PRODUCTION_INSTANCE  ➜  ~ node -p process.versions.openssl  
3.0.8+quic
PRODUCTION_INSTANCE  ➜  ~ openssl version                   
OpenSSL 3.0.8 7 Feb 2023 (Library: OpenSSL 3.0.8 7 Feb 2023)
PRODUCTION_INSTANCE  ➜  ~ sudo  yum install postgresql-devel
Last metadata expiration check: 10:52:45 ago on Fri Mar 22 03:47:08 2024.
Package libpq-devel-15.0-2.amzn2023.0.1.aarch64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
PRODUCTION_INSTANCE  ➜  ~ pg_config
BINDIR = /usr/bin
DOCDIR = /usr/share/doc/pgsql
HTMLDIR = /usr/share/doc/pgsql
INCLUDEDIR = /usr/include
PKGINCLUDEDIR = /usr/include/pgsql
INCLUDEDIR-SERVER = /usr/include/pgsql/server
LIBDIR = /usr/lib64
PKGLIBDIR = /usr/lib64/pgsql
LOCALEDIR = /usr/share/locale
MANDIR = /usr/share/man
SHAREDIR = /usr/share/pgsql
SYSCONFDIR = /etc
PGXS = /usr/lib64/pgsql/pgxs/src/makefiles/pgxs.mk
CONFIGURE =  '--build=aarch64-amazon-linux-gnu' '--host=aarch64-amazon-linux-gnu' '--program-prefix=' '--disable-dependency-tracking' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--disable-rpath' '--with-ldap' '--with-openssl' '--with-gssapi' '--enable-nls' '--without-readline' '--datadir=/usr/share/pgsql' 'build_alias=aarch64-amazon-linux-gnu' 'host_alias=aarch64-amazon-linux-gnu' 'CC=gcc' 'CFLAGS=-O2 -ftree-vectorize -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -march=armv8.2-a+crypto -mtune=neoverse-n1 -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection' '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/postgresql-15.0/.package_note-libpq-15.0-2.amzn2023.0.1.aarch64.ld' 'CXX=g++' 'CXXFLAGS=-O2 -ftree-vectorize -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -march=armv8.2-a+crypto -mtune=neoverse-n1 -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection' 'PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'
CC = gcc
CPPFLAGS = -D_GNU_SOURCE
CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -ftree-vectorize -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -march=armv8.2-a+crypto -mtune=neoverse-n1 -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection
CFLAGS_SL = -fPIC
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/postgresql-15.0/.package_note-libpq-15.0-2.amzn2023.0.1.aarch64.ld -Wl,--as-needed
LDFLAGS_EX = 
LDFLAGS_SL = 
LIBS = -lpgcommon -lpgport -lssl -lcrypto -lgssapi_krb5 -lz -lm 
VERSION = PostgreSQL 15.0

nrathi avatar Mar 22 '24 14:03 nrathi

I'm not sure this will compile on anything past node 18 LTS yet. I have plans to upgrade the NAN references as needed to fix compilation under node

18 coming up in the next month or two.

On Fri, Mar 22, 2024 at 9:37 AM Neha Rathi @.***> wrote:

HI,

I have a c7g EC2 running Linux. I keep getting this error when trying to install pg-native:

@./node_modules/libpq: Running install script, failed in 3.5s ...@./node_modules/libpq install$ node-gyp rebuild │ gyp info it worked if it ends with ok │ gyp info using @.*** │ gyp info using @.*** | linux | arm64 │ gyp info find Python using Python version 3.9.16 found at "/usr/bin/python3" │ gyp info spawn /usr/bin/python3 │ gyp info spawn args [ │ gyp info spawn args '/home/ec2-user/.nvm/versions/node/v19.9.0/lib/node_modules/pnpm/dist/node_modul │ 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 @./node_modules/libpq/build/config. │ gyp info spawn args '-I', │ gyp info spawn args '/home/ec2-user/.nvm/versions/node/v19.9.0/lib/node_modules/pnpm/dist/node_modul │ gyp info spawn args '-I', │ gyp info spawn args '/home/ec2-user/.cache/node-gyp/19.9.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=/home/ec2-user/.cache/node-gyp/19.9.0', │ gyp info spawn args '-Dnode_gyp_dir=/home/ec2-user/.nvm/versions/node/v19.9.0/lib/node_modules/pnpm/ │ gyp info spawn args '-Dnode_lib_file=/home/ec2-user/.cache/node-gyp/19.9.0/<(target_arch)/node.lib', │ gyp info spawn args @./node_modules/l │ 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 spawn make │ gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] │ make: Entering directory @./node_modules/libpq/build' │ CXX(target) Release/obj.target/addon/src/connection.o │ CXX(target) Release/obj.target/addon/src/connect-async-worker.o │ CXX(target) Release/obj.target/addon/src/addon.o │ In file included from ..@./node_modules/nan/nan.h:62, │ from ../src/addon.h:4, │ from ../src/addon.cc:1: │ /home/ec2-user/.cache/node-gyp/19.9.0/include/node/node.h:1169:7: warning: cast between incompatible f │ 1169 | (node::addon_register_func) (regfunc),
│ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ │ /home/ec2-user/.cache/node-gyp/19.9.0/include/node/node.h:1203:3: note: in expansion of macro ‘NODE_MO │ 1203 | NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage) │ | ^~~~~~~~~~~~~ │ ../src/addon.cc:76:1: note: in expansion of macro ‘NODE_MODULE’ │ 76 | NODE_MODULE(addon, InitAddon) │ | ^~~~~~~~~~~ │ SOLINK_MODULE(target) Release/obj.target/addon.node │ /usr/bin/ld: cannot open linker script file /builddir/build/BUILD/postgresql-15.0/.package_note-libpq- │ collect2: error: ld returned 1 exit status │ make: *** [addon.target.mk:160: Release/obj.target/addon.node] Error 1 │ make: Leaving directory @./node_modules/libpq/build' │ gyp ERR! build error │ gyp ERR! stack Error: make failed with exit code: 2 │ gyp ERR! stack at ChildProcess.onExit (/home/ec2-user/.nvm/versions/node/v19.9.0/lib/node_modules/ │ gyp ERR! stack at ChildProcess.emit (node:events:513:28) │ gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:293:12) │ gyp ERR! System Linux 6.1.79-99.164.amzn2023.aarch64 │ gyp ERR! command "/home/ec2-user/.nvm/versions/node/v19.9.0/bin/node" "/home/ec2-user/.nvm/versions/no │ gyp ERR! cwd @./node_modules/libpq │ gyp ERR! node -v v19.9.0 │ gyp ERR! node-gyp -v v9.3.1 │ gyp ERR! not ok

— Reply to this email directly, view it on GitHub https://github.com/brianc/node-pg-native/issues/122, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAMHIIGPJHNOE5E2T5BZKLYZQ62TAVCNFSM6AAAAABFDOIZKCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGIYDENRVGAZDGNQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

brianc avatar Mar 22 '24 14:03 brianc

Thank you for the quick reply! I still have the same problem :(

PRODUCTION_INSTANCE  ➜  ~ nvm install 18
v18.19.1 is already installed.
Now using node v18.19.1 (npm v10.2.4)
PRODUCTION_INSTANCE  ➜  ~ pnpm install pg-native           
Packages: +17
+++++++++++++++++
node_modules/.pnpm/[email protected]/node_modules/libpq: Running install script, failed in 3.6s
.../[email protected]/node_modules/libpq install$ node-gyp rebuild
│ 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 3.9.16 found at "/usr/bin/python3"
│ gyp info spawn /usr/bin/python3
│ gyp info spawn args [
│ gyp info spawn args   '/home/ec2-user/.nvm/versions/node/v18.19.1/lib/node_modules/pnpm/dist/node_modu
│ 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   '/home/ec2-user/node_modules/.pnpm/[email protected]/node_modules/libpq/build/config.
│ gyp info spawn args   '-I',
│ gyp info spawn args   '/home/ec2-user/.nvm/versions/node/v18.19.1/lib/node_modules/pnpm/dist/node_modu
│ gyp info spawn args   '-I',
│ gyp info spawn args   '/home/ec2-user/.cache/node-gyp/18.19.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=/home/ec2-user/.cache/node-gyp/18.19.1',
│ gyp info spawn args   '-Dnode_gyp_dir=/home/ec2-user/.nvm/versions/node/v18.19.1/lib/node_modules/pnpm
│ gyp info spawn args   '-Dnode_lib_file=/home/ec2-user/.cache/node-gyp/18.19.1/<(target_arch)/node.lib'
│ gyp info spawn args   '-Dmodule_root_dir=/home/ec2-user/node_modules/.pnpm/[email protected]/node_modules/l
│ 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 spawn make
│ gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
│ make: Entering directory '/home/ec2-user/node_modules/.pnpm/[email protected]/node_modules/libpq/build'
│   CXX(target) Release/obj.target/addon/src/connection.o
│   CXX(target) Release/obj.target/addon/src/connect-async-worker.o
│   CXX(target) Release/obj.target/addon/src/addon.o
│ In file included from ../../../../[email protected]/node_modules/nan/nan.h:62,
│                  from ../src/addon.h:4,
│                  from ../src/addon.cc:1:
│ /home/ec2-user/.cache/node-gyp/18.19.1/include/node/node.h:1014:7: warning: cast between incompatible 
│  1014 |       (node::addon_register_func) (regfunc),                          \
│       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│ /home/ec2-user/.cache/node-gyp/18.19.1/include/node/node.h:1048:3: note: in expansion of macro ‘NODE_M
│  1048 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
│       |   ^~~~~~~~~~~~~
│ ../src/addon.cc:76:1: note: in expansion of macro ‘NODE_MODULE’
│    76 | NODE_MODULE(addon, InitAddon)
│       | ^~~~~~~~~~~
│   SOLINK_MODULE(target) Release/obj.target/addon.node
│ /usr/bin/ld: cannot open linker script file /builddir/build/BUILD/postgresql-15.0/.package_note-libpq-
│ collect2: error: ld returned 1 exit status
│ make: *** [addon.target.mk:160: Release/obj.target/addon.node] Error 1
│ make: Leaving directory '/home/ec2-user/node_modules/.pnpm/[email protected]/node_modules/libpq/build'
│ gyp ERR! build error 
│ gyp ERR! stack Error: `make` failed with exit code: 2
│ gyp ERR! stack     at ChildProcess.onExit (/home/ec2-user/.nvm/versions/node/v18.19.1/lib/node_modules
│ gyp ERR! stack     at ChildProcess.emit (node:events:517:28)
│ gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:292:12)
│ gyp ERR! System Linux 6.1.79-99.164.amzn2023.aarch64
│ gyp ERR! command "/home/ec2-user/.nvm/versions/node/v18.19.1/bin/node" "/home/ec2-user/.nvm/versions/n
│ gyp ERR! cwd /home/ec2-user/node_modules/.pnpm/[email protected]/node_modules/libpq
│ gyp ERR! node -v v18.19.1
│ gyp ERR! node-gyp -v v9.3.1
│ gyp ERR! not ok 
└─ Failed in 3.6s at /home/ec2-user/node_modules/.pnpm/[email protected]/node_modules/libpq
Progress: resolved 17, reused 17, downloaded 0, added 0, done
 ELIFECYCLE  Command failed with exit code 1.

nrathi avatar Mar 22 '24 14:03 nrathi

hmmm...you might be missing some system libraries? Looks like its not linking properly....have you checked out this?

brianc avatar Mar 22 '24 14:03 brianc

You might wanna try this as well:

https://github.com/brianc/node-libpq/issues/85#issuecomment-1279702249

brianc avatar Mar 22 '24 14:03 brianc

I did the steps in your first comment (yum install, checking pg_config is defined).

Regarding your second comment:

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

^ I have ARM architecture, not x86. Is that a deal breaker?

nrathi avatar Mar 22 '24 14:03 nrathi

Is there a way to remove the pg config and start over?

PRODUCTION_INSTANCE  ➜  ~ sudo dnf install -y gcc-c++ make
Last metadata expiration check: 11:09:50 ago on Fri Mar 22 03:47:08 2024.
Package gcc-c++-11.4.1-2.amzn2023.0.2.aarch64 is already installed.
Package make-1:4.3-5.amzn2023.0.2.aarch64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
PRODUCTION_INSTANCE  ➜  ~ sudo  yum install postgresql-devel
Last metadata expiration check: 10:52:45 ago on Fri Mar 22 03:47:08 2024.
Package libpq-devel-15.0-2.amzn2023.0.1.aarch64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
PRODUCTION_INSTANCE  ➜  ~ sudo dnf install redhat-rpm-config

Last metadata expiration check: 11:12:17 ago on Fri Mar 22 03:47:08 2024.
Package amazon-rpm-config-228-3.amzn2023.0.2.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!

nrathi avatar Mar 22 '24 14:03 nrathi

PRODUCTION_INSTANCE  ➜  ~ sudo yum remove postgresql-devel

Dependencies resolved.
==========================================================================================================
 Package                 Architecture      Version                           Repository              Size
==========================================================================================================
Removing:
 libpq-devel             aarch64           15.0-2.amzn2023.0.1               @amazonlinux           504 k
Removing unused dependencies:
 libpq                   aarch64           15.0-2.amzn2023.0.1               @amazonlinux           875 k
 openssl-devel           aarch64           1:3.0.8-1.amzn2023.0.11           @amazonlinux           4.7 M

Transaction Summary
==========================================================================================================
Remove  3 Packages

Freed space: 6.0 M

Then I re-installed, but it didn't change anything

nrathi avatar Mar 22 '24 15:03 nrathi