繁体   English   中英

无法在Ubuntu 12.04LTS上安装ruby-oci8

[英]Cannot Install ruby-oci8 on Ubuntu 12.04LTS

我执行

$ bundle install

对于我的导轨应用程序......(3.2.8)

当它到达ruby-oci8时...

    Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /home/ubuntu/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb 
checking for load library path... 
  LD_LIBRARY_PATH... 
    checking /usr/lib/oracle/12.1/client/... no
  checking ld.so.conf... no
checking for cc... ok
checking for gcc... yes
checking for LP64... no
checking for sys/types.h... yes
checking for ruby header... ok
Get the version of Oracle from SQL*Plus... *** 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/ubuntu/.rvm/rubies/ruby-1.9.3-p448/bin/ruby
    --with-instant-client
    --without-instant-client
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:760:in `get_version': RuntimeError (RuntimeError)
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:709:in `initialize'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `new'
    from /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `get'
    from extconf.rb:18:in `<main>'
---------------------------------------------------
Error Message:
  cannot get Oracle version from sqlplus
Backtrace:
  /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:760:in `get_version'
  /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:709:in `initialize'
  /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `new'
  /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/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/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/ruby-oci8-2.1.5 for inspection.
Results logged to /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/ruby-oci8-2.1.5/ext/oci8/gem_make.out

An error occurred while installing ruby-oci8 (2.1.5), and Bundler cannot continue.
Make sure that `gem install ruby-oci8 -v '2.1.5'` succeeds before bundling.

我从每个网站和论坛(特别是从这里)做了一切。 这个我觉得最近的... http://jigyasamakkar.com/ruby-oci8-with-rails-3-1-on-ubuntu/

解决这个问题的最佳方法是什么?

我最近不得不安装oracle + ruby​​ gem,这里是mac的说明(但是对于ubuntu也可以。) 完整说明如下:

http://blog.codiez.co.za/2013/09/setup-oracle-instant-client-ruby-oci8-gem-mac/

关键是ruby-oci gem需要知道动态库的存储位置。 对于ubuntu,您需要设置: LD_LIBRARY_PATH

抓取以下文件:

  • instantclient-basic-linux.x64-11.2.0.3.0.zip
  • instantclient-sqlplus-linux.x64-11.2.0.3.0.zip
  • instantclient-sdk-linux.x64-11.2.0.3.0.zip

提取它们并将它们放在某处,然后添加以下环境变量。 有关详细说明,请参阅链接

export ORACLE_BASE=/usr/local/oracle
export ORACLE_HOME=$ORACLE_BASE/product/instantclient_64/11.2.0.3.0
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$DYLD_LIBRARY_PATH
export TNS_ADMIN=$ORACLE_BASE/admin/network

环境变量的说明:

ORACLE_BASE:存储所有文件的位置ORACLE_HOME:实际客户端的路径LD_LIBRARY_PATH:应该指向lib目录,确保你在这里提取了SDK zip文件TNS_ADMIN:在哪里找到你的TNS_ADMIN文件(对ruby来说不是必需的) oci gem)

要使ruby-oci8正常工作,安装即时客户端,即时客户端SDK和sqlplus即时客户端非常重要。 这是一个很好的工具:)

我能在网上找到的最好的资源(就像魅力一样)来自help.ubuntu.com,所以这是一个很好的权威资源:

https://help.ubuntu.com/community/Oracle%20Instant%20Client

它使用rpms安装即时客户端,可以通过外星人完成。 无论如何,它都在那里解释。

要使OCI在代码中连接,请配置TNS_ADMIN环境变量。 我将它放在ubuntu社区解决方案中提到的相同位置(在配置ORACLE_HOME的同一位置)。 我使用与oracle rdbms中常见的相同的文件夹标准:network / admin。

对我来说是:sudo vi /etc/profile.d/oracle.sh export ORACLE_HOME = / usr / lib / oracle / 11.1.0.1 / client export TNS_ADMIN = / usr / lib / oracle / network / admin

然后将你的tnsnames.ora放在TNS_ADMIN文件夹中。

完成后,只需安装gem即可。

宝石将抛出一些错误/警告,但它们不是很重要,它仍然有效。 重新启动会话以获取环境变量。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM