make error when installing nokogiri gem using rvm on ruby-1.8.7-p334 [ x86_64 ] - ruby-on-rails

When I try to install nokogiri gem on ruby-1.8.7-p334 [ x86_64 ] on Mac OS X 10.6, I get the following error:
sudo gem install nokogiri
/Users/patelc75/.rvm/rubies/ruby-1.8.7-p334/bin/gem:4: warning: Insecure world writable dir /Users in PATH, mode 040777
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/patelc75/.rvm/rubies/ruby-1.8.7-p334/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
-----
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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.

Before installing nokogiri gem, you need to get libraries installed.
Here are the steps to do it with homebrew
# the rest of this snippet assumes installation of libxml 2.7.7. YMMV.
brew install libxml2
brew link libxml2
# install libxslt from source
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
tar -zxvf libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure --prefix=/usr/local/Cellar/libxslt/1.1.26 \
--with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.7
make
sudo make install
gem install nokogiri -- --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26
With macports
sudo port install libxml2 libxslt
sudo gem install nokogiri
More information here http://nokogiri.org/tutorials/installing_nokogiri.html

I tries all kinds of solutions I can found, including:
. use brew to install libxslt / libxml2 / libiconv
. tries to gem install with various --with-configurations
sadly, they all didn't work for me, until I uninstalled MacPort and all installed ports.
Then simply executed command gem install nokogiri, the gem and rdoc got installed like a breeze.
I don't understand the very details of why, but according to my own experiences of using MacPort (resulted in multiple sets of ruby/rake/gem(s) installed) and articles comparing brew and port, I will not go back to port.

Related

Problems with libxml2 when installing Ruby on Rails on OSX Mavericks

I'm having a problem installing Ruby on Rails in my terminal.
Has anyone else encountered the following error in the terminal:
checking for main() in -llzma... yes
checking for xmlParseDoc() in libxml/parser.h... no
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
-----
libxml2 is missing. Please locate mkmf.log to investigate how it is failing.
-----
*** 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.
I'm using the standard bash:
$ gem install rails
How would I go about fixing this? I've tried a few things here on stack exchange but nothing so far has worked...
Using $ brew list in the terminal yields:
Michaels-iMac:~ iMacHome$ brew list
autoconf libksba libxslt pkg-config
automake libtool libyaml readline
libgpg-error libxml2 openssl
Michaels-iMac:~ iMacHome$
It seems to be there...
assuming you have Xcode installed try this
gem install rails -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.‌platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2 --use-system-libraries
The problem could be your RVM.
Try either this command:
rvm cleanup all
rvm pkg uninstall libxml2
rvm reinstall all --force
or upgrade/reinstall to the latest RVM installation.
--
To properly install the rails gem globally for a Ruby version:
rvm use <rubyversion>
gem install rails
example to use rails on ruby 2.1.5:
rvm use 2.1.5
gem install rails

How to install Nokogiri on CentOS when "sudo gem install nokogiri" works fine

I am trying to set up a Rails project on CentOS (Amazon Linux) and the bundle install fails while installing Nokogiri with the following error:
/usr/bin/ruby2.0 extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... no
-----
libxslt is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
I verified I have the libxslt yum package.
sudo gem install nokogiri works fine, but I don't want to do sudo gem install. Any ideas what I am missing here?

Failed to gem install nokogiri in Fedora16

I'm running Ruby 1.9.3p194 & Rails 3.2.9 in Fedora 16.
When I gem install nokogiri, it fails with error message:
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/home/chelseaw/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... no
checking for libiconv_open() in -liconv... no
-----
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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.
I've googled around for quite a while but only found some solutions for MacOS. I've no idea what to do, please help.
Edit 1
The results of yum search iconv:
mingw32-iconv-debuginfo.noarch : Debug information for package mingw32-iconv
mingw32-iconv-static.noarch : Static version of the MinGW Windows Iconv library
mingw32-win-iconv.noarch : MinGW Windows Iconv library
mingw32-win-iconv-debuginfo.noarch : Debug information for package
: mingw-win-iconv
mingw32-win-iconv-static.noarch : Static version of the MinGW Windows Iconv
: library
perl-Text-Iconv.i686 : Perl interface to iconv() codeset conversion function
perl-Text-Iconv-debuginfo.i686 : Debug information for package perl-Text-Iconv
psiconv-debuginfo.i686 : Debug information for package psiconv
psiconv-devel.i686 : Development files for psiconv
uniconvertor-debuginfo.i686 : Debug information for package uniconvertor
mingw32-iconv.noarch : GNU libraries and utilities for character set conversion
perl-HTML-WikiConverter.noarch : Perl module to convert HTML to wiki markup
perl-HTML-WikiConverter-Markdown.noarch : Convert HTML to Markdown markup
psiconv.i686 : A conversion utility for Psion files
uniconvertor.i686 : Universal vector graphics translator
Finally got it work, here are the steps:
Download libiconv
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.11.tar.gz
Extract files tar -xvzf libiconv-1.11.tar.gz
Enter the directory cd libiconv-1.11
Configure libiconv Library ./configure --prefix=/usr/local/libiconv
Compile libiconv make CFLAGS="-O2 -fno-tree-dce -fno-optimize-sibling-calls" (I have to add CFLAGS to make the compiling work.)
Install libiconv sudo make install
Install nokogiri
CFLAGS="-O2 -fno-tree-dce -fno-optimize-sibling-calls" gem install nokogiri -- --with-iconv-dir=/usr/local/libiconv --with-iconv-lib=/usr/local/libiconv/lib --with-iconv-include=/usr/local/libiconv/include
Voila, it shows the success message!
No need to compile it yourself, try running this command:
sudo yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel
Or:
rvm get head && rvm requirements run force
Try:
yum install -y iconv-devel
and then:
gem install nokogiri
Error message indicates libiconv is missing. Did you install it? you may need to install libiconv and libiconv-devel packages.

