安装ruby-oci8时出错

时间:2013-09-03 05:22:11

标签: oracle ubuntu oci8

我有$ ORACLE_HOME和$ LD_LIBRARY_PATH变量

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

但我仍然无法安装ruby-oci8

这是错误消息

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 个答案:

答案 0 :(得分:0)

确保正确放置这些值:

在.bashrc或.bach_profile中(无论你使用哪个)

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

然后到达你的instantclient目录(/ 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

现在,只要我使用12.1

,您就会看到正确的版本

答案 1 :(得分:0)

您似乎正在使用sudo来安装宝石。出于安全原因,sudo显然已取消LD_LIBRARY_PATH。尝试不使用sudo或在sudo运行后重新设置:

sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH gem install ruby-oci8

答案 2 :(得分:0)

我遇到了类似的问题,发现需要gcc >= 4.9