ibmdb / node-ibm_db

IBM DB2 and IBM Informix bindings for node
MIT License
188 stars 151 forks source link

I am tryingto install ibm_db in linux and getting error #988

Closed Kaaviya36 closed 3 months ago

Kaaviya36 commented 3 months ago

I am using ibm_db2 in cypress end to end testing. Everything works fine in local and when I try to run the same in linux jenkins I was getting below ELF header error.

Node version used : v18.14.2 npm version used : 9.5.0

Error: /e2e/node_modules/ibm_db/build/Release/odbc_bindings.node: invalid ELF header at Module._extensions..node (node:internal/modules/cjs/loader:1338:18) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at Module.require (node:internal/modules/cjs/loader:1141:19) at require (node:internal/modules/cjs/helpers:110:18) at bindings (/e2e/node_modules/bindings/bindings.js:112:48) at Object. (/e2e/node_modules/ibm_db/lib/odbc.js:57:31) at Module._compile (node:internal/modules/cjs/loader:1254:14) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at Module.require (node:internal/modules/cjs/loader:1141:19) at require (node:internal/modules/cjs/helpers:110:18) at Object. (/e2e/cypress.config.js:4:16) at Module._compile (node:internal/modules/cjs/loader:1254:14) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at Module.require (node:internal/modules/cjs/loader:1141:19) at require (node:internal/modules/cjs/helpers:110:18) at loadFile (/root/.cache/Cypress/12.8.1/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:89:14) at EventEmitter. (/root/.cache/Cypress/12.8.1/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:116:38) Build step 'Execute shell' marked build as failure Finished: FAILURE


so I tried to install ibm_db manually and came with below error


npm ERR! A complete log of this run can be found in: npm ERR! /home/apps/jenkins/.npm/_logs/2024-03-11T04_31_58_177Z-debug-0.log Build step 'Execute shell' marked build as failure Finished: FAILURE

Any help would be greatly appreciated

bimalkjha commented 3 months ago

@Kaaviya36 To avoid ELF header error, you need to delete node_modules directory from your local before pushing the e2e directory on linux jenkins. Your local is different than linux OS and hence binary files are not compatible.

During manual installation of ibm_db, you can see this error in the output log: npm ERR! make: g++: Command not found. Having gcc and make on non-Windows is prerequisite to install ibm_db package. Please install gcc@12 on linux system and then install ibm_db. Thanks.

Kaaviya36 commented 3 months ago

@bimalkjha Thank you so much for the response! I am seeing below error while doing npm install after installing gcc and make.

Step 6/8 : RUN npm install ---> Running in e753f82b0d1c npm ERR! code 1 npm ERR! path /opt/app/node_modules/ibm_db npm ERR! command failed npm ERR! command sh -c node installer/driverInstall.js npm ERR! **** npm ERR! You are downloading a package which includes the Node.js module for IBM DB2/Informix. The module is licensed under the Apache License 2.0. The package also includes IBM ODBC and CLI Driver from IBM, which is automatically downloaded as the node module is installed on your system/device. The license agreement to the IBM ODBC and CLI Driver is available in /opt/app/node_modules/ibm_db/installer/clidriver. Check for additional dependencies, which may come with their own license agreement(s). Your use of the components of the package and dependencies constitutes your acceptance of their respective license agreements. If you do not accept the terms of any license agreement(s), then delete the relevant component(s) from your device. npm ERR! **** npm ERR! npm ERR! Downloading DB2 ODBC CLI Driver from https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz ... npm ERR! npm ERR! 0.03% | 8000 bytes downloaded out of 25388860 bytes. 50.01% | 12696000 bytes downloaded out of 25388860 bytes. 100.00% | 25388860 bytes downloaded out of 25388860 bytes. npm ERR! npm ERR! Downloading and extraction of DB2 ODBC CLI Driver completed successfully. npm ERR! npm ERR! Error: Command failed: node-gyp configure build --IS_DOWNLOADED=true --IBM_DB_HOME="$IBM_DB_HOME" npm ERR! make: g++: No such file or directory npm ERR! make: *** [odbc_bindings.target.mk:120: Release/obj.target/odbc_bindings/src/odbc.o] Error 127 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 (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:514:28) npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12) npm ERR! gyp ERR! System Linux 3.10.0-1160.105.1.el7.x86_64 npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build" "--IS_DOWNLOADED=true" "--IBM_DB_HOME=/opt/app/node_modules/ibm_db/installer/clidriver" npm ERR! gyp ERR! cwd /opt/app/node_modules/ibm_db npm ERR! gyp ERR! node -v v20.6.1 npm ERR! gyp ERR! node-gyp -v v9.4.0 npm ERR! gyp ERR! not ok npm ERR! npm ERR! at ChildProcess.exithandler (node:child_process:422:12) npm ERR! at ChildProcess.emit (node:events:514:28) npm ERR! at maybeClose (node:internal/child_process:1105:16) npm ERR! at ChildProcess._handle.onexit (node:internal/child_process:305:5) { npm ERR! code: 1, npm ERR! killed: false, npm ERR! signal: null, npm ERR! cmd: 'node-gyp configure build --IS_DOWNLOADED=true --IBM_DB_HOME="$IBM_DB_HOME"' npm ERR! }

npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-03-11T17_08_10_192Z-debug-0.log The command '/bin/sh -c npm install' returned a non-zero code: 1 Build step 'Execute shell' marked build as failure Finished: FAILURE


Attaching the full log below for reference

kaaviya_errorlog.txt

bimalkjha commented 3 months ago

@Kaaviya36 We still see below gcc error in the shared output of npm install:

npm ERR! Error: Command failed: node-gyp configure build  --IS_DOWNLOADED=true --IBM_DB_HOME="$IBM_DB_HOME"
npm ERR! make: g++: No such file or directory
npm ERR! make: *** [odbc_bindings.target.mk:120: Release/obj.target/odbc_bindings/src/odbc.o] Error 127
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 (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm ERR! gyp ERR! System Linux 3.10.0-1160.105.1.el7.x86_64

Could you please share output of below commands:

gcc --version
make --version
g++ --version
uname -a

Error says, make is unable to find g++ in the system. Please add location of g++ to PATH env var if it is present in your system. Else, try to upgrade GNU Make 3.82 to the latest version. I see GNU Make 4.2.1 installed in my Linux system. Thanks.

bimalkjha commented 3 months ago

@Kaaviya36 I checked the error log file and it seems you are trying to install ibm_db under some container using docker script. Under container environment, g++ is not part of gcc and hence we need to install it specifically. In your system, g++ package is missing and hence the error. Please install it. We have documented below info under pre-requisite section of ibm_db for linux container: https://github.com/ibmdb/node-ibm_db?tab=readme-ov-file#prerequisite image

So, you need to add g++ or gcc-c++ also in Step 5/8 on your script as below. I am not sure gcc-c++ package or g++ package is available on this linux container. Whichever works, use it and update here.

Step 5/8 : RUN apt-get update      && apt-get install gcc g++ gcc-c++ python3 make -y

Thanks.

Kaaviya36 commented 3 months ago

Thanks @bimalkjha works now!! appreciate your help