Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: Error installing libxml-ruby: ERROR: Failed to build gem native extension #315

Closed
DavidIValencia opened this issue Jul 21, 2017 · 19 comments

Comments

@DavidIValencia
Copy link

@DavidIValencia DavidIValencia commented Jul 21, 2017

Error installing version 5.0.0. ruby version '2.3.1' using rvm

→ gem install libxml-ruby -v '3.0.0'
Building native extensions. This could take a while...
ERROR: Error installing libxml-ruby:
ERROR: Failed to build gem native extension.

current directory: /Users/David/.rvm/gems/ruby-2.3.1/gems/libxml-ruby-3.0.0/ext/libxml

/Users/David/.rvm/rubies/ruby-2.3.1/bin/ruby -r ./siteconf20170721-35283-1f8lwpv.rb extconf.rb
checking for libxml/xmlversion.h in /opt/include/libxml2,/opt/local/include/libxml2,/usr/local/include/libxml2,/usr/include/libxml2... no
*** 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
--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=/Users/David/.rvm/rubies/ruby-2.3.1/bin/$(RUBY_BASE_NAME)
--with-xml2-config
--without-xml2-config
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
extconf failure: need libxml2.

Install the library or try one of the following options to extconf.rb:

  --with-xml2-config=/path/to/xml2-config
  --with-xml2-dir=/path/to/libxml2
  --with-xml2-lib=/path/to/libxml2/lib
  --with-xml2-include=/path/to/libxml2/include

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

/Users/David/.rvm/gems/ruby-2.3.1/extensions/x86_64-darwin-15/2.3.0/libxml-ruby-3.0.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/David/.rvm/gems/ruby-2.3.1/gems/libxml-ruby-3.0.0 for inspection.
Results logged to /Users/David/.rvm/gems/ruby-2.3.1/extensions/x86_64-darwin-15/2.3.0/libxml-ruby-3.0.0/gem_make.out

@mlund01

This comment has been minimized.

Copy link

@mlund01 mlund01 commented Jul 22, 2017

I also ran into this issue when upgrading from 4.11.1 to 5.0.0. Looks like v5 depends on libxml3, while Nokogiri depends on libxml2. The way to fix it is by installing libxml2 onto your system (NOT as a gem... I tried this and failed).

I added this (in my Dockerfile),

sudo apt-get install libxslt-dev libxml2-dev

before installing the gems. But what you need will depend on what system you are running on. Here is where I found the answer and should also have the details on how to fix for other systems,

https://stackoverflow.com/a/7811458/3789073

And also the guide for installing Nokogiri correctly for different systems...

http://www.nokogiri.org/tutorials/installing_nokogiri.html

@ilanbiala

This comment has been minimized.

Copy link
Contributor

@ilanbiala ilanbiala commented Jul 22, 2017

Also take a look at https://stackoverflow.com/questions/38129330/libxml-ruby-failed-to-build-gem-native-extension, which seems to have a reasonable solution similar to @mlund01's.

@KaraAJC

This comment has been minimized.

Copy link

@KaraAJC KaraAJC commented Jul 26, 2017

I just helped a student of mine with this issue as well, and we found the following closed issues in libXML-ruby repo to be helpful (depending on your configuration):

@ilanbiala

This comment has been minimized.

Copy link
Contributor

@ilanbiala ilanbiala commented Jul 26, 2017

@DavidIValencia @mlund01 can this be closed?

@DavidIValencia

This comment has been minimized.

Copy link
Author

@DavidIValencia DavidIValencia commented Jul 26, 2017

@ilanbiala really up to you. I honestly think that gems should work out of the box, especially if they conflict with super popular dependencies such as nokogiri. Yes, I can totally get this working on my own machine, but it's a much tougher sell to reconfigure production just so that I can use the most current version of the gem.

As of now, I am using 4.xx of this gem so I feel confident about adding it to my production environment. Feel free to close the bug though if my feelings don't align with the goals of your team.

@mlund01

This comment has been minimized.

Copy link

@mlund01 mlund01 commented Jul 27, 2017

@ilanbiala I think this should be further discussed as to how it should be dealt with. I think given the ubiquity of Nokogiri, you should either be very clear in the documentation about how to fix the issue, or if possible, use the same version of lib-xml. My thought is just to provide more clear documentation, because I'd rather not use an older version if I don't have to, and it was a pretty easy fix.

@justjoehere

This comment has been minimized.

Copy link

@justjoehere justjoehere commented Aug 9, 2017

I have the same problems installing this gem on windows, but I don't know what the "simple fix" is. Any ideas?

@teeparham

This comment has been minimized.

Copy link

@teeparham teeparham commented Aug 14, 2017

How much trouble would it be to remove the libxml-ruby dependency?

malmckay added a commit to malmckay/twilio-ruby that referenced this issue Aug 18, 2017
twilio-ruby works with either libxml version 2 or 3.
libxml2 is common enough in other gems that allowing it here will reduce gem conflicts
@efossier efossier closed this in 9cf88af Aug 25, 2017
jingming added a commit that referenced this issue Aug 30, 2017
twilio-ruby works with either libxml version 2 or 3.
libxml2 is common enough in other gems that allowing it here will reduce gem conflicts
tmconnors added a commit that referenced this issue Sep 1, 2017
* Autogenerate TwiML classes

* [Librarian] Regenerated @ 3c4f9f6ab80f12da0cc09d5153809cffad5eca23

* Add DeployedDevices

* Release 5.1.2

