【问题标题】:Error in install ruby-oci8安装 ruby​​-oci8 时出错
【发布时间】:2020-09-25 16:55:35
【问题描述】:

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

【问题讨论】:

  • 那些shell变量被导出了吗?
  • 你解决过这个问题吗?我正在尝试为一个项目设置一个带有 oci8 的 vagrant box ;) 好像你在我所在的同一个兔子洞里

标签: oracle ubuntu oci8


【解决方案1】:

确保您正确放置了这些值:

在 .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 的地方都有正确的版本

【讨论】:

    【解决方案2】:

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

    sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH gem install ruby-oci8

    【讨论】:

      【解决方案3】:

      我遇到了类似的问题,发现gcc &gt;= 4.9是必填项。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-11-11
        • 1970-01-01
        • 2016-03-15
        • 2018-11-23
        • 2017-06-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多