NameError: uninitialized constant Bundler

2019-09-21 10:09发布

问题:

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.

回答1:

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