oracle 如何安装 ruby​​-oci8?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11894194/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:02:18  来源:igfitidea点击:

How to install ruby-oci8?

rubymacosoracle

提问by earlyriser

I'm trying to install ruby-oci8 on OS X.

我正在尝试在 OS X 上安装 ruby​​-oci8。

I've tried installing both with and without sudo.

我试过安装和不安装sudo.

Error Message without sudo:

错误消息没有sudo

gem install ruby-oci8
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.

Error Message with sudo:

错误消息sudo

sudo gem install ruby-oci8
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing ruby-oci8:
    ERROR: Failed to build gem native extension.

        /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for load library path... 
  DYLD_LIBRARY_PATH is not set.
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=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
    --with-instant-client
    --without-instant-client
./oraconf.rb:887:in `get_home': RuntimeError (RuntimeError)
    from ./oraconf.rb:703:in `initialize'
    from ./oraconf.rb:319:in `new'
    from ./oraconf.rb:319:in `get'
    from extconf.rb:18

Error Message:

错误信息:

Set the environment variable ORACLE_HOME if Oracle Full Client.
Append the path of Oracle client libraries to DYLD_LIBRARY_PATH if Oracle Instant Client.

The 'sudo' command unset some environment variables for security reasons.
Pass required varialbes as follows
     sudo env DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH /usr/bin/gem install ruby-oci8
  or 
     sudo env ORACLE_HOME=$ORACLE_HOME /usr/bin/gem install ruby-oci8


Backtrace:
  ./oraconf.rb:887:in `get_home'
  ./oraconf.rb:703:in `initialize'
  ./oraconf.rb:319:in `new'
  ./oraconf.rb:319:in `get'
  extconf.rb:18

See:
 * http://ruby-oci8.rubyforge.org/en/HowToInstall.html
 * http://ruby-oci8.rubyforge.org/en/ReportInstallProblem.html

回答by etusm

Slightly updated version of install of ruby-oci8 for 10.9/10.10/10.11OSX Mavericks/Yosemite/El Capitan - step-by-step:

