Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using node-oracledb on OS X without having DYLD_LIBRARY_PATH set? #149

Closed
cjbj opened this issue Jul 28, 2015 · 35 comments
Closed

Using node-oracledb on OS X without having DYLD_LIBRARY_PATH set? #149

cjbj opened this issue Jul 28, 2015 · 35 comments

Comments

@cjbj
Copy link
Member

cjbj commented Jul 28, 2015

Have any OS X users played with the node-oracledb build or with install_name_tool and made it so that DYLD_LIBRARY_PATH isn't needed? I did a little initial investigation, see https://blogs.oracle.com/opal/entry/installing_node_oracledb_on_os
Would this seem reasonable to 'officially' document?

@cjbj cjbj added the question label Jul 28, 2015
@cjbj
Copy link
Member Author

cjbj commented Jul 31, 2015

Are there no OS X users out there?!

@ecowden
Copy link

ecowden commented Jul 31, 2015

I'm on OS X. Sorry, I've been busy getting started with a new project this week, but I'll try this out over the weekend.

@wesleyeff
Copy link

I had been having a really hard time getting this node module running on OS X. I'm running the OS X 10.11 el capitan beta and I read somewhere (unconfirmed) that you cannot create DYLD variables or something. This script worked great to get everything set up and working for me.

@cjbj
Copy link
Member Author

cjbj commented Aug 23, 2015

@wesleyeff can you describe your problems? Did you try the steps in my blog post https://blogs.oracle.com/opal/entry/installing_node_oracledb_on_os ? From what I read about 10.11 you can still use DYLD variables but there are restrictions on passing them to subshells, which mainly affects shell scripts, see rust-lang/cargo#1816

@wesleyeff
Copy link

I was originally using the instructions here, https://github.com/oracle/node-oracledb but I couldn't get the oracle instant client libraries working. As soon as I found your blog post and tried your script it worked perfectly for me. I definitely think it should be added to the documentation.

@cjbj
Copy link
Member Author

cjbj commented Aug 24, 2015

@wesleyeff What bit wasn't working? The build? The runtime? How were you invoking Node? What environment did you have set?

@wesleyeff
Copy link

@cjbj On this page, https://github.com/oracle/node-oracledb/blob/master/INSTALL.md#instosx where you set these environment variables: DYLD_LIBRARY_PATH, OCI_LIB_DIR and OCI_INC_DIR is where I was having problems. For example when I would do this: export DYLD_LIBRARY_PATH=/opt/oracle/instantclient:$DYLD_LIBRARY_PATH and then close and re open the terminal app the DYLD_LIBRARY_PATH variable would be empty. The same thing happened for OCI_LIB_DIR, and OCI_INC_DIR. because of this when I would run node app.js I would get the same error that you describe in your blog post here: https://blogs.oracle.com/opal/entry/installing_node_oracledb_on_os.

Sorry I'm not very good at describing this. Let me know if you have any other questions.

@cjbj
Copy link
Member Author

cjbj commented Aug 24, 2015

@wesleyeff I totally wouldn't expect environment variables to remain set if you reopen a terminal. You would need to set them in whatever shell startup script you use, e.g. $HOME/.bash_profile.
Can you try setting them there and see if they work with 10.11?
Note OCI_INC_DIR & OCI_LIB_DIR are only needed for installation, so you probably don't need to set these (unless you do a lot of installs).

@wesleyeff
Copy link

@cjbj Ok, I added the DYLD_LIBRARY_PATH to my .bash_profile and it is now working without using the osxinstall.sh script on 10.11.

@cjbj
Copy link
Member Author

cjbj commented Aug 25, 2015

@wesleyeff thanks for the testing. I'll make a note to improve the doc.

@akiellor
Copy link

Just did this installation today, its very far from a simple 'npm install'. Understandable that there are licensing issues, but its a pain none the less.

  • The documentation was accurate and helpful.

@cjbj
Copy link
Member Author

cjbj commented Aug 26, 2015

@akiellor thanks for the feedback. The first million times are the worst.

@cjbj cjbj closed this as completed Sep 9, 2015
@akiellor
Copy link

akiellor commented Sep 9, 2015

Was this closed with a resolution?

@cjbj
Copy link
Member Author

cjbj commented Sep 9, 2015

@akiellor the base question was mine about whether to augment the doc, then the thread got hijacked a bit. Feel free to open a new issue if you have a question.

@cristobal
Copy link

Why is this issue closed?
I guess we should augment the docs for now.

But in the long term DYLD_LIBRARY_PATH dependency must be removed somehow, currently i would state that the usage of DYLD_LIBRARY_PATH is a deprecated feature...

