Error in install ruby-oci8

7.3k views Asked by At

I do have the $ORACLE_HOME and $LD_LIBRARY_PATH variable

vagrant@oracle:~$ env | grep oracle
LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/xe/lib:
ORACLE_BASE=/u01/app/oracle
PATH=/home/vagrant/.rbenv/shims:/home/vagrant/.rbenv/bin:/u01/app/oracle/product/11.2.0/xe/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/vagrant_ruby/bin
ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe

But I still can't not install ruby-oci8

here is the error message

vagrant@oracle:~$ sudo gem install ruby-oci8
Building native extensions.  This could take a while...
ERROR:  Error installing ruby-oci8:
    ERROR: Failed to build gem native extension.

    /home/vagrant/.rbenv/versions/2.0.0-p247/bin/ruby extconf.rb
checking for load library path... 
  LD_LIBRARY_PATH is not set.
  checking ld.so.conf... no
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=/home/vagrant/.rbenv/versions/2.0.0-p247/bin/ruby
    --with-instant-client
    --without-instant-client
/home/vagrant/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:889:in `get_home': RuntimeError (RuntimeError)
    from /home/vagrant/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:705:in `initialize'
    from /home/vagrant/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `new'
    from /home/vagrant/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/ruby-oci8-2.1.5/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 LD_LIBRARY_PATH if Oracle Instant Client.

  The 'sudo' command unset some environment variables for security reasons.
  Pass required varialbes as follows
       sudo env LD_LIBRARY_PATH=$LD_LIBRARY_PATH /home/vagrant/.rbenv/shims/gem install ruby-oci8
    or 
       sudo env ORACLE_HOME=$ORACLE_HOME /home/vagrant/.rbenv/shims/gem install ruby-oci8

Backtrace:
  /home/vagrant/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:889:in `get_home'
  /home/vagrant/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:705:in `initialize'
  /home/vagrant/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `new'
  /home/vagrant/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `get'
  extconf.rb:18:in `<main>'
---------------------------------------------------
See:
 * http://ruby-oci8.rubyforge.org/en/HowToInstall.html
 * http://ruby-oci8.rubyforge.org/en/ReportInstallProblem.html



Gem files will remain installed in /home/vagrant/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/ruby-oci8-2.1.5 for inspection.
Results logged to /home/vagrant/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/ruby-oci8-2.1.5/ext/oci8/gem_make.out
3

There are 3 answers

0
user14339088 On

I met the similar problem and I found that gcc >= 4.9 is required.

0
Vishal Kumar On

Make sure you these values correctly placed :

In .bashrc or .bach_profile (whichever you use)

ORACLE_HOME=/opt/oracle/12_1/instantclient
LD_LIBRARY_PATH=/opt/oracle/12_1/instantclient

Then got to your instantclient directory (/opt/oracle/12_1/instantclient)

ln -s libclntsh.so.12.1 libclntsh.so
chmod -R a+rX $ORACLE_HOME or chmod -R 755 $ORACLE_HOME

Now see you have correct version wherever i used 12.1

0
Milan Iliev On

Looks like you're using sudo to install gems. For security reasons, sudo apparently unsets LD_LIBRARY_PATH. Try without sudo or re-set it after sudo runs:

sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH gem install ruby-oci8