Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pretend other platform for `bundle install`

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?

like image 934
Christopher Oezbek Avatar asked Sep 05 '25 03:09

Christopher Oezbek


1 Answers

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

like image 58
Ryan Lyu Avatar answered Sep 07 '25 19:09

Ryan Lyu