Understanding Gemfile Dependencies
I really struggled with this while learning Rails. In the Gemfile, I thought you could have groupings of Gems that would only be installed for a particular environment, like:
group :production do gem 'execjs' gem 'mysql' end
And, you can–but not in the way I thought. What I thought was that if my environment was set to something other than “production,” then those Gems wouldn’t load. But that’s not the case without a little extra coaxing from bundler.
To ignore those gems, when I bundle, I need to add the switch --without production, like
bundle install --without production
Obviously you’d want to change production to whatever group you wanted bundler to skip. Doing this stores a flag in your APP_ROOT/.bundle/config file, and then subsequent bundles won’t include gems within the production group. That’s how you get groupings of Gems to be ignored in your Gemfile. To read more, check out http://gembundler.com/rationale.html.
Got anything to say? Go ahead and leave a comment!
Archives
- January 2012
- December 2011
- November 2011
- May 2011
- April 2011
- March 2011
- February 2011
- January 2010
- December 2009
- September 2009
- August 2009
- April 2009
- February 2009
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- May 2007
- April 2007
- March 2007
- January 2007
- December 2006
- October 2006
- August 2006



Posted under: