运行Rails控制台时出现Gem :: LoadError

时间:2015-03-10 22:23:59

标签: ruby-on-rails

我正在尝试通过执行rails console来运行Rails控制台并且我收到了该错误

 /home/ahmed/.rvm/gems/ruby-.2.0@global/gems/bundler-.8.2/lib/bundler/runtime.rb:34:in `block in setup': You have already activated spring 1.3.3, but your Gemfile requires spring 1.3.2. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
  from home/ahmed/.rvm/gems/ruby-.2.0@global/gems/bundler-.8.2/lib/bundler/runtime.rb:19:in `setup'
  from /home/ahmed/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.8.2/lib/bundler.rb:122:in `setup'
  from /home/ahmed/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.8.2/lib/bundler/setup.rb:8:in `<top (required)>'
  from /home/ahmed/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  from /home/ahmed/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  from /home/ahmed/.rvm/gems/ruby-2.2.0/gems/spring-1.3.3/lib/spring/commands.rb:33:in `<module:Spring>'
  from /home/ahmed/.rvm/gems/ruby-2.2.0/gems/spring-1.3.3/lib/spring/commands.rb:4:in `<top (required)>'
  from /home/ahmed/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  from /home/ahmed/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  from /home/ahmed/.rvm/gems/ruby-2.2.0/gems/spring-1.3.3/lib/spring/server.rb:9:in `<top (required)>'
  from /home/ahmed/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
  from /home/ahmed/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
  from /home/ahmed/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'

5 个答案:

答案 0 :(得分:13)

我认为你的机器有多个spring gem版本。我想删除spring 1.3.3。

$ gem uninstall spring

显示机器上的所有弹簧宝石

uninstall spring version like shown on this attached image

我有类似的问题,它解决了问题

答案 1 :(得分:3)

更改您的应用程序Gemfile

gem 'spring'

gem 'spring', "~>1.3.3"

bundle install
bundle update
它对我有用!

答案 2 :(得分:2)

更改您的应用程序Gemfile

gem 'spring'

gem 'spring', "~>1.3.3" 

答案 3 :(得分:1)

首先尝试运行捆绑更新 - 这为我解决了这个问题

   bundle update

然后

  rails console

答案 4 :(得分:0)

您是否尝试按照建议将bundle exec添加到您的命令中?

bundle exec rails console