NameError:未初始化的常数Bundler(NameError: uninitialized constant Bundler)

12 IT屋

I just changed my webserver to Puma and had to change my development DB from sqlite to postgresql. but now I'm getting this error everytime I try to run 'rake db:migrate':

rake aborted!
NameError: uninitialized constant Bundler
C:/Sites/dawnrebirth/config/application.rb:7:in <top (required)>'
C:/Sites/dawnrebirth/Rakefile:4:in <top (required)>'
(See full trace by running task with --trace)

my gemfile:

source 'https://rubygems.org'
gem 'rails', '4.2.1'
gem 'pg'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
  gem 'byebug'
  gem 'web-console', '~> 2.0'
  gem 'better_errors', '~> 2.1.1'
  gem 'annotate', '~> 2.6.10'
  gem 'binding_of_caller'
 end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'devise', '~> 3.5.1'
gem 'haml', '~> 4.0.6'
gem 'sass', '~> 3.4.14'
gem 'paperclip', '~> 4.3.0'
gem 'babosa', '~> 1.0.2'
gem 'rails-i18n', '~> 4.0.4'
gem 'devise-i18n', '~> 0.12.1'
gem 'simple_form', '~> 3.1.0'
gem 'dotiw'
gem 'paperclip-dropbox', '~> 1.3.2'
gem 'rmagick', '~> 2.15.3', group: :production
gem 'masonry-rails', '~> 0.2.4'
gem 'rufus-scheduler', '~> 3.1.3'
gem 'jquery-turbolinks'
gem 'puma'
gem 'rails_12factor', group: :production
gem 'mailboxer'
gem 'acts_as_votable'

ruby "2.1.5"

EDIT:

running bundle exec rake db:migrate works and successfully migrates my db.

解决方案

Install the bundler gem:

gem install bundler

Then, try again.

Update

If the above does not work, try:

rm -rf .bundle/
rm -rf vendor/cache/

Then try again.

If this does not work, you may try removing Gemfile.lock which is not recommended (but if you are just starting your project and no one else is having Gemfile.lock in their machine, you can do this):

rm -rf Gemfile.lock

我只是将Web服务器更改为Puma,并且不得不将开发数据库从sqlite更改为postgresql。但现在每次尝试运行" rake db:migrate"时,都会出现此错误:



  rake被中止! 
NameError:未初始化的常量捆绑器
C:/Sites/dawnrebirth/config/application.rb:7:in< top(必需)>'
C:/ Sites / dawnrebirth / Rakefile :4:in< top(必需)>'
(通过使用--trace运行任务来查看完整跟踪)


我的gemfile:



  source'https://rubygems.org'
gem 'rails','4.2.1'
gem'pg'
gem'sass-rails','〜> 5.0"
宝石uglifier","> = 1.3.0"
宝石" coffee-rails","〜> 4.1.0’
gem‘jquery-rails’
gem‘turbolinks’
gem‘jbuilder’,’〜> 2.0"
gem" sdoc","〜> 0.4.0",组::doc
组:开发,:test做
gem‘byebug’
gem‘web-console’,’〜> 2.0"
宝石" better_errors","〜> 2.1.1"
宝石"注释","〜> 2.6.10'
gem'binding_of_caller'
end
gem'tzinfo-data',平台:[:mingw,:mswin,:x64_mingw,:jruby]

gem'devise','〜> 3.5.1’
宝石‘haml’,’〜> 4.0.6"
宝石" sass","〜> 3.4.14"
宝石"回形针","〜> 4.3.0"
宝石" babosa","〜> 1.0.2’
宝石’rails-i18n’,’〜> 4.0.4’
宝石‘devise-i18n’,’〜> 0.12.1’
宝石‘simple_form’,’〜> 3.1.0’
宝石‘dotiw’
宝石‘paperclip-dropbox’,’〜> 1.3.2’
宝石‘rmagick’,’〜> 2.15.3",组::生产
宝石"砌石路轨","〜> 0.2.4’
宝石‘rufus-scheduler’,’〜> 3.1.3'
gem'jquery-turbolinks'
gem'puma'
gem'rails_12factor',组::production
gem'mailboxer'
gem'acts_as_votable '

红宝石" 2.1.5"


编辑:



运行 bundle exec rake db:migrate 可以成功迁移我的数据库。


解决方案

安装捆绑器 gem:



 < code> gem安装捆绑软件


然后,再试一次。



更新



如果上述方法无效,请尝试:



  rm -rf .bundle / 
rm -rf vendor / cache /


< p>然后再试一次。



如果这不起作用,您可以尝试删除 Gemfile.lock 而不是建议(但如果您只是开始您的项目,并且没有人在他们的计算机中拥有 Gemfile.lock ,则可以这样做):



  rm -rf Gemfile.lock 

本文地址:IT屋 » NameError:未初始化的常数Bundler