weixin_39756235
2020-11-30 19:29 阅读 124

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

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.

该提问来源于开源项目:oracle/node-oracledb

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

40条回答 默认 最新

  • weixin_39638929 weixin_39638929 2020-11-30 19:29

    What's your OS version?

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

    点赞 评论 复制链接分享
  • weixin_39969028 weixin_39969028 2020-11-30 19:29

    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.

    点赞 评论 复制链接分享
  • weixin_39638929 weixin_39638929 2020-11-30 19:29

    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).

    点赞 评论 复制链接分享
  • weixin_39969028 weixin_39969028 2020-11-30 19:29

    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: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.**

    点赞 评论 复制链接分享
  • weixin_39969028 weixin_39969028 2020-11-30 19:29

    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.

    点赞 评论 复制链接分享
  • weixin_39638929 weixin_39638929 2020-11-30 19:29

    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.

    点赞 评论 复制链接分享
  • weixin_39605191 weixin_39605191 2020-11-30 19:29

    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.

    点赞 评论 复制链接分享
  • weixin_39886251 weixin_39886251 2020-11-30 19:29

    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.

    点赞 评论 复制链接分享
  • weixin_39638929 weixin_39638929 2020-11-30 19:29

    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.

    点赞 评论 复制链接分享
  • weixin_39606177 weixin_39606177 2020-11-30 19:29

    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

    点赞 评论 复制链接分享
  • weixin_39638929 weixin_39638929 2020-11-30 19:29

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

    点赞 评论 复制链接分享
  • weixin_39756235 weixin_39756235 2020-11-30 19:29

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

    点赞 评论 复制链接分享
  • weixin_39587029 weixin_39587029 2020-11-30 19:29

    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).

    点赞 评论 复制链接分享
  • weixin_39587029 weixin_39587029 2020-11-30 19:29

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

    点赞 评论 复制链接分享
  • weixin_39967670 weixin_39967670 2020-11-30 19:29

    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.

    点赞 评论 复制链接分享
  • weixin_39638929 weixin_39638929 2020-11-30 19:29

    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.

    点赞 评论 复制链接分享
  • weixin_39638929 weixin_39638929 2020-11-30 19:29

    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)?

    点赞 评论 复制链接分享
  • weixin_39932611 weixin_39932611 2020-11-30 19:29

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

    点赞 评论 复制链接分享
  • weixin_39638929 weixin_39638929 2020-11-30 19:29
    点赞 评论 复制链接分享
  • weixin_39953629 weixin_39953629 2020-11-30 19:29

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

    点赞 评论 复制链接分享
  • weixin_39869593 weixin_39869593 2020-11-30 19:29

    Hi! I am having similar issues! I upgraded to Catalina. 19_3 stopped working. I tried to connect to the database, using cx_Oracle client. I get the following error:
    error msgDPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1) Python, cx_Oracle Client and cx_oracle are 64 bit. Gave permissions (777) to /opt/oracle. I'm not using unbundled Python

    点赞 评论 复制链接分享
  • weixin_39638929 weixin_39638929 2020-11-30 19:29

    this is the repo for node-oracledb. The cx_Oracle issue you want is here.

    点赞 评论 复制链接分享
  • weixin_39869593 weixin_39869593 2020-11-30 19:29

    thanks!

    点赞 评论 复制链接分享
  • weixin_39967670 weixin_39967670 2020-11-30 19:29

    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 #231)?

    Yes, when the LD_LIBRARY_PATH is set, it will propagate to all subshells. 🥇

    点赞 评论 复制链接分享
  • weixin_39828847 weixin_39828847 2020-11-30 19:29

    I followed below steps to fix this issue: 1. Uninstall node-oracledb. -> npm uninstall oracledb 2. Install it again with use python option: npm install --python=/python-2.7/bin/python oracledb 3. set LD_LIBRARY_PATH: export LD_LIBRARY_PATH=~/lib:/instantclient_19_3 4. Open System Preferences -> General Tab. Keep it open. 5. Try connecting to Oracle database. 6. You will get 'Developer Unverified' message. Check System Preferences window and click Allow Anyway. Repeat it for all 3-4 libraries. 7. BOOM!

    点赞 评论 复制链接分享
  • weixin_39638929 weixin_39638929 2020-11-30 19:29

    what Node.js version did you use? And did you need to do both 2 & 3, or would just 3 have worked?

    点赞 评论 复制链接分享
  • weixin_39828847 weixin_39828847 2020-11-30 19:29

    what Node.js version did you use? And did you need to do both 2 & 3, or would just 3 have worked?

    I'm on Node v14.2, macOS Catalina v10.15. Although I did both 2 and 3, it seems only 3 would have worked. However steps 4,5,6 are required.

    点赞 评论 复制链接分享
  • weixin_39638929 weixin_39638929 2020-11-30 19:29

    I found the variable didn't propagate to subshells. thanks for the update. I didn't need to force the use of Python 2.

    
    orcl test % cat v.js
    
    const oracledb = require('oracledb');
    const config = { user: 'cj', password: 'cj', connectString: 'localhost/orclpdb1' };
    
    async function run() {
      let connection;
    
      try {
        connection = await oracledb.getConnection(config);
        const result = await connection.execute(`SELECT TO_CHAR(CURRENT_DATE, 'DD-Mon-YYYY HH24:MI') AS D FROM DUAL`);
        console.log(result);
      } catch (err) {
        console.error(err);
      } finally {
        if (connection) {
          try {
        await connection.close();
          } catch (err) {
        console.error(err);
          }
        }
      }
    }
    
    run();
    

    Without any environment set the oracle client isn't found:

    
    orcl test % node v.js
    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
    [ . . .]
    

    With LD_LIBRARY_PATH set the client was found. (The ORA error was expected, since I didn't have a DB running. But it does show that node-oracledb found Instant Client):

    
    orcl test % export LD_LIBRARY_PATH=$HOME/instantclient_19_3
    
    orcl test % node v.js
    node v.js
    [Error: ORA-12547: TNS:lost contact] { errorNum: 12547, offset: 0 } 
    

    In a subshell the LD_LIBRARY_PATH variable was ignored:

    
    orcl test % cat t.sh
    #!/bin/sh
    node v.js
    
    orcl test % ./t.sh
    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
    [ . . .]
    

    If I set LD_LIBRARY_PATH in t.sh the app worked.

    We have some other alternative ways that you can configure node-oracledb to find Instant Client.coming in node-oracledb 5. They'll probably get pushed to the master branch at the end of the week.

    点赞 评论 复制链接分享
  • weixin_39828847 weixin_39828847 2020-11-30 19:29

    I just wanted to give you an update. While I was able to run my app through 'node' command (after doing all the steps I mentioned above), I wasn't able to run it through nodemon.

    I had to finally turn off System Integrity Protection in Mac to make that work.

    点赞 评论 复制链接分享
  • weixin_39638929 weixin_39638929 2020-11-30 19:29

    the fact that it didn't work in nodemon is not surprising, since the LD_LIBRARY_PATH variable won't propagate.

    I don't like the idea of turning off SIP.

    Try using the feature we just pushed to the master branch. Use npm install oracle/node-oracledb.git#master to compile & build the module, see Installing GitHub clones and zip files.

    Then you can do something like this:

    
    ln -s ~/instantclient_19_3/libclntsh.dylib node_modules/oracledb/build/Release
    

    or use the new method:

    javascript
    const oracledb = require('oracledb');
    try {
      oracledb.initOracleClient({libDir: '/Users/your_username/instantclient_19_3'});
    } catch (err) {
      console.error('Whoops!');
      console.error(err);
      process.exit(1);
    }
    

    The development doc is here.

    Note to other readers: On Linux, using initOracleClient() like the above example won't do what you think it will do with current Oracle client libraries: you still need to use ldconfig or set LD_LIBRARY_PATH.

    点赞 评论 复制链接分享
  • weixin_39638929 weixin_39638929 2020-11-30 19:29

    And note with node-oracledb 5.0.0-dev on macOS that putting Instant Client in ~/lib will mostly not be usable, depending on your Node.js version and macOS version.

    点赞 评论 复制链接分享
  • weixin_39623716 weixin_39623716 2020-11-30 19:29

    I am having the same issue...

    my system and versions macOS catalina node v12.18.0 npm v6.14.4 oracle instant client v19.3.0.0.0 oracledb v4.2.0

    after reading this thread would the recommended solution for me be to follow the steps in a post above?

    -Uninstall node-oracledb. -> npm uninstall oracledb
    -Install it again with use python option:
    -npm install --python=<your_path>/python-2.7/bin/python oracledb
    - set LD_LIBRARY_PATH:
         export LD_LIBRARY_PATH=~/lib:<your_path>/instantclient_19_3
    -Open System Preferences -> General Tab. Keep it open.
    -Try connecting to Oracle database.
    -You will get 'Developer Unverified' message. Check System Preferences window and click              Allow Anyway.
    

    -Repeat it for all 3-4 libraries.

    点赞 评论 复制链接分享
  • weixin_39638929 weixin_39638929 2020-11-30 19:29

    Probably not. I don't believe you need to recompile - I didn't.

    点赞 评论 复制链接分享
  • weixin_39623716 weixin_39623716 2020-11-30 19:29

    I solved my issues by following these steps on mac with Catalina: - downgrading to node 12.16.1 from 12.18 with these commands - "sudo npm cache clean -f" - "sudo npm install -g n" - "sudo n 12.16.1" - copied all the instantclient_19_3 files into /opt/oracle with this command - "sudo cp /Users/myuser/instantclient_19_3/* ." - then had to click "allow anyway" with all the unverified files, in the security/privacy general pane in system preferences

    点赞 评论 复制链接分享
  • weixin_39638929 weixin_39638929 2020-11-30 19:29

    do you happen to have DYLD_LIBRARY_PATH or similar set somewhere? I don't see how copying the Instant Client to /opt would help without this.

    I didn't have to downgrade or install globally. With 14.4 on Catalina using node-oracledb 4.2 I could simply set DYLD_LIBRARY_PATH to the location of my Instant Client files. Plus do the 'allow' clickthrough for the Instant Client libraries.

    With the upcoming node-oracledb 5 (that you can currently compile from the master branch), there were the other options I mention earlier in this issue.

    点赞 评论 复制链接分享
  • weixin_39623716 weixin_39623716 2020-11-30 19:29

    Yes, that is another step I had forgotten to mention thanks, so setting DYLD_LIBRARY_PATH in the same terminal as I was running the npm script with this command - DYLD_LIBRARY_PATH='path to instantclient files'

    点赞 评论 复制链接分享
  • weixin_39677104 weixin_39677104 2020-11-30 19:29

    This is working for me after a lot of troubleshooting. I think the whole issue is caused by MacOS Gatekeeper. It is silently denying access to the client executable.

    I followed deepanksinghal's steps noted above: Uninstall node-oracledb. -> npm uninstall oracledb Install it again with use python option: npm install --python=/python-2.7/bin/python oracledb set LD_LIBRARY_PATH: export LD_LIBRARY_PATH=~/lib:/instantclient_19_3

    Then because on Mojave I don't get an option to approve running the software I needed to run sudo spctl --master-disable in terminal.

    Now everything works.

    点赞 评论 复制链接分享
  • weixin_39533361 weixin_39533361 2020-11-30 19:29

    Try using the feature we just pushed to the master branch. Use npm install oracle/node-oracledb.git#master to compile & build the module, see Installing GitHub clones and zip files.

    This resolved it for me. , When do you expect the 5.0 branch to be published to NPM?

    Thanks.

    点赞 评论 复制链接分享
  • weixin_39638929 weixin_39638929 2020-11-30 19:29

    thanks for the confirmation.

    We are at feature freeze for 5.0.0-dev

    If you get a chance to run some testing with it and let us know how it behaves, that would help us get it out sooner.

    点赞 评论 复制链接分享
  • weixin_39638929 weixin_39638929 2020-11-30 19:29

    as you might have seen from other Issue updates, node-oracledb 5 is on npm. Check out the new macOS installation doc and new initialization doc.

    点赞 评论 复制链接分享

相关推荐