ruby和IRB找到安装的宝石,但是eclipse不能

时间:2012-09-10 10:20:51

标签: ruby eclipse

我是Ruby开发的初学者,所以道歉这是一个面子问题。

在mac OSX上我安装了ruby 1.9.3,然后通过命令'gem install selenium-webdriver'安装了一个gem,然后我安装了eclipse作为IDE。

然后我写了一个简单的类,需要'selenium-webdriver'宝石。

class Cheese
  require 'rubygems'
  require 'selenium-webdriver'
  ... rest of code class. 

我可以使用irb或ruby(即ruby ./path to file / cheese.rb)从命令行运行cheese.rb,但是当通过eclipse GUI运行脚本时,我收到错误:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- selenium-webdriver (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /Users/bryan/Documents/workspace/New Se Project/Cheese.rb:3

这表明Eclipse存在配置问题。请注意,安装的默认ruby版本是来自rvm-list的1.9.3,但Eclipse仍然“绑定”到1.8。谷歌搜索表明这可能是一个路径问题,但我不熟悉Mac OSx上的环境变量。

* 如何重新配置​​Eclipse(或Aptana)以“看到”已安装的宝石? *

更多信息:

Bryans-MacBook-Air:Library bryan$ which ruby
/Users/bryan/.rvm/rubies/ruby-1.9.3-p194/bin/ruby

Bryans-MacBook-Air:Library bryan$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.24
  - RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-darwin11.4.0]
  - INSTALLATION DIRECTORY: /Users/bryan/.rvm/gems/ruby-1.9.3-p194
  - RUBY EXECUTABLE: /Users/bryan/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/bryan/.rvm/gems/ruby-1.9.3-p194/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-11
  - GEM PATHS:
     - /Users/bryan/.rvm/gems/ruby-1.9.3-p194
     - /Users/bryan/.rvm/gems/ruby-1.9.3-p194@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
    - :backtrace => false
    - :bulk_threshold => 1000
 - REMOTE SOURCES:
    - http://rubygems.org/


Bryans-MacBook-Air:Library bryan$  echo $PATH
/Users/bryan/.rvm/gems/ruby-1.9.3-p194/bin:/Users/bryan/.rvm/gems/ruby-1.9.3-p194@global/bin:/Users/bryan/.rvm/rubies/ruby-1.9.3-p194/bin:/Users/bryan/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。我首先尝试了本教程:http://net.tutsplus.com/tutorials/ruby/how-to-install-ruby-on-a-mac/

这没有帮助。

然后我在超级用户中看到了这个条目:https://superuser.com/questions/154292/ruby-rubygems-why-do-i-always-get-error-messages-when-trying-to-install-gems并使用sudo运行gem install帮助了我。