Closed janvda closed 1 year ago
FYI
I am using docker image: nodered/node-red:2.2.3-16
I have installed packages
RUN apk add alpine-sdk libc6-compat linux-pam libxml2 python2 sudo loksh
I have installed ibm_db in folder /data/node_modules
by entering following commands as user node-red
(so not as root user).
cd /data
npm install ibm_db
I have same problem with alpine image: node:14-alpine3.14
.
I could install it node ibm_db
Then I had to install following packages to fix errors but this didn't fix. I am still getting segmentation fault.
apk add libc6-compat linux-pam libxml2
The error logs:
/data/node_modules/ibm_db/test # node test-connection-object.js
/data/node_modules/bindings/bindings.js:121
throw e;
^
Error: Error loading shared library libcrypt.so.1: No such file or directory (needed by /data/node_modules/ibm_db/build/Release/../../installer/clidriver/lib/libdb2.so.1)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:101:18)
at bindings (/data/node_modules/bindings/bindings.js:112:48)
at Object.<anonymous> (/data/node_modules/ibm_db/lib/odbc.js:57:31)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32) {
code: 'ERR_DLOPEN_FAILED'
}
/data/node_modules/ibm_db/test # apk add libc6-compat
(1/1) Installing libc6-compat (1.2.2-r3)
OK: 261 MiB in 63 packages
/data/node_modules/ibm_db/test # node test-connection-object.js
/data/node_modules/bindings/bindings.js:121
throw e;
^
Error: Error loading shared library libpam.so.0: No such file or directory (needed by /data/node_modules/ibm_db/build/Release/../../installer/clidriver/lib/libdb2.so.1)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:101:18)
at bindings (/data/node_modules/bindings/bindings.js:112:48)
at Object.<anonymous> (/data/node_modules/ibm_db/lib/odbc.js:57:31)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32) {
code: 'ERR_DLOPEN_FAILED'
}
/data/node_modules/ibm_db/test # apk add linux-pam
(1/1) Installing linux-pam (1.5.1-r1)
Executing busybox-1.33.1-r7.trigger
OK: 262 MiB in 64 packages
/data/node_modules/ibm_db/test # node test-connection-object.js
/data/node_modules/bindings/bindings.js:121
throw e;
^
Error: Error loading shared library libxml2.so.2: No such file or directory (needed by /data/node_modules/ibm_db/build/Release/../../installer/clidriver/lib/libdb2.so.1)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:101:18)
at bindings (/data/node_modules/bindings/bindings.js:112:48)
at Object.<anonymous> (/data/node_modules/ibm_db/lib/odbc.js:57:31)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32) {
code: 'ERR_DLOPEN_FAILED'
}
/data/node_modules/ibm_db/test # apk add libxml2
(1/1) Installing libxml2 (2.9.14-r2)
OK: 263 MiB in 65 packages
/data/node_modules/ibm_db/test # node test-connection-object.js
Segmentation fault (core dumped)
/data/node_modules/ibm_db/test #
Output of npm list
/data/node_modules # npm list
/data
`-- ibm_db@3.0.0
+-- axios@0.26.1
| `-- follow-redirects@1.15.2
+-- big-integer@1.6.51
+-- bindings@1.5.0
| `-- file-uri-to-path@1.0.0
+-- fs-extra@8.1.0
| +-- graceful-fs@4.2.10
| +-- jsonfile@4.0.0
| | `-- graceful-fs@4.2.10 deduped
| `-- universalify@0.1.2
+-- fstream@1.0.12
| +-- graceful-fs@4.2.10 deduped
| +-- inherits@2.0.4
| +-- mkdirp@0.5.6
| | `-- minimist@1.2.7
| `-- rimraf@2.7.1
| `-- glob@7.2.3
| +-- fs.realpath@1.0.0
| +-- inflight@1.0.6
| | +-- once@1.4.0 deduped
| | `-- wrappy@1.0.2
| +-- inherits@2.0.4 deduped
| +-- minimatch@3.1.2
| | `-- brace-expansion@1.1.11
| | +-- balanced-match@1.0.2
| | `-- concat-map@0.0.1
| +-- once@1.4.0
| | `-- wrappy@1.0.2 deduped
| `-- path-is-absolute@1.0.1
+-- lodash@4.17.21
+-- nan@2.17.0
+-- q@1.5.1
+-- targz@1.0.1
| `-- tar-fs@1.16.3
| +-- chownr@1.1.4
| +-- mkdirp@0.5.6 deduped
| +-- pump@1.0.3
| | +-- end-of-stream@1.4.4
| | | `-- once@1.4.0 deduped
| | `-- once@1.4.0 deduped
| `-- tar-stream@1.6.2
| +-- bl@1.2.3
| | +-- readable-stream@2.3.7 deduped
| | `-- safe-buffer@5.2.1
| +-- buffer-alloc@1.2.0
| | +-- buffer-alloc-unsafe@1.1.0
| | `-- buffer-fill@1.0.0
| +-- end-of-stream@1.4.4 deduped
| +-- fs-constants@1.0.0
| +-- readable-stream@2.3.7 deduped
| +-- to-buffer@1.1.1
| `-- xtend@4.0.2
`-- unzipper@0.10.11
+-- big-integer@1.6.51 deduped
+-- binary@0.3.0
| +-- buffers@0.1.1
| `-- chainsaw@0.1.0
| `-- traverse@0.3.9
+-- bluebird@3.4.7
+-- buffer-indexof-polyfill@1.0.2
+-- duplexer2@0.1.4
| `-- readable-stream@2.3.7 deduped
+-- fstream@1.0.12 deduped
+-- graceful-fs@4.2.10 deduped
+-- listenercount@1.0.1
+-- readable-stream@2.3.7
| +-- core-util-is@1.0.3
| +-- inherits@2.0.4 deduped
| +-- isarray@1.0.0
| +-- process-nextick-args@2.0.1
| +-- safe-buffer@5.1.2 extraneous
| +-- string_decoder@1.1.1
| | `-- safe-buffer@5.1.2 extraneous
| `-- util-deprecate@1.0.2
`-- setimmediate@1.0.5
npm ERR! extraneous: safe-buffer@5.1.2 /data/node_modules/readable-stream/node_modules/safe-buffer
npm ERR! extraneous: safe-buffer@5.1.2 /data/node_modules/string_decoder/node_modules/safe-buffer
/data/node_modules
I didn't get a segmentation fault when using the default image : node
The command I used to start the container =
docker run node sh -c 'while sleep 3600; do :; done'
Note that this image contained everything. So I didn't need to install any additional packages.
This is the output:
root@f5dfaca57cf6:/data# npm install ibm_db
added 60 packages, and audited 61 packages in 1m
4 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
root@f5dfaca57cf6:/data# ls
node_modules package-lock.json package.json
root@f5dfaca57cf6:/data# cd node_modules/
root@f5dfaca57cf6:/data/node_modules# ls
axios buffer-alloc core-util-is fstream listenercount process-nextick-args tar-fs wrappy
balanced-match buffer-alloc-unsafe duplexer2 glob lodash pump tar-stream xtend
big-integer buffer-fill end-of-stream graceful-fs minimatch q targz
binary buffer-indexof-polyfill file-uri-to-path ibm_db minimist readable-stream to-buffer
bindings buffers follow-redirects inflight mkdirp rimraf traverse
bl chainsaw fs-constants inherits nan safe-buffer universalify
bluebird chownr fs-extra isarray once setimmediate unzipper
brace-expansion concat-map fs.realpath jsonfile path-is-absolute string_decoder util-deprecate
root@f5dfaca57cf6:/data/node_modules# cd ibm_db/test/
root@f5dfaca57cf6:/data/node_modules/ibm_db/test# node test-connection-object.js
node:assert:124
throw new AssertionError(obj);
^
AssertionError [ERR_ASSERTION]: [Error: [IBM][CLI Driver] SQL1336N The remote host "waldevdbclnxtst06.dev.rocketsoftware.com" was not found. SQLSTATE=08001
] {
error: '[ibm_db] SQL_ERROR',
sqlcode: -1336,
state: '08001'
} == null
at /data/node_modules/ibm_db/test/test-connection-object.js:8:10
at /data/node_modules/ibm_db/lib/odbc.js:371:18 {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: [Error: [IBM][CLI Driver] SQL1336N The remote host "waldevdbclnxtst06.dev.rocketsoftware.com" was not found. SQLSTATE=08001
] {
error: '[ibm_db] SQL_ERROR',
sqlcode: -1336,
state: '08001'
},
expected: null,
operator: '=='
}
Node.js v19.1.0
root@f5dfaca57cf6:/data/node_modules/ibm_db/test#
The above error is expected as the default settings didn't point to a DB2 database.
@janvda ibm_db do not work on Alpine Linux. See the issue #217 for details. Thanks.
I have lost a lot of time with this issue.
In the end I got it working by using images based on debian instead of alpine. (e.g. node:19.1.0-bullseye-slim
or node:16-buster-slim
).
If it is not supported on alpine based docker images then it would be good to mention this in the prerequisites section of the readme as the alpine images are very popular due to their reduced size.
Note also that all nodered docker images at docker hub (https://hub.docker.com/r/nodered/node-red) are based on alpine. So you don't immediately have an alternative unless you decide to build node-red yourselves based on debian image (which I actually did).
I also believe that there must be a way to install this properly on alpine. Note also that for the debian based builds I needed to add the following to my dockerfile to get it working:
# fix missing libxml2 and libc.musl-x86_64.so.1 (see https://github.com/alexander-akhmetov/python-telegram/issues/3) and
RUN apt-get update && apt-get install -y musl-dev libxml2
RUN ln -s /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1
@janvda The segmentation fault is because clidriver/lib/libdb2.so.1
is not compatible with libc.musl-x86_64.so.1
. If you run ldd libdb2.so.1
, you'll get the missing symbols.
As mentioned the details in this comment, Alpine Linux is not a supported platform for node ibm_db as we have add this info in the latest documentation of ibm_db. Hence, closing this issue. Thanks.
@janvda If you want it should work on Alpine Linux too in future, please open an idea here https://ideas.ibm.com/new-idea to compile Db2 clidriver using musl gcc for Alpine Linux with Product: Database Portfolio Db2
and Category: Db2 Connect and Drivers
. Thanks.
Alpine docker container:
docker host machine is macbook pro
only PATH is set.
npm install ibm_db
command.ibm_db/test/config.testConnectionStrings.json
file and share complete output of below commands: