All About The Gemfile

The Gemfile is great, and bundler is freakin great! And together, they figure out all of your application’s dependencies. I came up with a couple rules of thumb to help remember how it all fits toegher…

Gemfile and Bundler Rules of Thumbs

  1. Dependicies are the Gemfile’s and Bundler’s bitches!
  2. Dependencies ain’t got shit on Bundler or his homie Gemfile
  3. Gemfile.lock is Gemfile’s main ho
  4. Bundler does all the work, but Gemfile is the fucking BOSS and takes all the credit

But sometimes, even with awesome tools like working with the Gemfile can be confusing when you need to do things that you don’t do every day… Like… Updating Gems. Sometimes that fucks up your entire app, and that’s not a good thing!

For reasons why this happens, check out this post

Basically his recommendation is to update one gem at a time, and to do that… you run the following command

 $ bundle update ––source gemname

But sometimes that won’t actually update the gem due to versions specified in the Gemfile.

Find out Latest Available Version of Gem
$ gem list -r gemname
Find all Installed Gems
$ gem query --local | grep middleman
When Bundler doesn’t exist…
$ gem install bundler

Controlling Versions of Gems

    gem 'nokogiri'
    gem 'rails', '3.0.0.beta3'
    gem 'rack',  '>=1.0'
    gem 'thin',  '~>1.1'
    gem 'nokogiri', :git => '', :branch => '1.4'

nokogiri specifies no version, rails specifies exact version 3.0.0.beta3, rack specifies version greater than or equal to 1.0. this is different.

The ~> version controller

This version controller will not make any freakin sense until you understand it.

~>1.1 allows versions … >=1.1 and <2.0
~>1.2.3 allows versions … >=1.2.3 and <1.3.0
~>3.0.0.beta3 will match versions like 3.0.0.beta12, but not 3.0.1.beta3
So this was part of the reason my blog didn’t update correctly when using bundle update --source middleman-blog. I had gem middleman-blog, ~>3.4.5 specified in my gemfile which locks in a maximum version below 3.5. So I needed to update my gemfile, then update the gem itself. Things.. always things.. things to know. Now I know. And now it’s time for some PANDA XPRESSSS!

In the end I just ended up just using $ bundle update. So I suppose I failed at using my advice. But, nonetheless, I’m giving it a shot!

Post Content