Search code examples
rubyrubygemsbundler

Why isn't 'bundler/setup' including any of the gems in my Gemfile?


I'd like to use bundler/setup to include all of my listed gems but I'm not succeeding. In go.rb I have

require 'rubygems'                                                                                                
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('Gemfile', __FILE__)                                                   
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])

which fails to require httparty as I thought it would:

$ bundle exec ruby go.rb                                                                                          
go.rb:5:in `<main>': uninitialized constant HTTParty (NameError)  

What am I doing incorrectly?


I've created a small project for this question, here.


Solution

  • As far as I understand 'bundler/setup' it only manages the require path (removes the default contents and adds paths for gems that are defined in Gemfile.lock). If you don't require the libraries in question, their contents won't be available.