2010-01-12 109 views
0

我很難在寶貝環境中正確加載寶石。我在'/ usr/local'(從http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard/的說明中)安裝了ruby和rubygems,我用'gem install gem-name'安裝了一些gem。寶石裝載問題

我正確地看到了創業板名單:

$ gem list 

*** LOCAL GEMS *** 
chrisjpowers-iterm_window (0.3.2) 
gemcutter (0.3.0) 

我可以看到正確安裝寶石:

$ ls /usr/local/lib/ruby/gems/1.8/gems/ 
chrisjpowers-iterm_window-0.3.2 
gemcutter-0.3.0 

,正確定義的寶石路徑:

$ gem env path 
/usr/local/lib/ruby/gems/1.8 

我定義各種路徑在我的bash配置文件中:

$ cat ~/.bash_profile 

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH" 
export GEM_HOME="/usr/local/lib/ruby/gems/1.8" 
export GEM_PATH="/usr/local/lib/ruby/gems/1.8" 
export RUBY_LIB="/usr/local/lib/ruby:/usr/local/lib/ruby/site_ruby" 

然而,當我運行下面的腳本

#!/usr/local/bin/ruby 

require 'rubygems' 
require 'chrisjpowers-iterm_window' 

我收到以下錯誤

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- chrisjpowers-iterm_window (LoadError) 
     from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' 
     from /usr/local/bin/sp:4 

我不知道如何解決它,任何幫助,將不勝感激:)

回答

2

您需要錯誤的lib名稱。寶石被命名爲chrisjpowers-iterm_window因爲GitHub的命名空間,但庫命名爲iterm_window

require 'rubygems' 
require 'iterm_window' 

的庫路徑從寶石路徑不同。 gem路徑是安裝gem的地方,但lib路徑包含加載rubygems後每個安裝的gem的lib目錄。您應該在該寶石的lib目錄內看到一個iterm_window.rb