node-oracledb icon indicating copy to clipboard operation
node-oracledb copied to clipboard

ERROR: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1)"

Open nandunbandara opened this issue 6 years ago • 43 comments

Hi everyone,

I am trying to setup on the MacOS. I have followed every step according to the installation instructions, but I am getting the error: ERROR: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1)"

Output: Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1): image not found". See https://oracle.github.io/odpi/doc/installation.html#macos for help Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html You must have the 64-bit Oracle Instant Client Basic or Basic Light package in ~/lib or /usr/local/lib They can be downloaded from http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html at OracleDb.createPool (/Users/nandunbandara/Documents/designboo/rnd/verisafe/verisafe-services/verisafe-core-services/node_modules/oracledb/lib/oracledb.js:202:8) at OracleDb.createPool (/Users/nandunbandara/Documents/designboo/rnd/verisafe/verisafe-services/verisafe-core-services/node_modules/oracledb/lib/util.js:185:19) at /Users/nandunbandara/Documents/designboo/rnd/verisafe/verisafe-services/verisafe-core-services/src/driver/oracle/OracleDriver.ts:694:25 at new Promise (<anonymous>) at OracleDriver.<anonymous> (/Users/nandunbandara/Documents/designboo/rnd/verisafe/verisafe-services/verisafe-core-services/src/driver/oracle/OracleDriver.ts:693:16) at step (/Users/nandunbandara/Documents/designboo/rnd/verisafe/verisafe-services/verisafe-core-services/node_modules/tslib/tslib.js:139:27) at Object.next (/Users/nandunbandara/Documents/designboo/rnd/verisafe/verisafe-services/verisafe-core-services/node_modules/tslib/tslib.js:120:57) at /Users/nandunbandara/Documents/designboo/rnd/verisafe/verisafe-services/verisafe-core-services/node_modules/tslib/tslib.js:113:75 at new Promise (<anonymous>) at Object.__awaiter (/Users/nandunbandara/Documents/designboo/rnd/verisafe/verisafe-services/verisafe-core-services/node_modules/tslib/tslib.js:109:16) { errorNum: 0, offset: 0 }

I do understand that this is because the client library is not available. But I have added all the libs in ~/lib. I have set all the env variables as well.

Database version: 11.2.0.1 (on AWS RDS)

`

process.platform 'darwin' process.version 'v12.16.2' process.arch 'x64' require('oracledb').versionString '4.2.0' require('oracledb').oracleClientVersionString Uncaught: Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1): image not found". See https://oracle.github.io/odpi/doc/installation.html#macos for help `

Could you please help me with this? Thank you.

nandunbandara avatar Apr 15 '20 23:04 nandunbandara

What's your OS version?

Show to us that you have everything in ~/lib.

cjbj avatar Apr 15 '20 23:04 cjbj

I'm also finding similar error in nestjs platform on Mac Mojave. I have downloaded Oracle Instant Client(Version 19_3) basic, sdk and sqlplus under $HOME. Then created a ~/lib. ls -al ~/lib (is shown below)

lrwxr-xr-x 1 XXXXXX staff 49 Apr 15 17:10 libclntsh.dylib -> /myhomedirectory/instantclient_19_3/libclntsh.dylib I put ~/lib directory in $PATH.

Then I try to run nestjs app from Visual Studio Code. When I run it I get same error. Am I missing something? Interestingly, I can connect to the remote database from command line with sqlplus.

kpbatman1 avatar Apr 16 '20 01:04 kpbatman1

Since PATH (on macOS and Linux) is for executables, and you don't have any of these in ~/lib, you probably want to set it to /myhomedirectory/instantclient_19_3 which is where the sqlplus binary is.

Try running a Node.js script from the command line prompt (outside VSC).

cjbj avatar Apr 16 '20 02:04 cjbj

Thanks for your reply.

Last two entries of my PATH is "/myhomedirectory/lib:/myhomedirectory/instantclient_19_3" In my test directory I run following:

  1. sqlplus userid/password@address:1521/servicename Works fine....
  2. Then I run the test script connect.js from the same location) - (with dbconfig.js - downloaded from Oracle Instant Client Example) node connect.js I get the same error from command line prompt when I run the node.js script: Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1): image not found". See https://oracle.github.io/odpi/doc/installation.html#macos for help Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html You must have the 64-bit Oracle Instant Client Basic or Basic Light package in ~/lib or /usr/local/lib They can be downloaded from http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html at OracleDb.getConnection (myhomedirectory/Documents/Tests/node_modules/oracledb/lib/oracledb.js:287:10) at /myhomedirectory/Documents/Tests/node_modules/oracledb/lib/util.js:202:16 at new Promise () at OracleDb.getConnection (/myhomedirectory/Documents/Tests/node_modules/oracledb/lib/util.js:190:14) at run (/myhomedirectory/Documents/Tests/connect.js:12:33) at Object. (/myhomedirectory/Documents/Tests/connect.js:29:1) at Module._compile (internal/modules/cjs/loader.js:1156:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10) at Module.load (internal/modules/cjs/loader.js:1000:32) at Function.Module._load (internal/modules/cjs/loader.js:899:14) { errorNum: 0, offset: 0 }

