Ruby-oci8 gem install fail !

Oracle & rails on a mac have a very estrange relation it gets exponentially annoying to setup a rails application with Oracle and the irritant here is the installation of Ruby-oci8 gem. 

This gem is not installed straight forward like any other gem, if you have already included the same in your Gemfile and tried bundle install you may get following error.

Installing ruby-oci8 (2.1.7)

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/akshatpaul/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb

checking for load library path…

  DYLD_LIBRARY_PATH is not set.

checking for cc… ok

checking for gcc… yes

checking for LP64… yes

checking for sys/types.h… yes

checking for ruby header… ok

*** extconf.rb failed ***

Could not create Makefile due to some reason, probably lack of necessary

libraries and/or headers.  Check the mkmf.log file for more details.  You may

need configuration options.

Provided configuration options:

    –with-opt-dir

    –without-opt-dir

    –with-opt-include

    –without-opt-include=${opt-dir}/include

    –with-opt-lib

    –without-opt-lib=${opt-dir}/lib

    –with-make-prog

    –without-make-prog

    –srcdir=.

    –curdir

    –ruby=/Users/akshatpaul/.rvm/rubies/ruby-2.0.0-p247/bin/ruby

    –with-instant-client

    –without-instant-client

/Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/gems/ruby-oci8-2.1.7/ext/oci8/oraconf.rb:891:in `get_home’: RuntimeError (RuntimeError)

    from /Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/gems/ruby-oci8-2.1.7/ext/oci8/oraconf.rb:707:in `initialize’

    from /Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/gems/ruby-oci8-2.1.7/ext/oci8/oraconf.rb:320:in `new’

    from /Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/gems/ruby-oci8-2.1.7/ext/oci8/oraconf.rb:320:in `get’

    from extconf.rb:18:in `<main>’

—————————————————

Error Message:

  Set the environment variable ORACLE_HOME if Oracle Full Client.

  Append the path of Oracle client libraries to DYLD_LIBRARY_PATH if Oracle Instant Client.

Backtrace:

  /Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/gems/ruby-oci8-2.1.7/ext/oci8/oraconf.rb:891:in `get_home’

  /Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/gems/ruby-oci8-2.1.7/ext/oci8/oraconf.rb:707:in `initialize’

  /Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/gems/ruby-oci8-2.1.7/ext/oci8/oraconf.rb:320:in `new’

  /Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/gems/ruby-oci8-2.1.7/ext/oci8/oraconf.rb:320:in `get’

  extconf.rb:18:in `<main>’

—————————————————

See:

 * http://rubydoc.info/gems/ruby-oci8/file/docs/install-full-client.md for Oracle full client

 * http://rubydoc.info/gems/ruby-oci8/file/docs/install-instant-client.md for Oracle instant client

 * http://ruby-oci8.rubyforge.org/en/file.report-installation-issue.html to report an issue.

extconf failed, exit code 1

Gem files will remain installed in /Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/gems/ruby-oci8-2.1.7 for inspection.

Results logged to /Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/extensions/x86_64-darwin-12/2.0.0-static/ruby-oci8-2.1.7/gem_make.out

An error occurred while installing ruby-oci8 (2.1.7), and Bundler cannot continue.

Make sure that `gem install ruby-oci8 -v ‘2.1.7’` succeeds before bundling.

Next when you try installing the gem itself by executing gem install ruby-oci8 -v ‘2.1.7’ or any version you will get stuck here : 

gem install ruby-oci8 -v ‘2.1.7’

akshatpaulsmbp2:pett akshatpaul$ gem install ruby-oci8 -v ‘2.1.7’

Building native extensions.  This could take a while…

/Users/akshatpaul/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/ext/builder.rb:73: warning: Insecure world writable dir /usr/local in PATH, mode 040777

ERROR:  Error installing ruby-oci8:

    ERROR: Failed to build gem native extension.

    /Users/akshatpaul/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb

checking for load library path…

  DYLD_LIBRARY_PATH is not set.

checking for cc… ok

checking for gcc… yes

checking for LP64… yes

checking for sys/types.h… yes

checking for ruby header… ok

*** extconf.rb failed ***

