4

Background: Not the Question

I have a project that is running in both development and production in a chruby environment, where ruby-install was installed as root and rubies are stored in /opt/rubies. I have a really hard time (as many people do) getting nokogiri to compile its native extensions as part of a bundle, but it compiles fine as any chruby user outside of the project directory and so long as there are no binstubs. That's just background context; it's not really what my question is about.

My Current Hack

I find that when I have committed binstubs to my project, all kinds of badness happens. So far, my best solution seems to be:

# skip any bundled/binstub version of bundler
rm -rf ./bin
`which bundle` install --binstubs --without="development test"

which seems to work just fine. Nokogiri is apparently not a production dependency (yay!) and the ./bin directory gets trimmed down to just the gems needed for production.

Question: Would the Bundler Deployment Flag Fix Anything?

So, here's the question: What's the difference between what I'm doing here, and bundle install --deploy with or without binstubs? I know it points to vendor/bundle instead of bin by default, but the docs don't really explain the pros and cons of this approach (at least not in a way that I'm understanding).

Aside from knowledge, which is valuable for its own sake, I'd really like to vendor in production gems in a way that it's likely to work across systems (e.g. RHEL6 and RHEL7) without having to rebuild native extensions or strip out development/test gems on production machines.

Is the deployment flag the answer? Or is there a better way to vendor gems with native extensions for cross-distro projects?

Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199
  • 1
    `--deployment` option has common neither with `--binstubs`, nor with `--without` ones. Its behavior is exactly described in https://bundler.io/man/bundle-install.1.html#DEPLOYMENT-MODE – Pavel Mikhailyuk Mar 18 '19 at 11:46
  • 1
    There is one insignificant moment about output color: https://github.com/bundler/bundler/blob/master/lib/bundler/cli/install.rb#L19 – Pavel Mikhailyuk Mar 18 '19 at 11:48

0 Answers0