roracle11gmacos-high-sierrainstantclientroracle

ROracle not loading Instantclient library on MacOS High Sierra


I have installed Oracle Instant Client 12.1.0.2.0 and am now trying to install ROracle 1.3-1 for R with the following command:

R CMD INSTALL --configure-args='--with-oci-lib=/usr/local/oracle/instantclient12 --with-oci-inc=/usr/local/oracle/instantclient12/sdk/include' ROracle_1.3-1.tar.gz

The Oracle Instant Client is installed in /usr/local/oracle/instantclient12

Unfortunately, I am getting the following error at the end of the ROracle install and have been having a difficult time figuring out what is going wrong:

** testing if installed package can be loaded
Error: package or namespace load failed for ‘ROracle’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/ROracle/libs/ROracle.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/ROracle/libs/ROracle.so, 6): Library not loaded: @rpath/libclntsh.dylib.12.1
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/ROracle/libs/ROracle.so
  Reason: image not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/ROracle’

For whatever reason @rpath/libclntsh.dylib.12.1 can't be found and is preventing ROracle from being fully installed. I have tried putting a link to libclntsh.dylib.12.1 in ~/lib and /usr/lib but neither link worked. I have also tried pointing to the directory containing libclntsh.dylib.12.1 with the environment variables DYLD_FALLBACK_LIBRARY_PATH and DYLD_LIBRARY_PATH but those have not worked as well.

I am using MacOS High Sierra (10.13) and R 3.4.2.


Solution

  • The only way I have found so far to get around this problem is to put a link to libclntsh.dylib.12.1 in the framework lib directory for R. On my computer the R framework lib directory is located in /Library/Frameworks/R.framework/Resources/lib

    My instant client is installed in /usr/local/oracle/instantclient12

    So I use the following command to make the file link:

    ln -s /usr/local/oracle/instantclient12/libclntsh.dylib.12.1 /Library/Frameworks/R.framework/Resources/lib/libclntsh.dylib.12.1
    

    This resolves the ROracle install problem and I can now load the ROracle library in R without issue.