brianc / node-libpq

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

npm install libpq fail #6

Closed EliSnow closed 9 years ago

EliSnow commented 9 years ago

I get the following error when I run npm install libpq inside a Debian Wheezy docker container running Node 0.11.14.

> libpq@1.3.0 install /var/lib/app/node_modules/libpq
> node-gyp rebuild

child_process: customFds option is deprecated, use stdio instead.
make: Entering directory `/var/lib/app/node_modules/libpq/build'
  CXX(target) Release/obj.target/addon/src/connection.o
../src/connection.cc: In static member function 'static void Connection::ResultErrorFields(const v8::FunctionCallbackInfo<v8::Value>&)':
../src/connection.cc:385:3: error: 'PG_DIAG_SCHEMA_NAME' was not declared in this scope
../src/connection.cc:386:3: error: 'PG_DIAG_TABLE_NAME' was not declared in this scope
../src/connection.cc:387:3: error: 'PG_DIAG_COLUMN_NAME' was not declared in this scope
../src/connection.cc:388:3: error: 'PG_DIAG_DATATYPE_NAME' was not declared in this scope
../src/connection.cc:389:3: error: 'PG_DIAG_CONSTRAINT_NAME' was not declared in this scope
make: *** [Release/obj.target/addon/src/connection.o] Error 1
make: Leaving directory `/var/lib/app/node_modules/libpq/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1059:12)
gyp ERR! System Linux 3.16.4-tinycore64
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/lib/app/node_modules/libpq
gyp ERR! node -v v0.11.14
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok 

npm ERR! Linux 3.16.4-tinycore64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "libpq"
npm ERR! node v0.11.14
npm ERR! npm  v2.0.0
npm ERR! code ELIFECYCLE
npm ERR! libpq@1.3.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the libpq@1.3.0 install script.
npm ERR! This is most likely a problem with the libpq package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls libpq
npm ERR! There is likely additional logging output above.

Related, probably, I get the following error when I run npm install pg-native:

> libpq@1.3.0 install /var/lib/app/node_modules/pg-native/node_modules/libpq
> node-gyp rebuild

child_process: customFds option is deprecated, use stdio instead.
make: Entering directory `/var/lib/app/node_modules/pg-native/node_modules/libpq/build'
  CXX(target) Release/obj.target/addon/src/connection.o
../src/connection.cc: In static member function 'static void Connection::ResultErrorFields(const v8::FunctionCallbackInfo<v8::Value>&)':
../src/connection.cc:385:3: error: 'PG_DIAG_SCHEMA_NAME' was not declared in this scope
../src/connection.cc:386:3: error: 'PG_DIAG_TABLE_NAME' was not declared in this scope
../src/connection.cc:387:3: error: 'PG_DIAG_COLUMN_NAME' was not declared in this scope
../src/connection.cc:388:3: error: 'PG_DIAG_DATATYPE_NAME' was not declared in this scope
../src/connection.cc:389:3: error: 'PG_DIAG_CONSTRAINT_NAME' was not declared in this scope
make: *** [Release/obj.target/addon/src/connection.o] Error 1
make: Leaving directory `/var/lib/app/node_modules/pg-native/node_modules/libpq/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1059:12)
gyp ERR! System Linux 3.16.4-tinycore64
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/lib/app/node_modules/pg-native/node_modules/libpq
gyp ERR! node -v v0.11.14
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok 

npm ERR! Linux 3.16.4-tinycore64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "pg-native"
npm ERR! node v0.11.14
npm ERR! npm  v2.0.0
npm ERR! code ELIFECYCLE
npm ERR! libpq@1.3.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the libpq@1.3.0 install script.
npm ERR! This is most likely a problem with the libpq package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls libpq
npm ERR! There is likely additional logging output above.

libpq-dev is installed.

brianc commented 9 years ago

What is the output of 'pg_config' and what version of postgres are you using? Could you get me a docker file?

On Thursday, November 20, 2014, EliSnow notifications@github.com wrote:

I get the following error when I run npm install libpq inside a Debian Wheezy docker container running Node 0.11.14.

libpq@1.3.0 install /var/lib/app/node_modules/libpq node-gyp rebuild