For those that need to disable SIP on El Capitan use the csrutil from the terminal in "OS X Recovery mode as explained here.

@ecowden
Copy link

ecowden commented Oct 5, 2015

Apologies for taking so long. Between work and planning a wedding, time has been sparse!

The good news: I was able to get it working. 👍

The bad news: this is still a pretty crummy setup. I hate to say this, but with the new El Capitan update, the setup has gone from, “crummy but workable" to "eee gads, yuck." Sorry, I'm trying to be nice but honest! 😁

Besides the additional frustration of saying, "hey, go download a script from a blog post, edit it and run it" as part of a project setup. I see two problems:

  1. We tend to work with lots of small projects. That means the script needs to be run individually for each one, or we need to manage copying around folders. Simple dependency management is a big deal for us.
  2. The oracledb dependency now must not be in our package.json for Mac developers since it would try to install it as a normal npm dependency. That further complicates usage across platforms, on the build server, etc. We might be able to get away with optionalDependencies for a while, but it's definitely a hack.

But flipping back to good news, I'm optimistic about the progress with #18! Please please please please prioritize this! 😁

@cristobal
Copy link

Tried out the script it works on my installation of El Capitan.
Modified the scripts to suits our needs on our project, since we both roll out on OS X and Linux.

Besides pulling out the $VER string in the script from:

VER=`ls $IC_DIR/libclntsh.dylib.* | sed s/[^0-9]*//`

to:

VER=`ls $IC_DIR/libclntsh.dylib.* | awk '{print $NF'} | xargs basename | sed s/libclntsh.dylib.//g`

Since just using sed messed up the $VER string on my machine.

@cristobal
Copy link

Further thinking on the topic why should the oracledb client depend on the LD_LIBRARY_PATH at all. Currently it has been removed on OS X, and it has been recommended to be avoided on Linux for a while.

Should I set LD_LIBRARY_PATH
Avoiding LD_LIBRARY_PATH

I guess it's due to that the instantclient is already precompiled. Which would require to compile it as part of the node oracledb client, is it possible? Otherwise one would require to have postinstall step for OS X only. Any ideas?

As it is now is not the best solution. Having so many system dependent steps and quirks just makes it troublesome for people to install this client at all. If it's possible to reconcile the system dependent steps and compile the instantclient as part of the installation of the node oracledb client it should be done, in my opinion.

@kubo
Copy link

kubo commented Oct 13, 2015

I made document, which doesn't use the script.
It uses fix_oralib.rb instead.
https://gist.github.com/kubo/aeabbbcd7b8cbda49531#file-install_node-oracledb_on_elcapitan-md

@cjbj
Copy link
Member Author

cjbj commented Oct 14, 2015

@cristobal thanks for the VER fix.

@kubo thanks for jumping in.

I like the comment on Avoiding LD_LIBRARY_PATH:
"Linkers and libraries require very good understanding of the link editor, of the Executable and Linking Format (ELF) and of how the whole process works; this is some highly specialized knowledge, and most "developers" today don't have a clue about it." This is why I'm waiting to hear from our internal Apple folk before blessing any solution.

@luizlugo
Copy link

Hi I'm having the following error when tried to run with El Capitan osx

dyld: lazy symbol binding failed: Symbol not found: _OCIClientVersion

Could you please help me?

Regards

@cjbj
Copy link
Member Author

cjbj commented Dec 15, 2015

@luizlugo please start a new issue.

@cjbj
Copy link
Member Author

cjbj commented Dec 18, 2015

For OS X El Capitan, what about these steps? Anyone see any (new!) issues:

Get Oracle Instant Client

cd /tmp
Download and extract the following ZIP files from http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html
unzip instantclient-basic-macos.x64-11.2.0.4.0.zip
unzip instantclient-sdk-macos.x64-11.2.0.4.0.zip

As root, copy the OCI libraries to /usr/local/lib

cd /tmp/instantclient_11_2
cp libclntsh.dylib.11.1 libnnz11.dylib libociei.dylib /usr/local/lib/
ln -s /usr/local/lib/libclntsh.dylib.11.1 /usr/local/lib/libclntsh.dylib

Install node-oracledb as a normal user

export OCI_LIB_DIR=/usr/local/lib
export OCI_INC_DIR=/tmp/instantclient_11_2/sdk/include
npm install oracledb

Clean up

rm -rf /tmp/instantclient_12_1
unset OCI_LIB_DIR OCI_INC_DIR

@kubo
Copy link

kubo commented Dec 20, 2015

@cjbj
IMO, it is perfect.

The following steps are also okay.

