Is there a bundle command to tell me what would be updated with
bundle update, without actually making those updates?
As it turns out there is! Bundler 1.1 introduces a new command:
bundle outdated Show all of the outdated gems in the current bundle. This will give you a report of gems that have newer versions available.
By itself, this will list all of the gems in your Gemfile.lock that have newer versions, and what the current and latest versions are.
This gives a good preview of what you are up against if you want to get your gems up to date. From there, use git commits to make incremental changes.
Putting it to use
Today I created an app with the suspenders gem, and noticed it is running on Rails 3.1.1, which I wanted to upgrade to 3.2.2.
I also saw a few other gems with version attributes:
gem 'sass-rails', '~> 3.1.4' gem 'coffee-rails', '~> 3.1.1' gem 'uglifier', '>= 1.0.3' gem 'rspec-rails', '~> 2.6.1' gem 'cucumber-rails', '1.1.0' gem 'capybara-webkit', '~> 0.7.1'
First I ran
rake to confirm all tests were passing,
bundle update to make sure the gems were all up to date with the versions specified, and created an initial commit.
Next I upgraded to rails 3.2.2 and reran
bundle update, and found out (after a couple itterations) that
coffee-rails had to be updated too, because of there dependance on
ActiveSomethingOrOther. Updating these three gems to their latest versions allowed
bundle update to do it’s thing.
I reran my tests, and did ran
git diff Gemfile.lock to see exactly what was new. For giggles I reran
bundle outdated and rejoiced at the shrinking list. Time to commit with a message about the gem version changes.
From here it was rinse and repeat, checking rubygems.org and looking at the dependencies, making small changes, bundling, raking, committing.
At the end of the road I had a good series of commits spelling out exactly what was needed to get to my goal of a fully updated rails 3.2.2 environment.
If you run
bundleoutdated and all you see is:
Outdated gems included in the bundle: * sprockets (2.4.0 > 2.1.2)
Then you are doing it right!
Have a cookie!
Read more about what’s new with bundler 1.1 from Pat Shaughnessy.