在Rails中添加迁移时出现Gem :: LoadError

时间:2015-03-18 05:00:35

标签: ruby-on-rails

当我运行添加迁移时,我遇到以下问题:

raj@itadmin-HP-Pavilion-17-Notebook-PC:~/Desktop/Projects/invoicemanagement$ rails g migration add_avatars_to_invoice_details avatars:string
Warning: You're using Rubygems 1.8.23 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
/usr/lib/ruby/vendor_ruby/bundler/runtime.rb:33:in `block in setup': You have already activated spring 1.3.3, but your Gemfile requires spring 1.3.2. Using bundle exec may solve this. (Gem::LoadError)
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:19:in `setup'
    from /usr/lib/ruby/vendor_ruby/bundler.rb:120:in `setup'
    from /usr/lib/ruby/vendor_ruby/bundler/setup.rb:7:in `<top (required)>'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /var/lib/gems/1.9.1/gems/spring-1.3.3/lib/spring/commands.rb:33:in `<module:Spring>'
    from /var/lib/gems/1.9.1/gems/spring-1.3.3/lib/spring/commands.rb:4:in `<top (required)>'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /var/lib/gems/1.9.1/gems/spring-1.3.3/lib/spring/server.rb:9:in `<top (required)>'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'

和我的Gemfile:

source 'https://rubygems.org'


    # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
    gem 'rails', '4.1.4'
    #gem 'therubyracer' , '0.12.1',  :platforms => :ruby
    # Use sqlite3 as the database for Active Record
    gem 'sqlite3', :group => [:development, :test]
    group :production do
      # gem 'thin'
      gem 'pg'
    end
    # Use SCSS for stylesheets
    gem 'sass-rails', '~> 4.0.3'
    # Use Uglifier as compressor for JavaScript assets
    gem 'uglifier', '>= 1.3.0'
    # Use CoffeeScript for .js.coffee assets and views
    gem 'coffee-rails', '~> 4.0.0'
    # See https://github.com/sstephenson/execjs#readme for more supported runtimes
    # gem 'therubyracer',  platforms: :ruby

    # Use jquery as the JavaScript library
    gem 'jquery-rails'
    # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
    #gem 'turbolinks'
    # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
    gem 'jbuilder', '~> 2.0'
    # bundle exec rake doc:rails generates the API under doc/api.
    gem 'sdoc', '~> 0.4.0',          group: :doc

    # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
    gem 'spring',        group: :development

    # Use ActiveModel has_secure_password
    # gem 'bcrypt', '~> 3.1.7'

    # Use unicorn as the app server
    # gem 'unicorn'

    # Use Capistrano for deployment
    # gem 'capistrano-rails', group: :development

    # Use debugger
    # gem 'debugger', group: [:development, :test]
    gem 'devise'
    gem "therubyracer"
    gem "less-rails"
    gem "twitter-bootstrap-rails"

    gem 'carrierwave', '~> 0.9'
    gem 'bootstrap-sass', '~> 2.3.2'

    gem 'prawn'
    gem 'prawnto'
    gem 'carmen-rails', '~> 1.0.0'
    gem 'jquery-datatables-rails', '~> 3.0.0'
    gem 'haml', '~> 4.0.5'
    gem 'simple_form'

以前,迁移运行正常,我也尝试在添加迁移commmeand之前使用bundle exec,但我发现没有运气。

请告诉我,我哪里出错了。 提前谢谢。

2 个答案:

答案 0 :(得分:2)

Spring在20天前更新了

尝试bundle update spring尝试解决此问题。这不仅会更新您的gem,还会更新依赖项。

答案 1 :(得分:0)

如消息所示,您需要更新您的Rubygems版本,然后运行gem pristine --all

您可以通过运行gem update --system来更新Rubygems。

完成上述操作后,您就可以开始使用bundle exec为命令添加前缀。