How to use gems not in a Gemfile when working with bundler?

前端 未结 6 1359
失恋的感觉
失恋的感觉 2020-12-28 15:18

When using bundler with a project in general and Rails specifically, you have access only to gems defined in your Gemfile. While this makes sense, it can be limiting. Mostly

6条回答
  •  再見小時候
    2020-12-28 16:09

    Add to .gitignore

    Gemfile.local
    Gemfile.local.lock
    

    Add to the project a Gemfile.local.sample file with the following content:

    # Include gems that are note meant to be part of the project but for development purposes
    # That's why Gemfile.local and Gemfile.local.lock must be git-ignored
    
    # To use these gems:
    #   1. Create a "Gemfile.local" file (at same level of "Gemfile")
    #   2. Prepend "BUNDLE_GEMFILE=Gemfile.local" before "bundle install" or "bundle exec rails c" and so forth.
    
    eval_gemfile "./Gemfile"
    
    group :development, :test do
      # Suggested gems
      gem "awesome_print", require:"ap"
      gem "hirb"
      gem "pry"
      gem "pry-byebug"
      gem "pry-rails"
      gem "meta_request"
    
      # My gems
      gem "fivemat"
    end
    

提交回复
热议问题