Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should Gemfile.lock be committed to source control on Windows?

Ruby newb here.

I download ruby via rubyinstaller, did gem install rails, resolved a few missing libraries, and finally forked the ruby project I want to work on.

Before touching anything, I see that my Gemfile.lock is modified:

diff --git a/Gemfile.lock b/Gemfile.lock
index aefda68..9ebccba 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -46,6 +46,7 @@ GEM
     diff-lcs (1.1.3)
     erubis (2.7.0)
     eventmachine (1.0.0)
+    eventmachine (1.0.0-x86-mingw32)
     execjs (1.4.0)
       multi_json (~> 1.0)
     hike (1.2.1)
@@ -65,11 +66,17 @@ GEM
     multi_json (1.3.6)
     multi_xml (0.2.2)
     pg (0.14.1)
+    pg (0.14.1-x86-mingw32)
     polyglot (0.3.3)

...

 PLATFORMS
   ruby
+  x86-mingw32

All the modified lines seem to be Windows related. This answer seems to indicate that I should not gitignore Gemfile.lock (it's already committed to the repo I cloned anyway). This answer implies I might get errors if I do commit & push it to heroku (makes sense, since I don't want my app to depend on Windows-specific files).

So, which is it? How should I fix it? Should I delete Gemfile.lock from my repo?

like image 517
ripper234 Avatar asked Dec 25 '12 22:12

ripper234


1 Answers

Last time I pushed to Heroku with a Windows Gemfile.lock it handled it pretty gracefully. I don't remember if it failed and rebuilt the Gemfile.lock or just stripped the binary gem tags.

There are 2 viable options I see.
One is to assume that there isn't going to be a problem with this behavior. Which means using strict gem version requirements or updating your bundle and confirming everything works before you push.

Another is to use the :platform flag in your Gemfile. I won't recommend this, but it should force the source down and compile the gem locally. Which means any external dependencies need to be available. With a lot of binary gems (like the pg gem) this isn't an easy task. With some other gems it can be nearly impossible. Once again, I would not recommend doing this.

like image 52
Azolo Avatar answered Oct 12 '22 23:10

Azolo