Home > Enterprise >  Why bundler doesn't use system gems?
Why bundler doesn't use system gems?

Time:11-11

Bundler version: 1.15.1. Ruby version: 2.3.1. I have (from gem env):

  - GEM PATHS:
     - /var/lib/gems/2.3.0
     - /root/.gem/ruby/2.3.0
     - /usr/lib/x86_64-linux-gnu/rubygems-integration/2.3.0
     - /usr/share/rubygems-integration/2.3.0
     - /usr/share/rubygems-integration/all

With all the gems from Gemfile.lock present under /var/lib/gems/2.3.0. But bundler will not try to re-use these and instead will attempt to redownload every time.

My .bundle/config:

    ---
    BUNDLE_PATH: "vendor/bundle"
    BUNDLE_BIN: "vendor/bin"
    BUNDLE_DISABLE_SHARED_GEMS: "true" <--- removing this config entry doesn't help

running bundle install just re-downloads the gems instead of saying 'Using' so takes a long time.

What are the settings that might cause this and how to make the bundler get gems from system path /var/lib/gems/2.3.0?

I have read the bundle and bundle install docs fully but can't see how I can make bundler use the system gems. Other than using source 'file:///var/lib/gems/2.3.0' after generating an index, but I would really like to avoid this and use a more elegant solution. Especially since it would probably cause the gems to be re-installed which takes even more time than re-download.

CodePudding user response:

You have set BUNDLE_DISABLE_SHARED_GEMS to true. This setting instructs bundler to specifically ignore any system-installed gems. Instead, bundler downloads all required gems into your BUNDLE_PATH.

If you want to use system-installed gems if appropriate, remove the BUNDLE_DISABLE_SHARED_GEMS setting from your bundle config.

  • Related