Skip to content

Instantly share code, notes, and snippets.

Created November 26, 2016 16:34
Show Gist options
  • Save anonymous/2d9383c0da536d7006e56bd787f97e7d to your computer and use it in GitHub Desktop.
Save anonymous/2d9383c0da536d7006e56bd787f97e7d to your computer and use it in GitHub Desktop.

Bundler can't find Nokogiri

My Rails app requires Nokogiri which won't install unless I do gem install nokogiri -- --use-system-libraries manually. But why can't Bundler find it?

I tried bundle config build.nokogiri --use-system-libraries and bundle config disable_shared_gems false to no avail.

Note that pkg-config is already installed:

% gem_home .

% gem install nokogiri -v '1.6.8.1' -- --use-system-libraries
Building native extensions with: '--use-system-libraries'
This could take a while...
Successfully installed nokogiri-1.6.8.1
Parsing documentation for nokogiri-1.6.8.1
Done installing documentation for nokogiri after 3 seconds
1 gem installed

% bundle install
[...]
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/home/www/myapp/vendor/bundle/ruby/2.3/gems/nokogiri-1.6.8.1/ext/nokogiri
/usr/local/bin/ruby23 -r ./siteconf20161126-23221-laf0qg.rb extconf.rb
--use-system-libraries
checking if the C compiler accepts ... yes
Building nokogiri using system libraries.
pkg-config could not be used to find libxml-2.0
Please install either `pkg-config` or the pkg-config gem per

    gem install pkg-config -v "~> 1.1.7"

pkg-config could not be used to find libxslt
Please install either `pkg-config` or the pkg-config gem per

    gem install pkg-config -v "~> 1.1.7"

pkg-config could not be used to find libexslt
Please install either `pkg-config` or the pkg-config gem per

    gem install pkg-config -v "~> 1.1.7"

ERROR: cannot discover where libxml2 is located on your system. please make sure
`pkg-config` is installed.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/local/bin/$(RUBY_BASE_NAME)23
        --help
        --clean
        --use-system-libraries
        --with-zlib-dir
        --without-zlib-dir
        --with-zlib-include
        --without-zlib-include=${zlib-dir}/include
        --with-zlib-lib
        --without-zlib-lib=${zlib-dir}/lib
        --with-xml2-dir
        --without-xml2-dir
        --with-xml2-include
        --without-xml2-include=${xml2-dir}/include
        --with-xml2-lib
        --without-xml2-lib=${xml2-dir}/lib
        --with-libxml-2.0-config
        --without-libxml-2.0-config
        --with-pkg-config
        --without-pkg-config
        --with-xslt-dir
        --without-xslt-dir
        --with-xslt-include
        --without-xslt-include=${xslt-dir}/include
        --with-xslt-lib
        --without-xslt-lib=${xslt-dir}/lib
        --with-libxslt-config
        --without-libxslt-config
        --with-exslt-dir
        --without-exslt-dir
        --with-exslt-include
        --without-exslt-include=${exslt-dir}/include
        --with-exslt-lib
        --without-exslt-lib=${exslt-dir}/lib
        --with-libexslt-config
        --without-libexslt-config

To see why this extension failed to compile, please check the mkmf.log which can
be found here:

/home/www/myapp/vendor/bundle/ruby/2.3/extensions/x86_64-openbsd/2.3/nokogiri-1.6.8.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
/home/www/myapp/vendor/bundle/ruby/2.3/gems/nokogiri-1.6.8.1 for inspection.
Results logged to
/home/www/myapp/vendor/bundle/ruby/2.3/extensions/x86_64-openbsd/2.3/nokogiri-1.6.8.1/gem_make.out

An error occurred while installing nokogiri (1.6.8.1), and Bundler
cannot continue.
Make sure that `gem install nokogiri -v '1.6.8.1'` succeeds before bundling.

Also:

% gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.5.1
  - RUBY VERSION: 2.3.1 (2016-04-26 patchlevel 112) [x86_64-openbsd]
  - INSTALLATION DIRECTORY: /home/www/myapp/.gem/ruby/2.3.1
  - USER INSTALLATION DIRECTORY: /home/www/myapp/.gem/ruby/2.3
  - RUBY EXECUTABLE: /usr/local/bin/ruby23
  - EXECUTABLE DIRECTORY: /home/www/myapp/.gem/ruby/2.3.1/bin
  - SPEC CACHE DIRECTORY: /home/www/myapp/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-openbsd
  - GEM PATHS:
     - /home/www/myapp/.gem/ruby/2.3.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /home/www/myapp/.gem/ruby/2.3.1/bin
     - /home/www/myapp//bin
     - /bin
     - /sbin
     - /usr/bin
     - /usr/sbin
     - /usr/local/bin
     - /usr/local/sbin

% bundle env
Environment

    Bundler   1.13.6
    Rubygems  2.5.1
    Ruby      2.3.1p112 (2016-04-26 revision 54768) [x86_64-openbsd]
    GEM_HOME  /home/www/myapp/.gem/ruby/2.3.1
    Git       2.9.0

Bundler settings

    path
      Set for your local app (/home/www/myapp/.bundle/config): "vendor/bundle"
      Set for the current user (/home/www/myapp/.bundle/config): "vendor/bundle"
    disable_shared_gems
      Set for your local app (/home/www/myapp/.bundle/config): "true"
      Set for the current user (/home/www/myapp/.bundle/config): "true"
    build.nokogiri
      Set for your local app (/home/www/myapp/.bundle/config): "--with-xml2-dir=/usr/local/lib/"
      Set for the current user (/home/www/myapp/.bundle/config): "--with-xml2-dir=/usr/local/lib/"
    gemfile
      Set via BUNDLE_GEMFILE: "/home/www/myapp/Gemfile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment