2012-08-10 88 views
22

我試圖在OS X如何安裝ruby-oci8?

安裝Ruby-OCI8我已經試過既沒有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 
+0

您是否嘗試按照錯誤文本中的建議運行'sudo'命令,並且您是否已驗證您具有在/Library/Ruby/Gems/1.8中授予的寫入權限? – 2012-08-10 16:43:51

+0

是的,我曾嘗試與sudo。錯誤是DYLD_LIBRARY_PATH未設置。 – earlyriser 2012-08-10 18:40:29

回答

45

稍微更新安裝Ruby-OCI8的版本爲10.9/10.10/10.11OSX小牛/優勝美地/埃爾卡皮坦 - 一步一步:

  1. 去這裏:http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html
  2. 下載64位instantclient-sqlplus中,instantclient-SDK,版本instantclient-基本 - 32位版本不支持OSX 10.9合作
  3. 上的/ opt/oracle的
  4. 解壓instantclient-基本的,移動到/ opt/ORA創建目錄CLE(應該添加一個文件夾 - 類似的/ 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(創建SA符號鏈接)
  12. env
  13. 驗證DYLD_LIBRARY_PATH = /選擇/ ORACLE/instantclient_11_2(請務必有沒有尾隨/ instantclient_11_2後)
  14. 校驗ORACLE_HOME = /選擇/ ORACLE/instantclient_11_2
  15. 創業板安裝ruby- oci8

之後應該工作。文件結構應該類似於此:

enter image description here

+12

哇,屁股疼! – Rn2dy 2014-05-13 05:57:15

+1

起初,說明看起來令人望而生畏,但我一步一步地跟着他們,終於能夠在優勝美地安裝ruby-oci8。偉大的工作寫他們。非常感謝。 – 2014-10-29 08:46:24

+0

嘿,快速的問題。如何找到系統密碼:'請爲您的Oracle安裝提供SYSTEM密碼' – tmartin314 2014-11-24 18:27:57

1

該錯誤消息是稍微詳細,但它基本上說您需要安裝Oracle Client libraries和將DYLD_LIBRARY_PATH變量指向該位置。

+0

嗨Steen。你說的是這個問題,但是我選擇了另一個答案,因爲它符合我提問的方式,但是你確定了這個問題。 – earlyriser 2014-06-23 13:29:57

0

開始從他們的網站下載的Oracle版本instantclient 11.2 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。以下行添加到文件底部,然後將其保存:

source ~/.bashrc 

- 現在,如果我們:

export LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2 

- 現在源的.bashrc與此命令,在終端加載新設置一切正常,我們應該能夠安裝oracle數據庫適配器gem。用這個命令試試:

gem install ruby-oci8 -v '2.1.5' 
7

對於任何試圖得到這個的好舊的一年2016年的工作,錯誤消息現在包含一個鏈接,讓您瞭解如何使用做說明頁http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install-on-osx.md家釀。上述所有的東西都不適合我(我試了一下),但後來我把這個問題帶給了一個同事,他們說:「嘿,你有沒有在錯誤消息中嘗試鏈接?」果然,那已經做到了。

+0

只是檢查,但按照這些說明,你得到它與安裝在El Capitan的12.1.0.2 instaclient版本? – 2016-06-08 13:58:59

+0

埃爾卡皮坦是,12.1.0.2 ...不確定,我無法訪問我第一次設置的機器。很確定這是去年3月的最新版本,無論如何。 – 2016-06-23 22:13:40

+2

哇,看錯誤信息? Who'da thunk?謝謝。 +1 – istrasci 2016-11-09 22:23:44

1

萬一別人需要在Mac OSX上埃爾卡皮坦上的Ruby 1.8.7安裝Ruby-OCI8的舊版本,我已經成功使用下面的方法安裝紅寶石oci8-2.1.2。我認爲它會在其他的Ruby-1.8.7版本的工作,以及(紅寶石OCI8 < 2.2.0),但我沒有檢查其他版本:

  1. 去這裏:http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html 下載的64位版本instantclient-基本instantclient-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. 現在搶紅寶石OCI8源git clone https://github.com/kubo/ruby-oci8.git
  9. 結帳要安裝(我需要2.1.2)版本git checkout ruby-oci8-2.1.2
  10. 編輯這個文件:紅寶石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'

  • 現在改變回寶石本身的根目錄並建立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
  • 1

    如果您在El Capitan中使用MAC,由於系統完整性保護(SIP)的最新嵌入功能,DYLD_ *環境變量將被忽略。

    因此,如果您想與El Capitan安裝ruby-oci8,首先必須禁用SIP。

    按照以下步驟禁用SIP:

    1. 重新啓動Mac。
    2. 在OS X啓動之前,按住Command-R並保持不動,直到看到Apple圖標和進度條。發佈。這將引導你進入恢復。
    3. 從「實用工具」菜單中選擇「終端」。
    4. 在提示符處輸入以下內容,然後按回車鍵:csrutil禁用
    5. 終端應顯示禁用SIP的消息。
    6. 從菜單中選擇重新啓動。

    如果你仍然面臨的問題嘗試此鏈接 http://blog.codiez.co.za/2013/09/setup-oracle-instant-client-ruby-oci8-gem-mac/

    0

    如果您正在使用OS X埃爾卡皮坦,優勝美地和小牛。您應該使用即時客戶端12.1.0.2 下載即時客戶端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。拉鍊

    然後按照這些步驟: -

    1. 創建上的/ opt/Oracle目錄
    2. 解壓instantclient-基本的,移動到/ 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 = /選擇/甲骨文/ instantclient_12_1出口 DYLD_LIBRARY_PATH ORACLE_HOME = /選擇/ ORACLE/instantclient_12_1出口ORACLE_HOME

  • 坎德拉/選擇/ ORACLE/instantclient_12_1
  • LN -s libclntsh.dylib.12.1 libclntsh.dylib(創建符號鏈接)

    LN -s libocci.dylib.12.1 libocci.dylib

  • 運行:ENV
  • 驗證DYLD_LIBRARY_PATH = /選擇/ ORACLE/instantclient_11_2(一定有
    沒有尾隨/ instantclient_11_2後) 驗證ORACLE_HOME = /選擇/ ORACLE/instantclient_11_2
  • 創業板安裝Ruby-OCI8 -v gemVersion
  • 注: -如果仍然沒有工作,來回嘗試禁用SIP在你的mac上 然後再試一次。

    它已經爲我工作,希望它也適用於你。所有最優秀的

    2

    在OS X塞拉利昂,我無法設置DYLD_LIBRARY_PATH由於系統完整性保護(https://forums.developer.apple.com/thread/13161),所以我複製所有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 
    ... 
    

    而且寶石安裝成功!

    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