1

I have a Sinatra application and I'm trying to use groups in my Gemfile in order to load only specified gems. But, when I restrict loading to just one group bundler still loads every gem in the file. Here's my Gemfile:

source 'https://rubygems.org'

group :one do
  gem 'sinatra'
end

group :two do 
  gem 'bitly'
end

And here's my application:

require 'bundler/setup'
Bundler.require(:one)

class App < Sinatra::Base

  configure do
    puts Gem.loaded_specs.keys.sort.join("\t")
  end

  get '/foo' do
  end

end

And I can clearly see the Bitly gem loaded when the application starts. What am I doing wrong?

Johnny
  • 7,073
  • 9
  • 46
  • 72
  • [Related question](http://stackoverflow.com/questions/6963836/why-does-bundle-install-production-gems-on-my-development-machine/6963907#6963907) – Mori Jun 04 '14 at 18:22

1 Answers1

2

Use

require 'bundler'

instead of

require 'bundler/setup'

The last one automatically loads all gems in Gemfile: Why do you need "require 'bundler/setup'"?

Community
  • 1
  • 1
Zhomart
  • 702
  • 1
  • 7
  • 19