安装了Rails 3.1 gem的环境中的Bundler错误 [英] Bundler errors in environment with Rails 3.1 gem installed

查看:78
本文介绍了安装了Rails 3.1 gem的环境中的Bundler错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了Rails 3.0.10和3.1,因为我想同时用于两个不同的项目。



在我的Rails 3.0.10项目中,我在我的Gemfile的顶部有以下内容:

  gem'rails','3.0.10'

但是,在运行 bundle安装之后; bundle exec rails --version ,我得到以下信息:

  / Users / bradley / .rbenv / versions / ree-1.8.7-2011.03 / lib / ruby​​ / gems / 1.8 / gems / bundler-1.0.21 / lib / bundler / runtime.rb:31:在`setup'中:您已经激活了activesupport 3.1 .1,但您的Gemfile需要activesupport 3.0.10。使用bundle exec可以解决这个问题。 (Gem :: LoadError)
来自/Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime .rb:17:在/users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/的设置
中bundler.rb:110:在/Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib的设置
中/bundler/cli.rb:340:在/Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0的'exec'
中。 21 / lib / bundler / vendor / thor / task.rb:22:在/Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8的'send'
中/gems/bundler-1.0.21/lib/bundler/vendor/thor/task.rb:22:在/Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/中的'run'
中lib / ruby​​ / gems / 1.8 / gems / bundler-1.0.21 / lib / bundler / vendor / thor / invocation.rb:118:在来自/Users/bradley/.rbenv/versions/ree的'invoke_task'
中-1.8.7-2011.03 / lib / ruby​​ / gems / 1.8 / gems / bundler-1.0.21 / lib / bundler / vendor / thor.rb:2 63:来自/Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/vendor的分发
/thor/base.rb:386:在/Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0的'start'
中。 21 / bin / bundle:13
来自/Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/bin/bundle:19:in`load'
来自/ Users / bradley / .rbenv / versions / ree-1.8.7-2011.03 / bin / bundle:19

有什么想法吗?显然,我已经在使用 bundle exec bundle show rails; bundle show activesupport 确认我应该使用正确版本的gem。我只需要卸载Rails 3.1吗?

解决方案

我遇到了同样的问题。



即使我在Gemfile中明确指定要使用的activesupport版本 ,也是如此:

  gem'rails','3.2.9'
gem'activesupport','3.2.9'

当我运行 bundle exec rails s 时,它仍然给我这个错误:

  /home/tyler/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.0.18/lib/bundler/runtime.rb :31:in`block in setup':
您已经激活了activesupport 3.2.10,但是您的Gemfile需要activesupport 3.2.9。考虑使用bundle exec。 (Gem :: LoadError)

当我想尝试返回旧版本时会发生这种情况



因此,即使为我的应用程序创建单独的gemset(无论如何我们通常也会这样做)也无法解决之所以会出现问题,是因为该应用程序本身(在返回到Rails 3.2.9之前临时安装/使用Rails 3.2.10)而不是其他某个应用程序污染了宝石集!



到目前为止,我找到的唯一解决方案卸载您不希望使用的较新版本:

 宝石卸载activesupport -v 3.2.10 

这似乎是Bundler中的一个错误或Rails中的一个错误(如果它导致在 加载Bundler之前加载/激活activesupport,那么我们就无法

另一个同样糟糕的解决方案::要暂时禁用宝石的新版本 而无需卸载,您可以编辑宝石的规范文件(例如 / home / tyler / .rvm / gems / ruby​​-1.9.3-p194 / specifications / activesupport-3.2.10.gemspec ),并添加一行 raise disabled 在顶部。 Bundler将跳过 activesupport 3.2.10 的加载(在挽救并打印错误后),然后继续加载 activesupport 它可以找到( activesupport 3.2.9 )。



当您准备重新-启用 activesupport 3.2.10 ,只需删除 raise



如果您只想在使用较旧版本的gem进行测试,然后再返回较新版本的gem,则这可能比卸载并重新安装gem更快。


I've got Rails 3.0.10 and 3.1 installed because I am trying to use both for two different projects.

In my Rails 3.0.10 project, I have the following at the top of my Gemfile:

gem 'rails', '3.0.10'

However, after running bundle install; bundle exec rails --version, I'm getting the following:

/Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:31:in `setup': You have already activated activesupport 3.1.1, but your Gemfile requires activesupport 3.0.10. Using bundle exec may solve this. (Gem::LoadError)
    from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:17:in `setup'
    from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler.rb:110:in `setup'
    from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/cli.rb:340:in `exec'
    from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/vendor/thor/task.rb:22:in `send'
    from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/vendor/thor/task.rb:22:in `run'
    from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
    from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/vendor/thor.rb:263:in `dispatch'
    from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/vendor/thor/base.rb:386:in `start'
    from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/bin/bundle:13
    from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/bin/bundle:19:in `load'
    from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/bin/bundle:19

Any ideas? Obviously, I'm already using bundle exec and bundle show rails; bundle show activesupport confirm that I should be using the right versions of the gems. Do I just need to uninstall Rails 3.1?

解决方案

I've run into the same problem.

Even when I explicitly specify the version of activesupport to use in my Gemfile:

gem 'rails', '3.2.9'
gem 'activesupport', '3.2.9'

it still gives me this error when I run bundle exec rails s:

/home/tyler/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.0.18/lib/bundler/runtime.rb:31:in `block in setup':
You have already activated activesupport 3.2.10, but your Gemfile requires activesupport 3.2.9. Consider using bundle exec. (Gem::LoadError)

This happens for me when I want to try going back to an older version of Rails in my app to test a difference between the two versions of Rails.

So even creating a separate gemset for my app (which we usually do anyway) does not solve the problem, because the gemset was "polluted" by this app itself (by temporarily installing/using Rails 3.2.10 before going back to Rails 3.2.9), not by some other app!

The only solution I've found so far is to uninstall the newer version that you don't want it to use:

gem uninstall activesupport -v 3.2.10

It seems like this is either a bug in Bundler or a bug in Rails (if it does something that causes activesupport to be loaded/activated before it loads Bundler, then we can't really blame it on Bundler...).

Another equally terrible solution: To disable a newer version of a gem temporarily without uninstalling it, you can edit the gem's specification file (for example, /home/tyler/.rvm/gems/ruby-1.9.3-p194/specifications/activesupport-3.2.10.gemspec) and add a line raise 'disabled' at the top. Bundler will skip the loading of activesupport 3.2.10 (after rescuing and printing the error) and proceed to load the next highest version of activesupport that it can find (activesupport 3.2.9).

When you're ready to re-enable activesupport 3.2.10, simply remove the raise.

This may be quicker than uninstalling and reinstalling a gem, if you just want to test something with the older version before going back to the newer version of them gem.

这篇关于安装了Rails 3.1 gem的环境中的Bundler错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