解析多个版本的rubygems

时间:2009-10-19 18:24:00

标签: ruby rubygems version

我的机器上安装了多个版本的rubygems,当我宝石列表我看到了所有的宝石,但是当我去运行脚本时,我收到的错误消息如

Missing these required gems:
  SystemTimer 

我可以遵循任何方法来删除所有版本的rubygems而不是一个吗?理想情况下,我希望能够访问我的程序中 gem list 下显示的所有宝石。

来自宝石环境        - RUBY EXECUTABLE:/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

如果我跑:

$ /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby script/mailer_daemon_fetcher start production
no such file to load -- SystemTimer
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/rails/gem_dependency.rb:208:in `load'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:307:in `load_gems'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:307:in `each'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:307:in `load_gems'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:164:in `process'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `send'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `run'
./script/../config/environment.rb:13
script/mailer_daemon_fetcher:5:in `require'
script/mailer_daemon_fetcher:5
no such file to load -- SystemTimer
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/rails/gem_dependency.rb:208:in `load'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:307:in `load_gems'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:307:in `each'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:307:in `load_gems'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:169:in `process'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `send'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `run'
./script/../config/environment.rb:13
script/mailer_daemon_fetcher:5:in `require'
script/mailer_daemon_fetcher:5
Missing these required gems:
  SystemTimer  

You're running:
  ruby 1.8.7.72 at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  rubygems 1.3.5 at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8, /Library/Ruby/Gems/1.8

注意在上面我手动调用ruby ** / System / Library / Frameworks / Ruby.framework / Versions / 1.8 / usr / bin / ruby​​ **这是我 / usr /的文件符号链接为bin / ruby​​ ,并且我的GEM_PATH也设置为 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8

宝石环境的完整输出可在此处获取:http://pastie.org/661104

4 个答案:

答案 0 :(得分:3)

我认为问题是SystemTimer加载有点奇怪,所以你需要在environment.rb

中进行更多配置

“问题”似乎是gem被称为“SystemTimer”,但您需要加载“system_timer”。为了使用environment.rb实现此目的,您应该使用:

  config.gem 'SystemTimer', :lib => 'system_timer'

这似乎为我解决了同样的问题。

答案 1 :(得分:1)

gem cleanup

它将删除所有旧的宝石版本

你有环境问题 - 运行gem比在脚本中使用rubygems时更有其他人

查看(尤其是GEM PATHS)的输出

gem environment

你也可以比较shell中执行的ruby -e 'p ENV'和代码中某处执行p ENV的结果 - 寻找宝石相关内容的差异

答案 2 :(得分:1)

我觉得你可能使用的不同版本的红宝石比红宝石更好。无论是红宝石还是红宝石都不知道在哪里寻找你的宝石。

请参阅gem installation guide以确保您的环境配置为使用gem。

如果您在按照说明操作后仍然遇到问题,请确保您没有安装多个版本的ruby。如果有多个版本的Ruby可用,请确保您的脚本调用与gem相同的Ruby版本。这是通过将RUBY_EXECUTABLE的gem environment列表与脚本的shebang行进行比较来完成的。仔细检查以遵循任何符号链接,因为大多数基于分发的ruby安装会将/usr/bin/ruby符号链接到/usr/bin/ruby1.8

您还应该检查您的宝石是否由运行该脚本的同一用户安装。

如果您运行没有root权限的gem install,新的gem将安装在您的主目录中。如果您正在运行依赖于这些gem作为另一个用户的脚本。那些已安装的宝石将无法找到。但是,如果您的gem由root用户安装并且另一个用户正在运行需要这些gem的脚本,则没有问题。

我在从Ruby转换为Ruby Enterprise Edition时遇到了这个问题。我发现我必须使用REE的gem实例再次安装我所需的所有宝石。

答案 3 :(得分:1)

使用RVM https://rvm.io/,您可以拥有不同版本的Ruby(企业版,MRI,Rubinius等)和不同的宝石集。

检查一下,它真的很有用!