mac中的ruby-oci8安装错误(El Capitan)

时间:2016-04-23 13:28:21

标签: ruby-on-rails ruby macos

我尝试使用ruby-oci8安装ruby-oci8(mac)并且无法安装。

当我尝试安装此gem时。

gem install ruby-oci8

它为环境变量生成错误。我无法弄清楚这个问题。

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/tayyab/.rbenv/versions/2.2.3/bin/ruby -r ./siteconf20160423-11068-8lu6zg.rb extconf.rb
checking for load library path... 
*** 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=/Users/tayyab/.rbenv/versions/2.2.3/bin/$(RUBY_BASE_NAME)
    --with-instant-client
    --without-instant-client
/Users/tayyab/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/ruby-oci8-2.2.1/ext/oci8/oraconf.rb:566:in `check_ic_dir': RuntimeError (RuntimeError)
    from /Users/tayyab/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/ruby-oci8-2.2.1/ext/oci8/oraconf.rb:316:in `get'
    from extconf.rb:22:in `<main>'
  DYLD_LIBRARY_PATH is not set.
  checking DYLD_FALLBACK_LIBRARY_PATH...
    checking /Users/tayyab/lib... no
    checking /usr/local/lib... no
    checking /lib... no
    checking /usr/lib... no
  checking OCI_DIR...
---------------------------------------------------

错误讯息:

  Set the environment variable DYLD_LIBRARY_PATH, DYLD_FALLBACK_LIBRARY_PATH or
  OCI_DIR to point to the Instant client directory.

  If DYLD_LIBRARY_PATH or DYLD_FALLBACK_LIBRARY_PATH is set, the environment
  variable must be set at runtime also.

  If OCI_DIR is set, dependent shared library paths are checked. If the checking
  is passed, ruby-oci8 works without DYLD_LIBRARY_PATH or DYLD_FALLBACK_LIBRARY_PATH.

  Note: OCI_DIR should be absolute path.
  Note: DYLD_* environment variables are unavailable for security reasons on OS X 10.11 El Capitan.

知道怎么解决吗?

3 个答案:

答案 0 :(得分:6)

您需要执行与此处提供的步骤几乎相同的步骤https://stackoverflow.com/a/21443313/4439981 而不是8。

  1. 将DYLD_LIBRARY_PATH替换为OCI_DIR

    OCI_DIR=/opt/oracle/instantclient_11_2 export OCI_DIR
    

答案 1 :(得分:0)

几天前,我也有同样的错误.. 尝试了很多想法,最后得到解决方案非常简单。

El Capitan附带新的OS X功能:系统完整性保护(SIP),也称为“无根”模式。这减少了恶意软件的攻击面。 这是无法设置“DYLD_LIBRARY_PATH”的主要原因。 所以解决方案是禁用此功能

按照以下步骤禁用SIP:

  1. 重新启动Mac。
  2. 在OS X启动之前,按住Command-R并保持按住直到看到Apple图标和进度条。发布。这会引导您进入Recovery。
  3. 从Utilities菜单中,选择Terminal。
  4. 在提示符下键入以下内容,然后按Return键: csrutil disable
  5. 终端应显示SIP已被禁用的消息。
  6. 从菜单中选择重新启动。

    从Recovery中的Utilities菜单中选择Terminal。 Terminal view 使用“恢复中的终端”输入SIP禁用命令。

答案 2 :(得分:0)

错误信息:

enter image description here

修正:

export OCI_DIR=$HOME/../../opt/oracle/instantclient_11_2 

enter image description here

成功:

enter image description here

下载链接 Instantclient:

https://www.oracle.com/uk/database/technologies/instant-client/macos-intel-x86-downloads.html