Sam
Sam

Reputation: 566

dyld: Library not loaded - sqlplus installation

I want to install sqlplus on my Mac. So, first I downloaded two files from this link https://www.oracle.com/technetwork/topics/intel-macsoft-096467.html these two file:

  1. instantclient-basic-macos.x64-18.1.0.0.0.zip

  2. instantclient-sqlplus-macos.x64-18.1.0.0.0.zip

Then, I moved these files.zip on my desktop and from my terminal I wrote these commands:

unzip /Users/nietmochi/Desktop/instantclient-basic-macos.x64-18.1.0.0.0.zip

and

unzip /Users/nietmochi/Desktop/instantclient-sqlplus-macos.x64-18.1.0.0.0.zip

and then:

export PATH=/Users/nietmochi/Desktop/instantclient_18_1:$PATH

and:

which sqlplus

Now, when I try to launch sqlplus with the command sqlplus, I have this message:

dyld: Library not loaded: @rpath/libclntsh.dylib.18.1
  Referenced from: /Users/nietmochi/Desktop/instantclient_18_1/sqlplus
  Reason: image not found
Abort trap: 6

Why? How to fix it?

Thanks a lot!

Upvotes: 3

Views: 5384

Answers (3)

Jason
Jason

Reputation: 12333

The problem is that the dependency for instantclient-sqlplus is in a different package, namely instantclient-basic. Care must be taken that all the files from that package actually end up in the same directory as the instantclient-sqlplus package. Normally, dependencies like this are managed automatically. Oracle, for some reason perhaps reflected in their name, decided to split all these dependencies across multiple packages and require you (or us) to manage them (and their installation) yourself! There is a lot of room for error in this.

Be sure:

  • the packages are of the same type (you cannot mix zip and dmg, but the OP doesn't seem to be doing that),
  • your unzip program is not overwriting the directory where it extracts files,
  • after executing for the first time, that you go into System Preferences and give the executable - and library - permission to execute (this may take several rounds to get all the libraries),
  • System Preferences allows executables from "App Store and identified developers" (I'm not sure how necessary this is, but in the past this was useful in some cases like this for me),
  • set the PATH to have the absolute path of the directory where sqlplus and all libraries are installed.

Don't feel bad if when following Oracle's instructions and answers here (including mine and others) that you fail. There's no way to predict all the ways this can go wrong. It's an awful idea to leave something like this to users. At least Oracle could have packaged all the libraries with SQLPlus (and again with each tool that needs them). This may be a "waist", but in CS there is a space/time trade off... and we all would have saved a LOT of time for the waisted 246MB space on our terabyte hard drives. We could recover that space by simply merging directories if we had multiple tools.

Upvotes: 0

Christopher Jones
Christopher Jones

Reputation: 10641

Installation has changed with 19c which introduced signed DMG packages. See Notarized macOS Oracle Instant Client Packages Make Installation Easier:

  • Download desired DMG packages from Oracle.

  • In Finder, double click on all desired Instant Client .dmg packages to mount them

  • Open a terminal window and change directory to one of the packages, for example:

    $ cd /Volumes/instantclient-basic-macos.x64-19.8.0.0.0dbru
    
  • Run the install_ic.sh script:

    $ ./install_ic.sh
    

    This copies the contents of all currently mounted Instant Client .dmg packages to $HOME/Downloads/instantclient_19_8

  • If you have multiple DMG packages mounted, you only need to run install_ic.sh once

  • In Finder, eject the mounted Instant Client packages

If you want a script that does the download and install automatically, see the blog post Notarized macOS Oracle Instant Client Packages Make Installation Easier.

When in doubt, follow the installation instructions which are on the page you download Instant Client from.

Upvotes: 2

Alex Poole
Alex Poole

Reputation: 191445

The error suggests that your ~/Desktop/instantclient_18_1 directory only has the contents of the instantclient-sqlplus-macos.x64-18.1.0.0.0.zip file. I suspect you've tried this several times from various locations, and you've ended up with a mix of partial and full installations, and you're happening to pick up a partial one.

When you do:

unzip /Users/nietmochi/Desktop/instantclient-basic-macos.x64-18.1.0.0.0.zip
unzip /Users/nietmochi/Desktop/instantclient-sqlplus-macos.x64-18.1.0.0.0.zip

then both zip archives should be expanded into the same instantclient_18_1 directory, which will be in your current working directory. If you didn't change to ~/Desktop before running then that could be anywhere...

I'd suggest you start again. Find and remove any directories called instantclient_18_1, from your home directory, ~/Desktop, ~/Downloads etc., anywhere you can find them; mostly just to avoid confusion.

Then, since your zip files are currently on the desktop, for simplicity for now do:

cd ~/Desktop
unzip instantclient-basic-macos.x64-18.1.0.0.0.zip
ls instantclient_18_1 | wc -l
unzip instantclient-sqlplus-macos.x64-18.1.0.0.0.zip
ls instantclient_18_1 | wc -l

The first ls should give you a count of 18 files. The second should give you a count of 23 files.

Once you have done that then sqlplus should work, using the PATH you've already modified.

You can put that instantclient_18_1 directory anywhere you want, as long as your PATH refers to it, and you can add setting your path to your ~/.bash_profile file so you don't have to do that manually in future.

Upvotes: 3

Related Questions