child_process: customFds option is deprecated, use stdio instead. make: Entering directory /var/lib/app/node_modules/libpq/build' CXX(target) Release/obj.target/addon/src/connection.o ../src/connection.cc: In static member function 'static void Connection::ResultErrorFields(const v8::FunctionCallbackInfo<v8::Value>&)': ../src/connection.cc:385:3: error: 'PG_DIAG_SCHEMA_NAME' was not declared in this scope ../src/connection.cc:386:3: error: 'PG_DIAG_TABLE_NAME' was not declared in this scope ../src/connection.cc:387:3: error: 'PG_DIAG_COLUMN_NAME' was not declared in this scope ../src/connection.cc:388:3: error: 'PG_DIAG_DATATYPE_NAME' was not declared in this scope ../src/connection.cc:389:3: error: 'PG_DIAG_CONSTRAINT_NAME' was not declared in this scope make: *** [Release/obj.target/addon/src/connection.o] Error 1 make: Leaving directory/var/lib/app/node_modules/libpq/build' gyp ERR! build error gyp ERR! stack Error: make failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23) gyp ERR! stack at ChildProcess.emit (events.js:110:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1059:12) gyp ERR! System Linux 3.16.4-tinycore64 gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /var/lib/app/node_modules/libpq gyp ERR! node -v v0.11.14 gyp ERR! node-gyp -v v1.0.2 gyp ERR! not ok

npm ERR! Linux 3.16.4-tinycore64 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "libpq" npm ERR! node v0.11.14 npm ERR! npm v2.0.0 npm ERR! code ELIFECYCLE npm ERR! libpq@1.3.0 install: node-gyp rebuild npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the libpq@1.3.0 install script. npm ERR! This is most likely a problem with the libpq package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-gyp rebuild npm ERR! You can get their info via: npm ERR! npm owner ls libpq npm ERR! There is likely additional logging output above.

Related, probably, I get the following error when I run npm install pg-native:

libpq@1.3.0 install /var/lib/app/node_modules/pg-native/node_modules/libpq node-gyp rebuild

child_process: customFds option is deprecated, use stdio instead. make: Entering directory /var/lib/app/node_modules/pg-native/node_modules/libpq/build' CXX(target) Release/obj.target/addon/src/connection.o ../src/connection.cc: In static member function 'static void Connection::ResultErrorFields(const v8::FunctionCallbackInfo<v8::Value>&)': ../src/connection.cc:385:3: error: 'PG_DIAG_SCHEMA_NAME' was not declared in this scope ../src/connection.cc:386:3: error: 'PG_DIAG_TABLE_NAME' was not declared in this scope ../src/connection.cc:387:3: error: 'PG_DIAG_COLUMN_NAME' was not declared in this scope ../src/connection.cc:388:3: error: 'PG_DIAG_DATATYPE_NAME' was not declared in this scope ../src/connection.cc:389:3: error: 'PG_DIAG_CONSTRAINT_NAME' was not declared in this scope make: *** [Release/obj.target/addon/src/connection.o] Error 1 make: Leaving directory/var/lib/app/node_modules/pg-native/node_modules/libpq/build' gyp ERR! build error gyp ERR! stack Error: make failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23) gyp ERR! stack at ChildProcess.emit (events.js:110:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1059:12) gyp ERR! System Linux 3.16.4-tinycore64 gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /var/lib/app/node_modules/pg-native/node_modules/libpq gyp ERR! node -v v0.11.14 gyp ERR! node-gyp -v v1.0.2 gyp ERR! not ok

npm ERR! Linux 3.16.4-tinycore64 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "pg-native" npm ERR! node v0.11.14 npm ERR! npm v2.0.0 npm ERR! code ELIFECYCLE npm ERR! libpq@1.3.0 install: node-gyp rebuild npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the libpq@1.3.0 install script. npm ERR! This is most likely a problem with the libpq package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-gyp rebuild npm ERR! You can get their info via: npm ERR! npm owner ls libpq npm ERR! There is likely additional logging output above.

libpq-dev is installed.

— Reply to this email directly or view it on GitHub https://github.com/brianc/node-libpq/issues/6.

EliSnow commented 9 years ago

The output of pg_config:

BINDIR = /usr/lib/postgresql/9.1/bin
DOCDIR = /usr/share/doc/postgresql-doc-9.1
HTMLDIR = /usr/share/doc/postgresql-doc-9.1
INCLUDEDIR = /usr/include/postgresql
PKGINCLUDEDIR = /usr/include/postgresql
INCLUDEDIR-SERVER = /usr/include/postgresql/9.1/server
LIBDIR = /usr/lib
PKGLIBDIR = /usr/lib/postgresql/9.1/lib
LOCALEDIR = /usr/share/locale
MANDIR = /usr/share/postgresql/9.1/man
SHAREDIR = /usr/share/postgresql/9.1
SYSCONFDIR = /etc/postgresql-common
PGXS = /usr/lib/postgresql/9.1/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--with-tcl' '--with-perl' '--with-python' '--with-pam' '--with-krb5' '--with-gssapi' '--with-openssl' '--with-libxml' '--with-libxslt' '--with-ldap' '--with-tclconfig=/usr/lib/tcl8.5' '--with-tkconfig=/usr/lib/tk8.5' '--with-includes=/usr/include/tcl8.5' 'PYTHON=/usr/bin/python' '--mandir=/usr/share/postgresql/9.1/man' '--docdir=/usr/share/doc/postgresql-doc-9.1' '--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share/' '--datadir=/usr/share/postgresql/9.1' '--bindir=/usr/lib/postgresql/9.1/bin' '--libdir=/usr/lib/' '--libexecdir=/usr/lib/postgresql/' '--includedir=/usr/include/postgresql/' '--enable-nls' '--enable-integer-datetimes' '--enable-thread-safety' '--enable-debug' '--disable-rpath' '--with-ossp-uuid' '--with-gnu-ld' '--with-pgport=5432' '--with-system-tzdata=/usr/share/zoneinfo' 'CFLAGS=-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC -pie' 'CPPFLAGS=-D_FORTIFY_SOURCE=2 -DLINUX_OOM_ADJ=0' 'LDFLAGS=-Wl,-z,relro -Wl,-z,now -Wl,--as-needed'
CC = gcc
CPPFLAGS = -D_FORTIFY_SOURCE=2 -DLINUX_OOM_ADJ=0 -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include/tcl8.5
CFLAGS = -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC -pie -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g
CFLAGS_SL = -fpic
LDFLAGS = -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -L/usr/lib -Wl,--as-needed
LDFLAGS_EX = 
LDFLAGS_SL = 
LIBS = -lpgport -lxslt -lxml2 -lpam -lssl -lcrypto -lkrb5 -lcom_err -lgssapi_krb5 -lz -ledit -lcrypt -ldl -lm 
VERSION = PostgreSQL 9.1.14

I have postgres and node running in seperate containers. Postgres version is 9.4-beta3.

For node there are two Dockerfiles. The base which I build and tag as node:local:

FROM debian:wheezy

ENV NODE_VERSION 0.11.14
ENV NPM_VERSION 2.1.4

RUN apt-get update \
    && apt-get install -y --no-install-recommends curl \
    && curl "http://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz" | tar xzf - -C /usr/local --strip-components=1 \
    && apt-get remove -y --purge curl \
    && rm -rf /var/lib/apt/lists/*

EXPOSE 80

CMD [ "node" ]

And here's the one which contains my Node app, modified to demo the error:

FROM node:local

#COPY app /var/lib/app

#WORKDIR /var/lib/app

#Install tools needed to build node packages
RUN apt-get update && apt-get install -y --no-install-recommends build-essential python2.7 libpq-dev \
    && rm -rf /var/lib/apt/lists/* \
    && npm install -g node-gyp

ENV PYTHON /usr/bin/python2.7

#CMD ["npm", "start"]
CMD ["npm", "install", "libpq"]
brianc commented 9 years ago

is that pg_config output from the postgres box or the node box?

EliSnow commented 9 years ago

Node

On Thu, Nov 20, 2014 at 4:31 PM, Brian C notifications@github.com wrote:

is that pg_config output from the postgres box or the node box?

— Reply to this email directly or view it on GitHub https://github.com/brianc/node-libpq/issues/6#issuecomment-63899732.

brianc commented 9 years ago

dang - something going on with the version reported in your libpq-fe.h file on the node box.

If you look here you can see I conditionally omit those fields if your version of postgres is > 9

https://github.com/brianc/node-libpq/blob/master/src/connection.cc#L384

I wonder if PG_DIAG_SCHEMA was added in a later version of postgres...lemme check....

yup! Wasn't added until libpq-fe.h v 9.3! I can fix this...gimme a few min...

brianc commented 9 years ago

This outta do the trick! Gonna wait for travis & then build a new patch version. Mind giving it a test?

EliSnow commented 9 years ago

I'd be happy to. I may not get to it till tomorrow, FYI.

On Thu, Nov 20, 2014 at 4:42 PM, Brian C notifications@github.com wrote:

This outta do the trick! Gonna wait for travis & then build a new patch version. Mind giving it a test?

— Reply to this email directly or view it on GitHub https://github.com/brianc/node-libpq/pull/6#issuecomment-63901115.

brianc commented 9 years ago

k - no worries - pushing a new version of libpq now. Once it works for you I'll update pg-native to work with it as well. :)

brianc commented 9 years ago

Okay! It's up in npm as libpq@1.3.1

brianc commented 9 years ago

apparently i can't re-open this issue after I merged the pull request, but I'll consider it open in my :heart: until I hear back from you. Please don't :broken_heart: me!

EliSnow commented 9 years ago

I lied I was able to check it sooner than tomorrow. It looks good. I look forward to seeing the change in pg-native.

On Thu, Nov 20, 2014 at 4:47 PM, Brian C notifications@github.com wrote:

apparently i can't re-open this issue after I merged the pull request, but I'll consider it open in my [image: :heart:] until I hear back from you. Please don't [image: :broken_heart:] me!

— Reply to this email directly or view it on GitHub https://github.com/brianc/node-libpq/pull/6#issuecomment-63901681.

brianc commented 9 years ago

:dancer: :tada: Releasing new pg-native right now!