* Client records the last response (#331)

* Client records the last response

* Twilio::Request class to wrap requests

erronenous file

* Adding lint back

* rubocop failures

* fixing test case

* Faraday connetion error and 5XX tests for last_response and last_request

* Additional verification

* linting

* explicit nil for last_response, handle situation were penultimate request succeeded but last failed

* remove body

* removed errorenous line

* Allow libxml 2 or 3 [Fixes #315] (#330)

twilio-ruby works with either libxml version 2 or 3.
libxml2 is common enough in other gems that allowing it here will reduce gem conflicts

* [Librarian] Regenerated @ 4b299c041980aa815254cd2ba767e17f2bf4465e

* update changelog

* Release 5.2.0

* Better spacing
@anhari

This comment has been minimized.

Copy link

@anhari anhari commented Nov 16, 2017

For anyone on macOS that runs into this, I was able to fix it with:

brew install libxml2
brew link --force libxml2
bundle install
@philnash

This comment has been minimized.

Copy link
Contributor

@philnash philnash commented Nov 17, 2017

For anyone who has suffered with this, I apologise. There is a fix on the horizon though, XML generation is moving to Nokogiri with this PR. Keep an eye on it, upgrade when the time comes and never worry about libxml-ruby again!

@teeparham

This comment has been minimized.

Copy link

@teeparham teeparham commented Nov 17, 2017

Fun fact: nokogiri includes a modified version of libxml2 and libxslt, but also allows you to use a system libxml if you choose to fight that battle yourself. In any case, nokogiri does a good job of dealing with the dependency so it works on just about any platform. So the libxml dependency isn't really going away, but #375 is a better solution. 👍

https://github.com/sparklemotion/nokogiri/#requirements

@reynard225

This comment has been minimized.

Copy link

@reynard225 reynard225 commented Oct 23, 2018

I also ran into this issue when upgrading from 4.11.1 to 5.0.0. Looks like v5 depends on libxml3, while Nokogiri depends on libxml2. The way to fix it is by installing libxml2 onto your system (NOT as a gem... I tried this and failed).

I added this (in my Dockerfile),

sudo apt-get install libxslt-dev libxml2-dev

before installing the gems. But what you need will depend on what system you are running on. Here is where I found the answer and should also have the details on how to fix for other systems,

https://stackoverflow.com/a/7811458/3789073

And also the guide for installing Nokogiri correctly for different systems...

http://www.nokogiri.org/tutorials/installing_nokogiri.html

safe my time thanks a lot

@Korayem

This comment has been minimized.

Copy link

@Korayem Korayem commented Jan 12, 2019

I solved this by running

gem install libxml-ruby -v '3.0.0' -- --with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config --with-xml2-dir=/usr/local/opt/libxml2 --with-xml2-lib=/usr/local/opt/libxml2/lib --with-xml2-include=/usr/local/opt/libxml2/include
@shaunmckinnonmint

This comment has been minimized.

Copy link

@shaunmckinnonmint shaunmckinnonmint commented Jan 17, 2019

I also ran into this issue when upgrading from 4.11.1 to 5.0.0. Looks like v5 depends on libxml3, while Nokogiri depends on libxml2. The way to fix it is by installing libxml2 onto your system (NOT as a gem... I tried this and failed).

I added this (in my Dockerfile),

sudo apt-get install libxslt-dev libxml2-dev

before installing the gems. But what you need will depend on what system you are running on. Here is where I found the answer and should also have the details on how to fix for other systems,

https://stackoverflow.com/a/7811458/3789073

And also the guide for installing Nokogiri correctly for different systems...

http://www.nokogiri.org/tutorials/installing_nokogiri.html

@tsai-jimmy

This comment has been minimized.

Copy link

@tsai-jimmy tsai-jimmy commented Mar 1, 2019

Help me a lot ,thanks @Korayem
It's solved now.

I used this command before:
gem install libxml-ruby -v '3.0.0' --source 'https://rubygems.org/'

and the following message response to me. It is as same as your solution.
image

@philnash

This comment has been minimized.

Copy link
Contributor

@philnash philnash commented Mar 5, 2019

Hey everyone,

The latest versions of twilio-ruby use Nokogiri for XML generation so you should no longer have to worry about libxml3 and libxml-ruby. If you are having a problem with libxml3 and this library, please open a new issue as something very wrong is going on.

@CodingMarkus

This comment has been minimized.

Copy link

@CodingMarkus CodingMarkus commented Mar 6, 2019

libxml2 is present on macOS by default (and always has been) but the headers are in libxml2/libxml/* and not in libxml/*. The configure code looks like this

#include <libxml/xmlversion.h>

but it should be looking like this

#include <libxml2/libxml/xmlversion.h>

then everything would work.

Running brew install libxml2 is just installing a 2nd copy of libxml2 in a different location and is not really meaningful.

The following will work on macOS systems with Xcode installed:

gem install libxml-ruby -v '3.1.0' -- --with-xml2-include=`xcrun --show-sdk-path`/usr/include/libxml2
@raldred

This comment has been minimized.

Copy link

@raldred raldred commented Mar 25, 2019

To expand on @CodingMarkus's comment.
You can configure bundler to remember this going forward should you reinstall your ruby version or add other ruby versions via RVM or rbenv.

bundle config build.libxml-ruby --with-xml2-include=`xcrun --show-sdk-path`/usr/include/libxml2

You won't need to gem install manually

@guilleiguaran

This comment has been minimized.

Copy link

@guilleiguaran guilleiguaran commented May 17, 2019

I've installed libxml2 with Homebrew so in my case this does the trick:

bundle config --global build.libxml-ruby --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.