Install a specific gem version with configuration options

I'm trying to install an old version of nokogiri, but I am having trouble specifying the format:
I'm using
gem install nokogiri -v 1.5.2 -- --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
but this is not the correct syntax. Do you know how to do this?
ERROR
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/boris/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
-----
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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:
You’ve only specified the lib dir to use, try specifying the include dir as well:
gem install nokogiri -v 1.5.2 -- \
--with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib \
--with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include
You may be able to specify both together:
gem install nokogiri -v 1.5.2 -- \
--with-iconv-dir=/usr/local/Cellar/libiconv/1.13.1
It looks like there was some changes as to how Nokogiri finds iconv between versions 1.5.2 and 1.5.5, which may explain why you’re able to install the latest version but not 1.5.2.
I simply installed homebrew, and used the brew link inconv to create the necessary symlinks to compile the gem.
$brew link libiconv
Linking /usr/local/Cellar/libiconv/1.13.1... 18 symlinks created
$gem install nokogiri -v 1.5.2

Error installing TinyTDS on OSX 10.6 via gem install tiny_tds

I have been trying to install the TinyTDS gem on a Macbook with OSX 10.6. I was successful in installing Free TDS -- confirmed that it works via:
tsql -H SERVER -p 1433 -U username.
The error I'm getting from gem install tiny_tds is:
Building native extensions. This could take a while...
ERROR: Error installing tiny_tds:
ERROR: Failed to build gem native extension.
/Users/jason/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for sybfront.h... yes
checking for sybdb.h... yes
checking for tdsdbopen() in -lsybdb... no
-----
freetds is missing.
-----
*** 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.
I've tried specifying the TDS lib and include dirs (/usr/local/lib and /usr/local/include) without luck. I've tried reinstalling FreeTDS from source manually as well as via homebrew, but that made no difference.
I've seen a few similar issues posted, but they seem to reference an issue with locating iconv libraries which I appear to be moving beyond.
Any suggestions or references I may have overlooked? Thanks in advance.
Same problem on Ubuntu 14.04 resolved with:
sudo apt-get install freetds-dev
gem install tiny_tds
Log output:
Building native extensions. This could take a while...
/home/david/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/ext/builder.rb:73: warning: Insecure world writable dir /mnt/datapart/david in PATH, mode 040777
Successfully installed tiny_tds-0.6.1
Parsing documentation for tiny_tds-0.6.1
Installing ri documentation for tiny_tds-0.6.1
Done installing documentation for tiny_tds after 0 seconds
1 gem installed
You need to install freetds with homebrew
brew update # always a good idea to update homebrew before installing anything!
brew install freetds
In my case, it seems the symlinks were not configured correctly, and using "brew link freetds" threw errors which required opening up some permissions. I tried just about everything else, and this is finally what worked:
devMac:0.95.18 Me$ sudo chown -R $USER /usr/local/share/doc/freetds/images
devMac:0.95.18 Me$ sudo chown -R $USER /usr/local/share/doc/freetds/reference
devMac:0.95.18 Me$ sudo chown -R $USER /usr/local/share/doc/freetds/userguide
devMac:0.95.18 Me$ sudo chown -R $USER /usr/local/share/man/man5
devMac:0.95.18 Me$ brew link --overwrite freetds
Linking /usr/local/Cellar/freetds/0.95.18... 2812 symlinks created
devMac:0.95.18 Me$ sudo gem install tiny_tds
Building native extensions. This could take a while...
Successfully installed tiny_tds-0.6.2
Parsing documentation for tiny_tds-0.6.2
Installing ri documentation for tiny_tds-0.6.2
Done installing documentation for tiny_tds after 0 seconds
1 gem installed
Disclaimer: I am in the early stages of learning this framework and do not have an understanding of the repercussions of using overwrite or changing these permissions.
In my case, installing Ruby 2.3.0 using brew install ruby worked. I got the idea from this question Cannot install tiny_tds on os.x 10.9.4.

Resources