Rails uninitialized constant Bundler (NameError)

前端 未结 3 762
半阙折子戏
半阙折子戏 2020-12-14 11:34

I\'m getting the following error when running any rails commands like rails s or rails c, it\'s also preventing my heroku app from starting (same e

相关标签:
3条回答
  • 2020-12-14 12:05

    These commands from the bundler FAQ did the trick:

    #remove project-specific settings
    rm -rf .bundle/
    
    # remove project-specific cached gems and repos
    rm -rf vendor/cache/
    
    # remove the saved resolve of the Gemfile
    rm -rf Gemfile.lock
    

    and then rebundling with bundle install

    edit: heroku deploy was also failing to start up because it starts the server with bin/rails s and my binstubs were all wonky. to fix this: BUNDLE INSTALL --BINSTUBS, again from bundler docs

    0 讨论(0)
  • 2020-12-14 12:10

    I just removed the lock using rm -rf Gemfile.lock within my project directory's root folder, and re-ran bundle install and everything works perfect now.

    0 讨论(0)
  • 2020-12-14 12:27

    I have problems like you, subscribe my case.

    config/applicataion.rb:

    require_relative 'boot'
    
    require 'rails/all'
    
    # Require the gems listed in Gemfile, including any gems
    # you've limited to :test, :development, or :production.
    Bundler.require(*Rails.groups)
    
    module AppName
      class Application < Rails::Application
        config.load_defaults 5.2
      end
    end
    

    where require_relative 'boot' is very important, such as config/boot.rb:

    ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
    
    require 'bundler/setup' # Set up gems listed in the Gemfile.
    

    has including bundler library into application.

    0 讨论(0)
提交回复
热议问题