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