Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bundler installing gem that's already installed

I believe I'm misunderstanding the way bundler works, but from the bundle install documentation it seems to indicate bundler will use locally installed system gems.

...

--system: Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application

...

The --system option is the default. Pass it to switch back after using the --path option as described below.

I'm not using rbenv/rvm or any other Ruby version manager. I'm using ChefDK as my primary development environment, which ships with Ruby and a bunch of preinstalled gems.

The full contents of the Gemfile, there is no Gemfile.lock yet.

source 'https://rubygems.org'

gem 'nokogiri', '1.6.3.1'

Local nokogiri installed

$ gem list --local | grep nokogiri
nokogiri (1.6.6.2, 1.6.3.1, 1.5.5)

System Gem location has nokogiri 1.6.3.1 installed

$ echo $GEM_HOME
/Users/arthur/.chefdk/gem/ruby/2.1.0
$ find /Users/arthur/.chefdk/gem/ruby/2.1.0 | grep nokogiri | grep 1.6.3.1
/Users/arthur/.chefdk/gem/ruby/2.1.0/cache/nokogiri-1.6.3.1.gem
/Users/arthur/.chefdk/gem/ruby/2.1.0/extensions/x86_64-darwin-12/2.1.0/nokogiri-1.6.3.1
/Users/arthur/.chefdk/gem/ruby/2.1.0/extensions/x86_64-darwin-12/2.1.0/nokogiri-1.6.3.1/mkmf.log
/Users/arthur/.chefdk/gem/ruby/2.1.0/gems/nokogiri-1.6.3.1
/Users/arthur/.chefdk/gem/ruby/2.1.0/gems/nokogiri-1.6.3.1/.autotest
/Users/arthur/.chefdk/gem/ruby/2.1.0/gems/nokogiri-1.6.3.1/.editorconfig
...

However, when I run a bundle install, it tries to install and compile libxml2 for nokogiri.

$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Using mini_portile 0.6.0
Building nokogiri using packaged libraries.
Building libxml2-2.8.0 for nokogiri with the following patches applied:
  - 0001-Fix-parser-local-buffers-size-problems.patch
  - 0002-Fix-entities-local-buffers-size-problems.patch
  - 0003-Fix-an-error-in-previous-commit.patch
  - 0004-Fix-potential-out-of-bound-access.patch
  - 0005-Detect-excessive-entities-expansion-upon-replacement.patch
  - 0006-Do-not-fetch-external-parsed-entities.patch
  - 0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch
  - 0008-Improve-handling-of-xmlStopParser.patch
  - 0009-Fix-a-couple-of-return-without-value.patch
  - 0010-Keep-non-significant-blanks-node-in-HTML-parser.patch
  - 0011-Do-not-fetch-external-parameter-entities.patch
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxml2.
...

What am I missing? How can I force bundler to use the already installed nokogiri 1.6.3.1 (that ships with ChefDK)? I'm trying to avoid having nokogiri compile libxml2 because that fails consistently on many different developer/operations workstations and has caused no end of grief. Thanks.

Edit

Thanks to Tim Moore, using bundle env I noticed in the output that bundler had shared gems disabled.

$ bundle env
Bundler 1.7.12
Ruby 2.1.4 (2014-10-27 patchlevel 265) [x86_64-darwin12.0]
Rubygems 2.4.4
GEM_HOME /Users/arthur/.chefdk/gem/ruby/2.1.0
GEM_PATH /Users/arthur/.chefdk/gem/ruby/2.1.0:/opt/chefdk/embedded/lib/ruby/gems/2.1.0

Bundler settings
  disable_shared_gems
    Set for the current user (/Users/arthur/.bundle/config): "1"


Gemfile
source 'https://rubygems.org'
...

Looking at the ~/.bundle/config, sure enough the global config was set.

---
BUNDLE_DISABLE_SHARED_GEMS: '1'

Once removed, Bundler resolves nokogiri 1.6.3.1 correctly and doesn't try reinstalling it. This setting should not be there by default, by default bundler installs with --system. I must have set this setting many months back and forgot I did.

like image 330
Arthur Maltson Avatar asked Oct 17 '25 15:10

Arthur Maltson


1 Answers

Try running bundle env to verify that the install location is what you expect.

If not, check whether there is a .bundle/config or ~/.bundle/config file overriding the install path. The output of bundle env will tell you what configuration it is using and how it was determined (i.e., which file it was in or whether it was picked up from an environment variable).

like image 68
Tim Moore Avatar answered Oct 19 '25 12:10

Tim Moore



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!