10.9/10.10/10.11OSX Mavericks/Yosemite/El Capitan 安装 ruby​​-oci8 的轻微更新版本 - 分步:

  1. Go here: http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html
  2. Download the 64bit versions of instantclient-sqlplus, instantclient-sdk, instantclient-basic- the 32bit versions do not work with OSX 10.9
  3. Create directories at /opt/oracle
  4. Unzip instantclient-basic first, move to /opt/oracle (should add a folder - something like /opt/oracle/instantclient_11_2/)
  5. Unzip instantclient-sdk and move its contents to /opt/oracle/instantclient_11_2/
  6. Unzip instantclient-sqlplus and move its contents /opt/oracle/instantclient_11_2/
  7. Open Terminal (if you haven't already) and type...
  8. DYLD_LIBRARY_PATH=/opt/oracle/instantclient_11_2 export DYLD_LIBRARY_PATH
  9. ORACLE_HOME=/opt/oracle/instantclient_11_2 export ORACLE_HOME
  10. cd /opt/oracle/instantclient_11_2
  11. ln -s libclntsh.dylib.11.1 libclntsh.dylib(creates a symbolic link)
  12. env
  13. verify that DYLD_LIBRARY_PATH=/opt/oracle/instantclient_11_2 (be sure there's no trailing / after instantclient_11_2)
  14. verify ORACLE_HOME=/opt/oracle/instantclient_11_2
  15. gem install ruby-oci8
  1. 去这里:http: //www.oracle.com/technetwork/topics/intel-macsoft-096467.html
  2. 下载 64 位版本的 Instantclient-sqlplus、instantclient-sdk、instantclient-basic- 32 位版本不适用于 OSX 10.9
  3. 在 /opt/oracle 创建目录
  4. 首先解压缩instantclient-basic,移动到/opt/oracle(应该添加一个文件夹——比如/opt/oracle/instantclient_11_2/)
  5. 解压 Instantclient-sdk 并将其内容移动到 /opt/oracle/instantclient_11_2/
  6. 解压 Instantclient-sqlplus 并移动其内容 /opt/oracle/instantclient_11_2/
  7. 打开终端(如果您还没有)并输入...
  8. DYLD_LIBRARY_PATH=/opt/oracle/instantclient_11_2 export DYLD_LIBRARY_PATH
  9. ORACLE_HOME=/opt/oracle/instantclient_11_2 export ORACLE_HOME
  10. cd /opt/oracle/instantclient_11_2
  11. ln -s libclntsh.dylib.11.1 libclntsh.dylib(创建一个符号链接)
  12. env
  13. 验证 DYLD_LIBRARY_PATH=/opt/oracle/instantclient_11_2(确保在 Instantclient_11_2 之后没有尾随 /)
  14. 验证 ORACLE_HOME=/opt/oracle/instantclient_11_2
  15. 宝石安装 ruby​​-oci8

Should work after that. The file structure should look similar to this:

应该在那之后工作。文件结构应类似于:

enter image description here

在此处输入图片说明

回答by Garrett Disco

For anyone attempting to get this to work in the good old year of 2016, the error message now contains a link to the page http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install-on-osx.mdthat gives you instructions for how to do it using Homebrew. None of the above stuff worked for me (and I tried it all), but then I took this problem to a coworker and they said, "Hey, did you try that link in the error message there?" Sure enough, that did it.

对于任何试图让它在 2016 年的旧年工作的人,错误消息现在包含一个链接到页面http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install- on-osx.md为您提供有关如何使用 Homebrew 进行操作的说明。上面的东西都不适合我(我都试过了),但后来我把这个问题交给了一位同事,他们说,“嘿,你试过那里错误消息中的那个链接吗?” 果然,做到了。

回答by 2potatocakes

In case anyone else needs to install a legacy version of ruby-oci8 on Ruby 1.8.7on mac osx el capitan, I had success installing ruby-oci8-2.1.2using the following method. I think it will also work on other ruby-1.8.7 versions as well (ruby-oci8 < 2.2.0) but I haven't checked other versions:

如果其他人需要在 mac osx el capan上的Ruby 1.8.7上安装旧版本的 ruby​​-oci8 ,我使用以下方法成功安装了ruby-oci8-2.1.2。我认为它也适用于其他 ruby​​-1.8.7 版本(ruby-oci8 < 2.2.0),但我没有检查其他版本:

  1. Go here: http://www.oracle.com/technetwork/topics/intel-macsoft-096467.htmlDownload the 64bit versions of instantclient-basic, instantclient-sdk, instantclient-sqlplus(I'm using the -macos.x64-11.2.0.4.0 versions)
  2. Copy the zip files to /opt/oracle and unzip each of them. It should extract them to /opt/oracle/instantclient_11_2
  3. cd /opt/oracle/instantclient_11_2
  4. ln -s libclntsh.dylib.11.1 libclntsh.dylib
  5. curl -O https://raw.githubusercontent.com/kubo/fix_oralib_osx/master/fix_oralib.rb
  6. Be sure to append the -a flag when running the script, this will make the script fix the libs using an absolute path rather than an @rpath/*.dylib path which ends up choking the gem build process. (read the fix_oralib.rb script first if you want to check). Anyways, run: ruby fix_oralib.rb -a
  7. export OCI_DIR=/opt/oracle/instantclient_11_2
  8. Now grab the ruby-oci8 source git clone https://github.com/kubo/ruby-oci8.git
  9. Checkout the version you want to install (I needed 2.1.2) git checkout ruby-oci8-2.1.2
  10. Edit this file: ruby-oci8/ext/oci8/oraconf.rband change this line:
  1. 去这里:http: //www.oracle.com/technetwork/topics/intel-macsoft-096467.html下载 64 位版本的Instantclient-basicinstantclient-sdkinstantclient-sqlplus(我正在使用 -macos.x64 -11.2.0.4.0 版本)
  2. 将 zip 文件复制到 /opt/oracle 并解压缩每个文件。它应该将它们提取到 /opt/oracle/instantclient_11_2
  3. cd /opt/oracle/instantclient_11_2
  4. ln -s libclntsh.dylib.11.1 libclntsh.dylib
  5. curl -O https://raw.githubusercontent.com/kubo/fix_oralib_osx/master/fix_oralib.rb
  6. 确保在运行脚本时附加 -a 标志,这将使脚本使用绝对路径而不是 @rpath/*.dylib 路径修复库,这最终会阻塞 gem 构建过程。(如果要检查,请先阅读 fix_oralib.rb 脚本)。无论如何,运行:ruby fix_oralib.rb -a
  7. export OCI_DIR=/opt/oracle/instantclient_11_2
  8. 现在获取 ruby​​-oci8 源代码 git clone https://github.com/kubo/ruby-oci8.git
  9. 签出您要安装的版本(我需要 2.1.2) git checkout ruby-oci8-2.1.2
  10. 编辑此文件:ruby-oci8/ext/oci8/oraconf.rb并更改此行:

when /darwin/ @@ld_envs = %w[DYLD_LIBRARY_PATH] so_ext = 'dylib'

when /darwin/ @@ld_envs = %w[DYLD_LIBRARY_PATH] so_ext = 'dylib'

To this:

对此:

when /darwin/ @@ld_envs = %w[DYLD_LIBRARY_PATH OCI_DIR] so_ext = 'dylib'

when /darwin/ @@ld_envs = %w[DYLD_LIBRARY_PATH OCI_DIR] so_ext = 'dylib'

  1. Now change back into the root directory of the gem itself and build the gemspec: gem build ruby-oci8.gemspec
  2. 2potatocakes$ gem install ruby-oci8-2.1.2.gem Building native extensions. This could take a while... Successfully installed ruby-oci8-2.1.2 1 gem installed
  1. 现在改回 gem 本身的根目录并构建 gemspec: gem build ruby-oci8.gemspec
  2. 2potatocakes$ gem install ruby-oci8-2.1.2.gem Building native extensions. This could take a while... Successfully installed ruby-oci8-2.1.2 1 gem installed

回答by Jose Neto

On OS X Sierra, I was unable to set DYLD_LIBRARY_PATH due to system integrity protection (https://forums.developer.apple.com/thread/13161), so I copied all oracle's instant client files to /users/.../lib, since it has a fallback to some directories including this one:

在 OS X Sierra 上,由于系统完整性保护(https://forums.developer.apple.com/thread/13161),我无法设置 DYLD_LIBRARY_PATH ,因此我将所有 oracle 的即时客户端文件复制到 /users/.../ lib,因为它可以回退到一些目录,包括这个目录:

...
checking the default value of DYLD_FALLBACK_LIBRARY_PATH...
checking /Users/<username>/lib... no
checking /usr/local/lib... no
checking /lib... no
checking /usr/lib... no
...

And the gem installed successfully!

并且 gem 安装成功!

cp -R /opt/oracle/instantclient_11_2/* /users/..username../lib
gem install ruby-oci8

Building native extensions.  This could take a while...
Successfully installed ruby-oci8-2.2.2
1 gem installed

回答by Prashant Mishra

If you are using MAC with El Capitan, the DYLD_* environment variables are ignored,due the latest embedded feature of System Integrity Protection (SIP).

如果您将 MAC 与 El Capitan 一起使用,由于系统完整性保护 (SIP) 的最新嵌入式功能,DYLD_* 环境变量将被忽略。

SO if you wants to install ruby-oci8 with El Capitan, first you have to disable SIP.

所以如果你想用 El Capitan 安装 ruby​​-oci8,首先你必须禁用 SIP。

Follow these steps to disable SIP:

请按照以下步骤禁用 SIP:

  1. Restart your Mac.
  2. Before OS X starts up, hold down Command-R and keep it held down until you see an Apple icon and a progress bar. Release. This boots you into Recovery.
  3. From the Utilities menu, select Terminal.
  4. At the prompt type exactly the following and then press Return: csrutil disable
  5. Terminal should display a message that SIP was disabled.
  6. From the ? menu, select Restart.
  1. 重新启动您的 Mac。
  2. 在 OS X 启动之前,按住 Command-R 并保持按住直到看到 Apple 图标和进度条。释放。这将引导您进入恢复。
  3. 从实用程序菜单中,选择终端。
  4. 在提示符下键入以下内容,然后按回车键:csrutil disable
  5. 终端应显示 SIP 已禁用的消息。
  6. 来自 ?菜单,选择重新启动。

If you still facing problem try this link http://blog.codiez.co.za/2013/09/setup-oracle-instant-client-ruby-oci8-gem-mac/

如果您仍然遇到问题,请尝试此链接 http://blog.codiez.co.za/2013/09/setup-oracle-instant-client-ruby-oci8-gem-mac/

回答by Steen

The error message is somewhat verbose, but it basically says that you need to install the Oracle Client librariesand point the DYLD_LIBRARY_PATHvariable to that location.

错误消息有点冗长,但它基本上表明您需要安装Oracle 客户端库并将DYLD_LIBRARY_PATH变量指向该位置。

回答by Justin

Begin by downloading oracle instantclient version 11.2 for 32 bit Linux from their website. Version 12 or later will not work with visual database (I always grabbed the .zip versions, so that's what the guide assumes. It also assumes the downloaded files are in the /tmp folder.). You will need the basic version, sqlplus, and sdk. Once those downloads are completed, execute the following commands in the terminal

首先从他们的网站下载适用于 32 位 Linux 的 oracle Instantclient 11.2 版。版本 12 或更高版本不适用于可视化数据库(我总是获取 .zip 版本,所以这就是指南所假设的。它还假设下载的文件位于 /tmp 文件夹中。)。您将需要基本版本、sqlplus 和 sdk。下载完成后,在终端中执行以下命令

sudo mkdir -p /opt/oracle
sudo cd /opt/oracle
sudo unzip /tmp/instantclient-basic-linux-11.2.0.4.0.zip
sudo unzip /tmp/instantclient-sqlplus-linux-11.2.0.4.0.zip
sudo unzip /tmp/instantclient-sdk-linux-11.2.0.4.0.zip
sudo apt-get install libaio1
sudo cd instantclient_11_2
sudo ln -s libclntsh.so.11.2 libclntsh.so

-Now, we'll need to tell our bash shell where the oracle client is located. So allow yourself to see hidden files, and open up $home/.bashrc with a text editor. Add the following line to the bottom of the file and then save it:

- 现在,我们需要告诉我们的 bash shell oracle 客户端所在的位置。因此,允许自己查看隐藏文件,并使用文本编辑器打开 $home/.bashrc。将以下行添加到文件底部,然后保存:

export LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2

-Now source .bashrc to load the new settings with this command in the terminal:

- 现在源 .bashrc 以在终端中使用此命令加载新设置:

source ~/.bashrc

-Now if we did everything correctly, we should be able to install the oracle database adapter gem. Try it with this command:

- 现在如果我们做的一切正确,我们应该能够安装 oracle 数据库适配器 gem。用这个命令试试:

gem install ruby-oci8 -v '2.1.5'

回答by bvk48

For some reason ruby-oci8 was not getting installed with instant client_11_2 for me. I tried all the answers suggested here and other places but couldnt get it done. Later I tried with instant client 12_1 and it worked without any issues.

出于某种原因,ruby-oci8 没有为我安装即时 client_11_2。我尝试了这里和其他地方建议的所有答案,但无法完成。后来我尝试使用即时客户端 12_1,它没有任何问题。

回答by feng ce

updated version of install of ruby-oci8 for CENTOS7

CENTOS7安装 ruby​​-oci8 的更新版本

cd /etc/yum.repos.d
sudo wget http://yum.oracle.com/RPM-GPG-KEY-oracle-ol7
sudo rpm --import RPM-GPG-KEY-oracle-ol7
sudo yum-config-manager --enable ol7_oracle_instantclient
sudo yum install oracle-instantclient18.3-basic
sudo yum install oracle-instantclient18.3-devel
sudo yum install oracle-instantclient18.3-jdbc
sudo yum install oracle-instantclient18.3-sqlplus
export ORACLE_HOME=/usr/lib/oracle/18.3/client64
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
gem install ruby-oci8 -v '2.2.7'

回答by user2918410

If you are using OS X El Capitan, Yosemite and Mavericks. You should use Instant Client 12.1.0.2Download Instant Client 12.1.0.2 from oracle website

如果您使用的是OS X El Capitan、Yosemite 和 Mavericks。您应该使用InstantClient 12.1.0.2 从 oracle 网站下载 Instant Client 12.1.0.2

  1. instantclient-basic-macos.x64-12.1.0.2.0.zip
  2. instantclient-sqlplus-macos.x64-12.1.0.2.0.zip
  3. instantclient-sdk-macos.x64-12.1.0.2.0.zip
  1. Instantclient-basic-macos.x64-12.1.0.2.0.zip
  2. Instantclient-sqlplus-macos.x64-12.1.0.2.0.zip
  3. Instantclient-sdk-macos.x64-12.1.0.2.0.zip

Then follow these steps:-

然后按照以下步骤操作:-

  1. Create directories at /opt/oracle
  2. Unzip instantclient-basic first, move to /opt/oracle (should add a folder -
    something like /opt/oracle/instantclient_12_1/)
  3. Unzip instantclient-sdk and move its contents to /opt/oracle/instantclient_12_1/
  4. Unzip instantclient-sqlplus and move its contents /opt/oracle/instantclient_12_1/
  5. Open Terminal (if you haven't already) and type...
  1. 在 /opt/oracle 创建目录
  2. 首先解压instantclient-basic,移动到/opt/oracle(应该添加一个文件夹——
    比如/opt/oracle/instantclient_12_1/)
  3. 解压 Instantclient-sdk 并将其内容移动到 /opt/oracle/instantclient_12_1/
  4. 解压 Instantclient-sqlplus 并移动其内容 /opt/oracle/instantclient_12_1/
  5. 打开终端(如果您还没有)并输入...

DYLD_LIBRARY_PATH=/opt/oracle/instantclient_12_1 export DYLD_LIBRARY_PATH ORACLE_HOME=/opt/oracle/instantclient_12_1 export ORACLE_HOME

DYLD_LIBRARY_PATH=/opt/oracle/instantclient_12_1 导出 DYLD_LIBRARY_PATH ORACLE_HOME=/opt/oracle/instantclient_12_1 导出 ORACLE_HOME

  1. cd /opt/oracle/instantclient_12_1
  1. cd /opt/oracle/instantclient_12_1

ln -s libclntsh.dylib.12.1 libclntsh.dylib (creates a symbolic link)

ln -s libocci.dylib.12.1 libocci.dylib

ln -s libclntsh.dylib.12.1 libclntsh.dylib(创建符号链接)

ln -s libocci.dylib.12.1 libocci.dylib

  1. run: env
    1. verify that DYLD_LIBRARY_PATH=/opt/oracle/instantclient_11_2 (be sure there's
      no trailing / after instantclient_11_2) verify ORACLE_HOME=/opt/oracle/instantclient_11_2
    2. gem install ruby-oci8 -v gemVersion
  1. 运行:环境
    1. 验证 DYLD_LIBRARY_PATH=/opt/oracle/instantclient_11_2(确保
      在 Instantclient_11_2 之后没有尾随 /) 验证 ORACLE_HOME=/opt/oracle/instantclient_11_2
    2. gem install ruby​​-oci8 -v gemVersion

Note:-If this still didn't work fro you try disabling SIP on your macthen try it again.

注意:-如果这仍然不起作用,请尝试在 Mac 上禁用 SIP,然后再试一次。

It has worked for me hope it works for you too.All the best

它对我有用,希望它对你也有用。祝一切顺利