Get Oracle Instant Client

cd /tmp
Download and extract the following ZIP files from http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html
unzip instantclient-basic-macos.x64-11.2.0.4.0.zip
unzip instantclient-sdk-macos.x64-11.2.0.4.0.zip
ln -s libclntsh.dylib.11.1 /tmp/instantclient_11_2/libclntsh.dylib

Install node-oracledb as a normal user

export OCI_LIB_DIR=/tmp/instantclient_11_2
export OCI_INC_DIR=/tmp/instantclient_11_2/sdk/include
npm install oracledb

As root, copy the OCI libraries to /usr/local/lib

cd /tmp/instantclient_11_2
cp libclntsh.dylib.11.1 libnnz11.dylib libociei.dylib /usr/local/lib/

Clean up

rm -rf /tmp/instantclient_12_1
unset OCI_LIB_DIR OCI_INC_DIR

@cjbj
Copy link
Member Author

cjbj commented Dec 21, 2015

@kubo, since node-oracledb's installer defaults to use /opt/oracle/instantclient the following is easier. It also uses sym links in /usr/local/lib which is easier to maintain & cleanup as needed, and keeps the SDK for future node-oracledb upgrades.

Install Instant Client 11.2 as root:

sudo su -
mkdir /opt/oracle
cd /opt/oracle
Download and extract the following ZIP files from http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html
unzip instantclient-basic-macos.x64-11.2.0.4.0.zip
unzip instantclient-sdk-macos.x64-11.2.0.4.0.zip

mv instantclient_11_2 /opt/oracle/instantclient
ln -s /opt/oracle/instantclient/libclntsh.dylib.11.1 /opt/oracle/instantclient/libclntsh.dylib
ln -s /opt/oracle/instantclient/{libclntsh.dylib.11.1,libnnz11.dylib,libociei.dylib} /usr/local/lib/

Clean up if desired:

rm instantclient-*.zip

Install node-oracle (which defaults to use /opt/oracle/instantclient):

[as a normal user]

npm install oracledb

@cjbj
Copy link
Member Author

cjbj commented Dec 21, 2015

I've documented these steps in INSTALL.

(Other work is ongoing on how Instant Client itself is built)

@cjbj cjbj closed this as completed Dec 21, 2015
@raymondfeng
Copy link

@cjbj To not require root access, we can install Oracle instant client for a regular user (for example, ~/opt/oracle/instantclient) and create symbolic links in ~/lib to reference dylibs as follows:

libclntsh.dylib.11.1 -> /Users/rfeng/opt/oracle/instantclient/libclntsh.dylib.11.1
libnnz11.dylib -> /Users/rfeng/opt/oracle/instantclient/libnnz11.dylib
libociei.dylib -> /Users/rfeng/opt/oracle/instantclient/libociei.dylib

@cjbj
Copy link
Member Author

cjbj commented Jan 11, 2016

@raymondfeng Magic. Though OCI_INC_DIR & OCI_LIB_DIR will need to be set during installation since the node-oracledb default location /opt/oracle/instantclient isn't being used. Do you have a reference on SIP and ~/lib?

(For future readers, this is regarding Instant Client 11.2. There should be more flexibility with Instant Client 12.1 when it is released on OS X)

@raymondfeng
Copy link

See https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/UsingDynamicLibraries.html

Installing Dependent Libraries

Before you can use a dynamic library as a dependent library, the library and its header files must be installed on your computer. The standard locations for header files are ~/include, /usr/local/include and /usr/include. The standard locations for dynamic libraries are ~/lib, /usr/local/lib, and /usr/lib.

@cjbj
Copy link
Member Author

cjbj commented Jan 12, 2016

@raymondfeng useful but last updated in 2012, pre-SIP.
I wish there was more on SIP around.

@raymondfeng
Copy link

The key is that SIP is happy with ~/lib ($HOME/lib) without messing around /usr/local/lib or /usr/lib. My test confirmed it.

@cjbj
Copy link
Member Author

cjbj commented Jan 12, 2016

@raymondfeng I also tested it, so it must be true (!) It's worth adding it to INSTALL.

@cjbj
Copy link
Member Author

cjbj commented May 27, 2016

Instant Client 12.1 for OS X is now available from: http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html

Updated installation instructions are at: http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html#ic_osx_inst

@yogithesymbian
Copy link

npm install oracledb

74 error oracledb ERR! NJS-067: a pre-built node-oracledb binary was not found for darwin arm64

@cjbj
Copy link
Member Author

cjbj commented Jun 21, 2021

@yogithesymbian please open new issues for new problems. But search the repo first: #1349

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants