如何安装ruby-oci8?
我正在尝试在OS X上安装ruby-oci8。
我尝试过安装sudo
和不安装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.
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
错误信息:
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
适用于10.9 / 10.10 / 10.11OSX Mavericks / Yosemite / El Capitan的ruby-oci8安装略有更新版本 – 循序渐进:
- 请访问: http : //www.oracle.com/technetwork/topics/intel-macsoft-096467.html
- 下载64位版本的instantclient-sqlplus,instantclient-sdk,instantclient-basic – 32位版本不适用于OSX 10.9
- 在/ opt / oracle创建目录
- 先解压Instantclient-basic,然后转到/ opt / oracle(应该添加一个文件夹 – 比如/ opt / oracle / instantclient_11_2 /)
- 解压Instantclient-sdk并将其内容移至/ opt / oracle / instantclient_11_2 /
- 解压Instantclient-sqlplus并移动其内容/ opt / oracle / instantclient_11_2 /
- 打开终端(如果你还没有)并输入…
-
DYLD_LIBRARY_PATH=/opt/oracle/instantclient_11_2 export DYLD_LIBRARY_PATH
-
ORACLE_HOME=/opt/oracle/instantclient_11_2 export ORACLE_HOME
-
cd /opt/oracle/instantclient_11_2
-
ln -s libclntsh.dylib.11.1 libclntsh.dylib
(创建符号链接) -
env
- validationDYLD_LIBRARY_PATH = / opt / oracle / instantclient_11_2(确保没有尾随/在instantclient_11_2之后)
- validationORACLE_HOME = / opt / oracle / instantclient_11_2
- gem install ruby-oci8
应该在那之后工作。 文件结构应该类似于:
对于任何试图让它在2016年的旧年工作的人,错误消息现在包含指向页面的链接http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install- on-osx.md ,它为您提供了如何使用Homebrew进行操作的说明。 以上所有的东西都没有为我工作(我尝试了所有这些),但后来我把这个问题交给了一个同事,他们说,“嘿,你在那里的错误信息中尝试了那个链接吗?” 果然,这样做了。
如果其他人需要在mac osx el capitan上的Ruby 1.8.7上安装旧版本的ruby-oci8,我使用以下方法成功安装了ruby-oci8-2.1.2 。 我认为它也适用于其他ruby-1.8.7版本(ruby-oci8 <2.2.0),但我没有检查其他版本:
- 请访问: http : //www.oracle.com/technetwork/topics/intel-macsoft-096467.html下载64位版本的instantclient-basic , instantclient-sdk , instantclient-sqlplus (我正在使用-macos.x64 -11.2.0.4.0版本)
- 将zip文件复制到/ opt / oracle并解压缩每个文件。 它应该将它们提取到/ opt / oracle / instantclient_11_2
-
cd /opt/oracle/instantclient_11_2
-
ln -s libclntsh.dylib.11.1 libclntsh.dylib
-
curl -O https://raw.githubusercontent.com/kubo/fix_oralib_osx/master/fix_oralib.rb
- 确保在运行脚本时附加-a标志,这将使脚本使用绝对路径而不是@rpath / * .dylib路径修复libs,最终阻塞gem构建过程。 (如果要检查,首先阅读fix_oralib.rb脚本)。 无论如何,运行:
ruby fix_oralib.rb -a
-
export OCI_DIR=/opt/oracle/instantclient_11_2
- 现在抓住ruby-oci8源代码
git clone https://github.com/kubo/ruby-oci8.git
- 检查您要安装的版本(我需要2.1.2)
git checkout ruby-oci8-2.1.2
- 编辑此文件: 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 OCI_DIR] so_ext = 'dylib'
- 现在改回gem本身的根目录并构建gemspec:
gem build ruby-oci8.gemspec
-
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
在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//lib... no checking /usr/local/lib... no checking /lib... no checking /usr/lib... no ...
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
错误消息有点冗长,但它基本上表示您需要安装Oracle客户端库并将DYLD_LIBRARY_PATH
变量指向该位置。
如果您使用MAC与El Capitan,则由于系统完整性保护(SIP)的最新嵌入式function,将忽略DYLD_ *环境变量。
因此,如果您想使用El Capitan安装ruby-oci8,首先必须禁用SIP。
请按照以下步骤禁用SIP:
- 重启你的Mac。
- 在OS X启动之前,按住Command-R并保持按住直到看到Apple图标和进度条。 发布。 这会引导您进入Recovery。
- 从Utilities菜单中,选择Terminal。
- 在提示符下键入以下内容,然后按Return:csrutil disable
- 终端应显示SIP已禁用的消息。
- 从菜单中,选择重新启动。
如果您仍然遇到问题请尝试此链接http://blog.codiez.co.za/2013/09/setup-oracle-instant-client-ruby-oci8-gem-mac/
首先从他们的网站下载oracle instantclient版本11.2 for 32位Linux。 版本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
– 现在,我们需要告诉我们的bash shell oracle客户端所在的位置。 因此,请允许自己查看隐藏文件,并使用文本编辑器打开$ home / .bashrc。 将以下行添加到文件的底部,然后保存:
export LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2
– 现在源.bashrc在终端中使用此命令加载新设置:
source ~/.bashrc
– 如果我们正确地做了一切,我们应该能够安装oracle数据库适配器gem。 尝试使用此命令:
gem install ruby-oci8 -v '2.1.5'
如果您使用OS X El Capitan,Yosemite和Mavericks 。 您应该使用来自oracle网站的Instant Client 12.1.0.2下载Instant Client 12.1.0.2
- instantclient-basic-macos.x64-12.1.0.2.0.zip
- instantclient-sqlplus-macos.x64-12.1.0.2.0.zip
- instantclient-sdk-macos.x64-12.1.0.2.0.zip
然后按照以下步骤操作 : –
- 在/ opt / oracle创建目录
- 首先解压后立即客户端,移动到/ opt / oracle(应该添加一个文件夹 –
像/ opt / oracle / instantclient_12_1 /) - 解压Instantclient-sdk并将其内容移至/ opt / oracle / instantclient_12_1 /
- 解压Instantclient-sqlplus并移动其内容/ opt / oracle / instantclient_12_1 /
- 打开终端(如果你还没有)并输入…
DYLD_LIBRARY_PATH = / opt / oracle / instantclient_12_1 export DYLD_LIBRARY_PATH ORACLE_HOME = / opt / oracle / instantclient_12_1 export ORACLE_HOME
- cd / opt / oracle / instantclient_12_1
ln -s libclntsh.dylib.12.1 libclntsh.dylib(创建一个符号链接)
ln -s libocci.dylib.12.1 libocci.dylib
- run:env
- validationDYLD_LIBRARY_PATH = / opt / oracle / instantclient_11_2(确保有
没有尾随/在instantclient_11_2之后)validationORACLE_HOME = / opt / oracle / instantclient_11_2 - gem install ruby-oci8 -v gemVersion
- validationDYLD_LIBRARY_PATH = / opt / oracle / instantclient_11_2(确保有
注意: –如果仍然无效,请尝试在Mac上禁用SIP,然后再次尝试。
它对我有用,希望它也适合你。 祝一切顺利
- gem install pg error:无法理解Yosemite w / Ruby 2.1.5上的kern.osversion`14.0.0′
- 耙子流产了! 无法在El Capitan上加载这样的文件 – mysql2 / mysql2
- mac os x上的Tesseract-ocr gem问题
- Mac OS X上未初始化的常量Gem :: UserInteraction(NameError)
- 尝试安装Homebrew:返回了其他错误
- 无法在Mountain Lion上安装pg gem
- 尝试使用Rails和PostgreSQL生成模型时,命令会挂起而不会出错
- OS X Lion升级后捆绑包更新和安装失败 – Rails 3
- 服务器启动时自动rails app启动?