How to Add MAC-Specific Gems to Bundle on MAC But Not on Linux

How to add Mac-specific gems to bundle on Mac but not on Linux?

Gemfile actually is a regular ruby file, so you can use something like

case RUBY_PLATFORM
when /darwin/
gem 'foo'
when /win32/
gem 'bar'
end

Rails: Handling different gem versions for different operating systems

If anyone running into this. This was a known bug that was fixed in bundler version v2.2.11

From: How to change the version of bundler used in Cloud Functions deployment?

This is bundler's regression since bundler v2.2.8. https://github.com/rubygems/rubygems/issues/4366

Fix is here: https://github.com/rubygems/rubygems/pull/3655

How to clone a gem, fix it, add it to repo, bundle, and deploy with Rails

Steps

  1. Fork the project under your account on Github

  2. Make the changes you want

  3. Use gem 'gem_name', git: 'your_forked_project', branch: 'the_branch_you_working_on'

  4. Run bundle install

Bundler and Heroku with offline gems

Ok I figured out the issue. The Chilkat gem I'm using has OS-specific versions, and the version I unbundled in vendor/gems is for OSx won't work on Heroku/AWS. So even if the path would have worked correctly in Heroku, the gem itself would not.

The problem I face now is because the Chilkat gem is OS-specific, Bundler will generate a Gemfile.lock file specific to the OS on which bundle install was called (OSx in my case). That OSx-specific Gemfile.lock is incompatible with AWS's machines, so Heroku complains that I can't push the code since the Gemfile.lock is inconsistent with what is expected.

This appears to be a known issue with Bundler (How to add Mac-specific gems to bundle on Mac but not on Linux?). I could just avoid committing Gemfile.lock, but we rely on the version dependency management that Gemfile.lock provides. And I don't want to get all the developers on my team to switch to developing on Linux/Unix. Anyway that's a separate issue so I'm closing this for now. Thanks to the people who commented!



Related Topics



Leave a reply



Submit