开发者

Problem with gem loading

开发者 https://www.devze.com 2022-12-16 17:33 出处:网络
I struggle to have gems correctly loading in a Snow Leopard environment. I installed ruby and rubygems in \'/usr/local\' (from http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-l

I struggle to have gems correctly loading in a Snow Leopard environment. I installed ruby and rubygems in '/usr/local' (from http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard/ instructions), I installed some gems with 'gem install gem-name'.

I correctly see开发者_如何学C the gem list:

$ gem list

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

I can see the gems correctly installed:

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

And the gem path correctly defined:

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

And I defined various paths in my bash profile:

$ 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"

However when I run the following script

#!/usr/local/bin/ruby

require 'rubygems'
require 'chrisjpowers-iterm_window'

I get the following error

/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

I have no idea how to fix it, any help would be greatly appreciated :)


You're requiring the wrong lib name. The gem is named chrisjpowers-iterm_window because of GitHub namespacing, but the library is named iterm_window:

require 'rubygems'
require 'iterm_window'

The lib path differs from the gem path. The gem path is where the gems are installed, but the lib path contains the lib directory of every installed gem after rubygems is loaded. You should see an iterm_window.rb inside the lib directory of that gem.

0

精彩评论

暂无评论...
验证码 换一张
取 消