by

Possible workaround for installing nokogiri 1.6.8 on OSX with brewed libxml2 2.9.4

Possible workaround for installing nokogiri 1.6.8 on OSX with brewed libxml2 2.9.4: 
workaround.md
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/1324749/Possible-workaround-for-installing-nokog?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
Problem: The following commands fail on OSX: gem install nokogiri gem install nokogiri -- --use-system-libraries gem install nokogiri -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-xml2-dir=/usr/local/opt/libxml2 Version: libxml2: 2.9.4 (installed via homebrew 0.9.9) libxslt: 1.1.28 nokogiri: 1.6.8 If you tried the last command mentioned above, and the following error message, then this guide might solve your problem: ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed. The problem I noticed is that the `xmlversion.h` header file won't be discovered by `extconf.rb` script because the inferred path of the `include` directory by nokogiri is `/usr/local/opt/libxml2/include`. But in the libxml2 `2.9.4` version, the path to the header file is `/usr/local/opt/libxml2/include/libxml2/xmlversion.h`. Specifying the `include` and `lib` paths explicitly solves the problem: gem install nokogiri -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-xml2-include=/usr/local/opt/libxml2/include/libxml2 --with-xml2-lib=/usr/local/opt/libxml2/lib I'm not sure if this even a bug, either in functionality or documentation.
If you want to be updated about similar snippets, Sign in and follow our Channels