2

I am developing with bundler under Windows and am wondering how to create the Gemfile.lock for my production environment.

What seems missing are the gems for other platforms. Running bundle install on

group :production do  
  gem 'mysql2'
end

on Windows creates a Gemfile.lock

mysql2 (0.3.18-x86-mingw32)

When deploying to a Linux environment this is obviously not correct, I would need the Gemfile.lock to also contain the correct result for Linux. I can run bundle install on Linux and learn that indeed

mysql2 (0.3.18)

is the correct gem for Linux. I then manually update the Gemfile.lock in the repository to contain both:

mysql2 (0.3.18)
mysql2 (0.3.18-x86-mingw32)

This works clean under both platforms, but it seems a kludge.

How can I tell bundle to resolve the Gemfile.lock for another platform other than the local one? I guess I need something like bundle install --all-platforms. What am I missing?

Christopher Oezbek
  • 23,994
  • 6
  • 61
  • 85
  • possible duplicate of [Make bundler use different gems for different platforms](http://stackoverflow.com/questions/3642085/make-bundler-use-different-gems-for-different-platforms) – tgf Aug 11 '15 at 22:37
  • The question is a little bit different, because I do not care to specify different gems for different platforms, but different Gemfile.lock specs. In particular I think it is against what the `Gemfile` should be, that I would have to pin down mysql to 0.3.18 in the `Gemfile` if I really don't care. – Christopher Oezbek Aug 11 '15 at 22:41

2 Answers2

2

Running the following commands will fix your issue.

bundle lock --add-platform x86_64-linux
bundle install
git add . ; git commit -m fix

Reference

  1. https://www.moncefbelyamani.com/understanding-the-gemfile-lock-file/#platforms

  2. https://bundler.io/man/gemfile.5.html#PLATFORMS

  3. https://github.com/rubygems/rubygems/issues/4269#issuecomment-758564690

Ryan Lyu
  • 4,180
  • 5
  • 35
  • 51
1

It would appear this is a known shortcoming in bundler and the workaround seems to be to run bundle pack on every platform you need to use.

hd1
  • 33,938
  • 5
  • 80
  • 91
  • The discussion in the links is a little bit about packaging (and for packaging there is actually a solution with --all-platforms). How about resolution? Can I run bundler to resolve dependencies for a platform without installation? – Christopher Oezbek Aug 11 '15 at 22:43
  • Generally, deployment is done on a similar platform to development, so I'd just watch the issues I linked to for a solution. – hd1 Aug 11 '15 at 22:57