0

我确实有 $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
4

3 回答 3

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

于 2014-05-15T11:53:10.607 回答
0

看起来您正在使用sudo安装宝石。出于安全原因,sudo显然 unsets LD_LIBRARY_PATH。尝试不使用sudo或在运行后重新设置sudo

sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH gem install ruby-oci8

于 2015-07-13T19:44:42.443 回答
0

我遇到了类似的问题,我发现这gcc >= 4.9是必需的。

于 2020-09-25T08:55:35.653 回答