You have modified your Gemfile in development

Première publication : 2011-03-18

Twice this week I’ve had a problem with Bundler (1.0.10).

During a deploy with Capistrano, I had some errors like this :

You have modified your Gemfile in development but did not check
the resulting snapshot (Gemfile.lock) into version control

You have added to the Gemfile:
* roxml (~> 3.1, < 3.1.6)

You have deleted from the Gemfile:
* roxml (< 3.1.6, ~> 3.1)

I’ve searched in Google for this kind of errors, and everything I’ve found was dealing with .bundle directories, ignoring and tracking again the Gemfil.lock… but nothing worked for me.

It was stupid of me not to follow some basic rules : what does the message tell? It’s telling that there is a difference between 2 versions. OK, but then there are the differences. It seems to be a matter of order in the version parameters.

All the gems in the Gemfile with none or only one version constraint were OK, and every one with two or more were listed in this error message.

The answer is really straightforward : let’s inverse the constraints, the < before the ~>. And it works!

Now I have the solution but not the explanation. I don’t have any idea why suddenly Bundler was picky like this. I didn’t even update it.

Update (quoting Andre Arko, maintainer of Bundler) :

This is an issue with Rubygems, which started calling .sort on the requirements list as of Rubygems 1.6 and higher. I’ve worked around it (just yesterday), and the fix will be in the next release of Bundler 1.0.x.