2010-11-25 124 views
6

我有點在我的智慧在這裏結束。我在OSX10.6上,我的寶石都搞砸了。我試圖使用的寶石之一是Hashie。我在網上瀏覽過,有幾個人似乎也遇到了類似的問題,但是我的解決方案似乎都不適用於我的案例。感謝您的期待。紅寶石找不到安裝的寶石

我所有的Ruby腳本/寶石安裝在/opt/ruby-enterprise-1.8.7-2010.02:

Komputor:~$ which ruby gem irb rails 
/opt/ruby-enterprise-1.8.7-2010.02/bin/ruby 
/opt/ruby-enterprise-1.8.7-2010.02/bin/gem 
/opt/ruby-enterprise-1.8.7-2010.02/bin/irb 
/opt/ruby-enterprise-1.8.7-2010.02/bin/rails 

和示例寶石,HASHIE(和許多其他)安裝:

Komputor:~ $ gem list -l | wc -l 
     67 
Komputor:~ $ gem list | grep hashie 
hashie (0.4.0) 
Komputor:gems $ cd /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems 
Komputor:gems $ ls | grep hashie 
drwxr-xr-x 13 root admin 442 Nov 24 17:13 hashie-0.4.0 

然而,當我嘗試從IRB或腳本訪問他們,這一切都失敗:

Komputor:~ $ irb 
irb(main):001:0> require 'hashie' 
LoadError: no such file to load -- hashie 
    from (irb):1:in `require' 
    from (irb):1 
irb(main):002:0> 

一些環境瓦里ABLES: 寶石ENV:

Komputor:gems $ gem env 
RubyGems Environment: 
    - RUBYGEMS VERSION: 1.3.7 
    - RUBY VERSION: 1.8.7 (2010-04-19 patchlevel 253) [i686-darwin10.4.0] 
    - INSTALLATION DIRECTORY: /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8 
    - RUBY EXECUTABLE: /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby 
    - EXECUTABLE DIRECTORY: /opt/ruby-enterprise-1.8.7-2010.02/bin 
    - RUBYGEMS PLATFORMS: 
    - ruby 
    - x86-darwin-10 
    - GEM PATHS: 
    - /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8 
    - /Users/<snip>/.gem/ruby/1.8 
    - GEM CONFIGURATION: 
    - :update_sources => true 
    - :verbose => true 
    - :benchmark => false 
    - :backtrace => false 
    - :bulk_threshold => 1000 
    - REMOTE SOURCES: 
    - http://rubygems.org/ 

$ PATH:

Komputor:gems $ echo $PATH 
/sw/bin:/sw/sbin:/opt/ruby-enterprise-1.8.7-2010.02/bin:/Applications/android-sdk-1.5/tools:/usr/brlcad/bin:/usr/local/mysql-5.0.67-osx10.5-x86_64/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/mongodb/bin:/sw/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:/usr/X11R6/bin 

我會很高興地張貼任何命令的輸出進行調試。

感謝您的期待!

+3

你不必須「要求'rubygems'」,然後才能「需要'hashie'」? – 2010-11-25 00:41:20

+0

好的,這讓我一半在那裏。 我注意到rails在boot.rb文件中有這個。我的lib文件夾中的一個文件也需要hashie,並且我在require'hashie'行上添加了require'rubygems',並且它仍然給出相同的錯誤。 – voxobscuro 2010-11-25 00:54:58

回答

12

正如亞當范登堡指出,加載寶石之前,你需要require "rubygems"

一些框架可以加載這個給你,你可以將其設置爲自動加載在你.irbrc如果你喜歡