Could not create Makefile due to some reason, probably lack of necessary

libraries and/or headers.  Check the mkmf.log file for more details.  You may

need configuration options.

Provided configuration options:

    –with-opt-dir

    –without-opt-dir

    –with-opt-include

    –without-opt-include=${opt-dir}/include

    –with-opt-lib

    –without-opt-lib=${opt-dir}/lib

    –with-make-prog

    –without-make-prog

    –srcdir=.

    –curdir

    –ruby=/Users/akshatpaul/.rvm/rubies/ruby-2.0.0-p247/bin/ruby

    –with-instant-client

    –without-instant-client

/Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/gems/ruby-oci8-2.1.7/ext/oci8/oraconf.rb:891:in `get_home’: RuntimeError (RuntimeError)

    from /Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/gems/ruby-oci8-2.1.7/ext/oci8/oraconf.rb:707:in `initialize’

    from /Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/gems/ruby-oci8-2.1.7/ext/oci8/oraconf.rb:320:in `new’

    from /Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/gems/ruby-oci8-2.1.7/ext/oci8/oraconf.rb:320:in `get’

    from extconf.rb:18:in `<main>’

—————————————————

Error Message:

  Set the environment variable ORACLE_HOME if Oracle Full Client.

  Append the path of Oracle client libraries to DYLD_LIBRARY_PATH if Oracle Instant Client.

Backtrace:

  /Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/gems/ruby-oci8-2.1.7/ext/oci8/oraconf.rb:891:in `get_home’

  /Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/gems/ruby-oci8-2.1.7/ext/oci8/oraconf.rb:707:in `initialize’

  /Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/gems/ruby-oci8-2.1.7/ext/oci8/oraconf.rb:320:in `new’

  /Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/gems/ruby-oci8-2.1.7/ext/oci8/oraconf.rb:320:in `get’

  extconf.rb:18:in `<main>’

—————————————————

See:

 * http://rubydoc.info/gems/ruby-oci8/file/docs/install-full-client.md for Oracle full client

 * http://rubydoc.info/gems/ruby-oci8/file/docs/install-instant-client.md for Oracle instant client

 * http://ruby-oci8.rubyforge.org/en/file.report-installation-issue.html to report an issue.

extconf failed, exit code 1

Gem files will remain installed in /Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/gems/ruby-oci8-2.1.7 for inspection.

Results logged to /Users/akshatpaul/.rvm/gems/ruby-2.0.0-p247/extensions/x86_64-darwin-12/2.0.0-static/ruby-oci8-2.1.7/gem_make.out

No problem, now lets install ruby-oci8 the right way 😉

Simply follow following steps in order and you will be done :

Step 1 

Go to oracle web site for some downloads http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html.

Step 2

Download the 64bit versions of instantclient-sqlplus, instantclient-sdk, instantclient-basic – the 32bit versions do not work with OSX 10.92.

Note : Please download 64bit version only as 32bit just wont work on your OS 10.8+ version. Also you would require oracle login credentials to download this free stuff.

Step 3

Create directories at /opt/oracle incase its not yet created with following command:

$ mkdir /opt/oracle

Step 4

Unzip instantclient-basic, move to /opt/oracle the unzipped folder will be something like instantclient_11_2.

Note : we will be moving other two unzipped folders in this folder, wont keep them separately.

Step 5

Next unzip instantclient-sqlplus move its filed & folders to /opt/oracle/instantclient_11_2/

Step 6 

Next unzip instantclient-sdk move its contents /opt/oracle/instantclient_11_2/

Step 7

Next, via terminal we will add some env variable. First, DYLD_LIBRARY_PATH=/opt/oracle/instantclient_11_2 export DYLD_LIBRARY_PATH

Secondly, ORACLE_HOME=/opt/oracle/instantclient_11_2 export ORACLE_HOME

Check if env variables are created properly by executing $ env

Step 8 

Now we will create a sym link. Go to instantclient_11_2/ by executing cd /opt/oracle/instantclient_11_2.

run $ ln -s libclntsh.dylib.11.1 libclntsh.dylib

Step 9

Now run gem install ruby-oci8

Share

Leave a Comment

Your email address will not be published. Required fields are marked *