← Back to Upcase

Versioning your Gemfile


(Edward Loveall) #1

I’d love to hear if anyone else versions their gem file. It seems like a good idea to me, but I might be missing some downsides (besides a less clean looking Gemfile). With ruby’s pessimistic operator it seems like you wouldn’t even necessarily be out of date that much, except for big version changes. But that almost seems like an upside since you wouldn’t want to upgrade a major gem version without looking at it first.

Any thoughts?


(Geoff Harcourt) #2

@edwardloveall, do you mean tracking in version control?

You definitely want to check in your Gemfile and your Gemfile.lock

The first reason is that tracking your Gemfile.lock helps you be sure you are on the same versions of gems as you were before. If your tests start failing after you bundle, you now have a place to fall back to.

The second reason is if you share a project with any other developers, sharing Gemfile.lock ensures you’re all using the same versions of every gem.

The third reason is that if you add a gem, it may influence the choice of dependencies (in some cases, downgrading a gem to an earlier version to satisfy dependency requirements). Without source control, you can’t follow these changes.


(Edward Loveall) #3

Ah, apologies, I should have been more clear. I meant adding verions next to every line in the Gem file, like so:

gem 'bourbon', '~> 4.0.1'
gem 'jbuilder', '~> 2.0.6'

as opposed to simply:

gem 'bourbon'
gem 'jbuilder'

Version control is :thumbsup:


(Geoff Harcourt) #4

Haha, sorry for the misunderstanding.

If you have a good test suite, I’m a big fan of only locking gems with the squiggly operator at the patch or minor level that you know are 1) not following SemVer or 2) have issued breaking changes in minor releases in the past. I like to get the upgrades from gems without having to check them out, so I prefer to wait until my test suite exposes problems before I start locking without provocation.


(Edward Loveall) #5

That’s sensible. Seems like the Gemfile.lock takes care of collaboration too, as you mentioned previously. Thanks!


(rubylove.io) #6

Simply… YES. Lock it down to a minor and let the bugfixes roll in by (one at a time) editing the locked version (in the lock) by bumping it one bugfix or two, then bundle, and that is the only gem that updates and it updates to what you want?