Thanks.**

kpbatman1 avatar Apr 16 '20 15:04 kpbatman1

I have upgraded to Mac Catalina. I have tried with both 19_3 and 18_1 version of Instant Client.

I have put the instantclient_19_3 folder under ~/lib. Also, I had to set LD_LIBRARY_PATH (and not PATH) in .bash_profile. echo $LD_LIBRARY_PATH /myhomedirectory/lib/instantclient_19_3

With this bare-bone program (downloaded from node-oracledb example) : node connect.js
Now I can successfully connect to database (tested with both 19_3 and 18_1).

However, when I run the nestjs app from command line or from VSC - the same problem is coming up. for both versions [Nest] 10517 - 04/16/2020, 3:22:39 PM [TypeOrmModule] Unable to connect to the database. Retrying (1)... +1ms Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1): image not found". See https://oracle.github.io/odpi/doc/installation.html#macos for help Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html You must have the 64-bit Oracle Instant Client Basic or Basic Light package in ~/lib or /usr/local/lib They can be downloaded from http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html

Thanks.

kpbatman1 avatar Apr 16 '20 23:04 kpbatman1

Catalina is not officially supported by current Instant Clients; I am not upgrading yet! Some users have workarounds in https://github.com/oracle/python-cx_Oracle/issues/341 Good luck.

cjbj avatar Apr 17 '20 00:04 cjbj

I Confirm as I had an update yesterday to Catalina. Big change for the environment: the bash shell has been replaced by zsh ... maybe investigate that direction for your problem.

OraDanGus avatar Apr 17 '20 06:04 OraDanGus

Which node version are you using? I changed to node v13.13.0 from v14.0.0 and got it to work. I'm using 18_1 version of Instant Client.

jhtomlee avatar Apr 23 '20 02:04 jhtomlee

The Node.js packages have just changed to notarized builds, which are causing problems for node-oracledb loading libclntsh even on Mojave. I don't have a full picture yet.

cjbj avatar Apr 23 '20 03:04 cjbj

I started having this issue when I recently upgraded to Node v12.16.2. After changing back to v12.16.1 it worked without issue

iorabi avatar Apr 23 '20 15:04 iorabi

Yes, recent versions of Node.js have been compiled differently: https://nodejs.org/en/blog/release/v12.16.2/

cjbj avatar Apr 24 '20 00:04 cjbj

Still could not find a solution to this. So I decided to use a Linux docker image with the libraries. Does the job.

nandunbandara avatar Apr 27 '20 00:04 nandunbandara

I started having this issue when I recently upgraded to Node v12.16.2. After changing back to v12.16.1 it worked without issue

Worked for me as well. I also installed latest python 2.7 - as I understood it right in some cases the prepacked python which comes with macOS may cause issues with node-oracledb during the instalation (node-gyp).

casperle avatar May 06 '20 12:05 casperle

The whole process I have done: https://github.com/oracle/node-oracledb/issues/1244#issuecomment-624646368

casperle avatar May 06 '20 13:05 casperle

Although in the documentation says that you don't need to set the LD_LIBRARY_PATH for an instant client above of 12.1, in Mac OS Catalina you have to set it to your /opt/oracle/instantclient_19_3 directory, if not you will not be able to execute oracle in Node.

reybis avatar May 07 '20 01:05 reybis

@reybis that also seems to work on Mojave, though I haven't tested extensively.

The other thing to try is:

diff --git a/binding.gyp b/binding.gyp
index f6d8d624..b094793f 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -75,7 +75,7 @@
           "GCC_ENABLE_CPP_EXCEPTIONS": "YES",
           "GCC_ENABLE_CPP_RTTI": "YES"
         },
-          "libraries"     : ['-ldl', '-lpthread']
+          "libraries"     : ['-ldl', '-lpthread', '-Wl,-rpath,$$HOME/lib', '-Wl,-rpath,/usr/local/lib']
       }
     ],
     [

and then rebuild node-oracledb. This seems to work on Mojave. I have this in my ~/lib:

libclntsh.dylib -> /Users/cjones/instantclient_19_3/libclntsh.dylib

Any testing would be appreciated, particularly on Catalina.

cjbj avatar May 07 '20 02:05 cjbj

@reybis some questions: On Catalina, did you do anything to SIP or the instant client libraries? Or did you just set LD_LIBRARY_PATH? Does LD_LIBRARY_PATH propagate to subshells for you (see https://github.com/oracle/node-oracledb/issues/231)?

cjbj avatar May 07 '20 10:05 cjbj

Just adding to the thread that I followed @casperle suggestion (https://github.com/oracle/node-oracledb/issues/1244#issuecomment-624646368) and they worked beautifully in a fresh-installed Catalina 10.15.4

rafael-trevisan avatar May 11 '20 04:05 rafael-trevisan

Also see the official Node.js documentation about Catalina.

cjbj avatar May 12 '20 05:05 cjbj

Is there no way to use node-oracledb with node 12.16.2 and Catalina?

dylnclrk avatar May 13 '20 01:05 dylnclrk