Error installing Nokogiri when using "bundle install" - ruby-on-rails

When I run bundle install it stops with:
Installing nokogiri (1.4.3.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
I tried installing it manually using "Installing Nokogiri" but this did work out in my favour.
Do I need to change something?
/usr/bin/ruby1.9.1 extconf.rb'
extconf.rb:10: Use RbConfig instead of obsolete and deprecated Config.
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... yes
checking for exsltFuncRegister() in -lexslt... yes
checking for xmlFirstElementChild()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetValidStructuredErrors()... yes
checking for xmlSchemaSetValidStructuredErrors()... yes
checking for xmlSchemaSetParserStructuredErrors()... yes
creating Makefile
Or this:
make
compiling xml_dtd.c
compiling xml_entity_reference.c
compiling xml_sax_parser_context.c
compiling xml_attribute_decl.c
compiling xml_schema.c
compiling xml_processing_instruction.c
compiling xml_cdata.c
compiling xml_xpath_context.c
xml_xpath_context.c: In function ‘xpath_generic_exception_handler’:
xml_xpath_context.c:154:3: error: format not a string literal and no format arguments [- Werror=format-security]
cc1: some warnings being treated as errors
make: *** [xml_xpath_context.o] Error 1
Gem files will remain installed in /home/virinchy/.bundler/tmp/10048/gems/nokogiri- 1.4.3.1 for inspection.
Results logged to /home/virinchy/.bundler/tmp/10048/gems/nokogiri- 1.4.3.1/ext/nokogiri/gem_make.out
An error occured while installing nokogiri (1.4.3.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.4.3.1'` succeeds before bundling.'

First, Nokogiri 1.4.3.1 is almost three years old. You should upgrade.
Second, please see https://github.com/sparklemotion/nokogiri/issues/680 for details around how Debian hardened the gcc compiler. You will need to use either an older version of debian or a newer version of Nokogiri.

Related

Trouble with SSL certificat and eventmachine gem

Helle everyone,
I am trying to install the eventmachine gem in a project after it fails during a bundle install.
gem install eventmachine -v '1.0.5'
Logs:
Building native extensions. This could take a while...
ERROR: Error installing eventmachine:
ERROR: Failed to build gem native extension.
/Users/studiohb/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... yes
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for inotify_init() in sys/inotify.h... no
checking for __NR_inotify_init in sys/syscall.h... no
checking for writev() in sys/uio.h... yes
checking for rb_thread_fd_select()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_enable_interrupt()... no
checking for rb_time_new()... yes
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for clock_gettime()... no
checking for gethrtime()... no
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling binder.cpp
In file included from binder.cpp:20:
./project.h:116:10: fatal error: 'openssl/ssl.h' file not found
#include <openssl/ssl.h>
^
1 error generated.
make: *** [binder.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/studiohb/.rvm/gems/ruby-2.1.2#regiex/gems/eventmachine-1.0.5 for inspection.
Results logged to /Users/studiohb/.rvm/gems/ruby-2.1.2#regiex/extensions/x86_64-darwin-13/2.1.0-static/eventmachine-1.0.5/gem_make.out
So I believe that this is a SSL certificat issue si I tried :
brew link --force openssl
logs :
Warning: Refusing to link: openssl
Linking keg-only openssl means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
Do you guys have any ideas on going around this error ?

Can't install kgio 2.8.1 on Ubuntu 14.04

Note: I'm running Ubuntu, not Windows.
This is what happens when trying to install kgio. Am I missing dependencies, what do I install?
gilani#debris$ gem install kgio -v '2.8.1'
Building native extensions. This could take a while...
ERROR: Error installing kgio:
ERROR: Failed to build gem native extension.
/home/gilani/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20151218-13133-1dvzrlz.rb extconf.rb
checking for CLOCK_MONOTONIC in time.h... yes
checking for clockid_t in time.h... yes
checking for clock_gettime() in -lrt... yes
checking for t_open() in -lnsl... no
checking for socket() in -lsocket... no
checking for poll() in poll.h... yes
checking for getaddrinfo() in sys/types.h,sys/socket.h,netdb.h... yes
checking for getnameinfo() in sys/types.h,sys/socket.h,netdb.h... yes
checking for struct sockaddr_storage in sys/types.h,sys/socket.h... yes
checking for accept4() in sys/socket.h... yes
checking for sys/select.h... yes
checking for writev() in sys/uio.h... yes
checking for ruby/io.h... yes
checking for rb_io_t.fd in ruby.h,ruby/io.h... yes
checking for rb_io_t.mode in ruby.h,ruby/io.h... yes
checking for rb_io_t.pathv in ruby.h,ruby/io.h... yes
checking for struct RFile in ruby.h,ruby/io.h... yes
checking size of struct RFile in ruby.h,ruby/io.h... 24
checking for struct RObject... yes
checking size of struct RObject... 40
checking size of int... 4
checking for rb_io_ascii8bit_binmode()... yes
checking for rb_update_max_fd()... yes
checking for rb_fd_fix_cloexec()... yes
checking for rb_cloexec_open()... yes
checking for rb_thread_blocking_region()... no
checking for rb_thread_io_blocking_region()... yes
checking for rb_str_set_len()... yes
checking for rb_time_interval()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_str_subseq()... yes
checking for rb_ary_subseq()... yes
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling wait.c
compiling autopush.c
compiling tryopen.c
tryopen.c:42:0: warning: "RUBY_UBF_IO" redefined [enabled by default]
# define RUBY_UBF_IO ((void *)(-1))
^
In file included from /home/gilani/.rvm/rubies/ruby-2.2.1/include/ruby-2.2.0/ruby/ruby.h:1710:0,
from /home/gilani/.rvm/rubies/ruby-2.2.1/include/ruby-2.2.0/ruby.h:33,
from tryopen.c:1:
/home/gilani/.rvm/rubies/ruby-2.2.1/include/ruby-2.2.0/ruby/intern.h:902:0: note: this is the location of the previous definition
#define RUBY_UBF_IO ((rb_unblock_function_t *)-1)
^
In file included from tryopen.c:43:0:
/home/gilani/.rvm/rubies/ruby-2.2.1/include/ruby-2.2.0/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete [-Wcpp]
#warning rubysig.h is obsolete
^
tryopen.c: In function ‘my_thread_blocking_region’:
tryopen.c:52:2: error: ‘TRAP_BEG’ undeclared (first use in this function)
TRAP_BEG; /* for FIFO */
^
tryopen.c:52:2: note: each undeclared identifier is reported only once for each function it appears in
tryopen.c:54:2: error: ‘TRAP_END’ undeclared (first use in this function)
TRAP_END;
^
make: *** [tryopen.o] Error 1
make failed, exit code 2
Gem files will remain installed in /home/gilani/.rvm/gems/ruby-2.2.1/gems/kgio-2.8.1 for inspection.
Results logged to /home/gilani/.rvm/gems/ruby-2.2.1/extensions/x86_64-linux/2.2.0/kgio-2.8.1/gem_make.out
As #bjhaid answered in the comments, and didn't follow up. I'll post it here myself to close the questoin:
you are trying to compile the gem against a version of ruby newer than
what it was written against, kgio 2.8.1 was released in
2013(bogomips.org/kgio.git/tag/?h=v2.8.1), ruby 2.2.1 was released
March 2015 (ruby-lang.org/en/news/2015/03/03/ruby-2-2-1-released)
A combination of these helped me on Ubuntu 16.04:
apt-get install ruby-kgio
bundle update kgio
Found that if you rvm is not loaded, you might receive same error.
to verify if rvm is loaded try:
rvm use 2.x.x
if you receive following warning:
You need to change your terminal emulator preferences to allow login
shell. Sometimes it is required to use /bin/bash --login as the
command. Please visit https://rvm.io/integration/gnome-terminal/ for
an example.
This would probably be also your case :-)
/bin/bash --login
rvm use 2.x.x
Solved for me after banging head for about an hour+ why could this happens

noi4r gem install issues

In trying to install the nio4r gem. I tried
gem install nio4r -v '1.0.0'
The error that pops up is:
Building native extensions. This could take a while...
ERROR: Error installing nio4r:
ERROR: Failed to build gem native extension.
/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150406-11564-1qtifmf.rb extconf.rb
checking for rb_thread_blocking_region()... no
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port.h... no
checking for sys/resource.h... yes
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling monitor.c
In file included from monitor.c:6:
In file included from ./nio4r.h:10:
/.rvm/rubies/ruby-2.2.1/include/ruby-2.2.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
warning use "ruby/io.h" instead of "rubyio.h"
...
What am I getting wrong? Is it an issue with my RVM?
With some basic updates, I was able to get it to work.
bundle update
and then
bundle
installs the gem.
Thanks to https://github.com/celluloid/nio4r/issues/46
Another approach would be to install a later version of ruby with RVM and do bundle again. Both works

Bundler won't install libxml-ruby (2.2.2) Rails

I'm trying to get set up with a somewhat outdated Rails app so I can try and update it a little but I can't seem to get bundle install working. It keeps telling me:
An error occurred while installing libxml-ruby (2.2.2), and Bundler cannot continue.
Make sure that `gem install libxml-ruby -v '2.2.2'` succeeds before bundling.
The entire error is:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/home/camillavk/.rvm/rubies/ruby-2.1.5/bin/ruby -r ./siteconf20150122-7039-3vyx6p.rb extconf.rb
extconf.rb:17:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
extconf.rb:17:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
checking for socket() in -lsocket... no
checking for gethostbyname() in -lnsl... yes
checking for atan() in -lm... yes
checking for inflate() in -lz... yes
checking for iconv_open() in -liconv... no
checking for libiconv_open() in -liconv... no
checking for libiconv_open() in -llibiconv... no
checking for iconv_open() in -llibiconv... no
checking for iconv_open() in -lc... yes
checking for xmlParseDoc() in -lxml2... yes
checking for libxml/xmlversion.h... no
checking for libxml/xmlversion.h in /opt/include/libxml2,/usr/local/include/libxml2,/usr/include/libxml2... yes
creating extconf.h
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling ruby_xml_html_parser_options.c
compiling ruby_xml_cbg.c
compiling ruby_xml_html_parser.c
compiling ruby_xml_relaxng.c
compiling ruby_xml_schema.c
compiling ruby_xml_xpath_expression.c
compiling ruby_xml_parser.c
compiling ruby_xml_io.c
compiling ruby_xml_error.c
compiling ruby_xml_html_parser_context.c
ruby_xml_html_parser_context.c: In function ‘rxml_html_parser_context_options_set’:
ruby_xml_html_parser_context.c:307:7: warning: variable ‘result’ set but not used [-Wunused-but-set-variable]
int result;
^
compiling ruby_xml_node.c
ruby_xml_node.c: In function ‘rxml_node_to_s’:
ruby_xml_node.c:585:54: error: dereferencing pointer to incomplete type
result = rxml_new_cstr((const char*) output->conv->content, xencoding);
^
ruby_xml_node.c:587:56: error: dereferencing pointer to incomplete type
result = rxml_new_cstr((const char*) output->buffer->content, xencoding);
^
make: *** [ruby_xml_node.o] Error 1
make failed, exit code 2
Gem files will remain installed in /home/camillavk/.rvm/gems/ruby-2.1.5/gems/libxml-ruby-2.2.2 for inspection.
Results logged to /home/camillavk/.rvm/gems/ruby-2.1.5/extensions/x86_64-linux/2.1.0/libxml-ruby-2.2.2/gem_make.out
An error occurred while installing libxml-ruby (2.2.2), and Bundler cannot continue.
Make sure that `gem install libxml-ruby -v '2.2.2'` succeeds before bundling.
When I try and install libxml-ruby it says;
gem install libxml-ruby *[master][ruby-2.1.5]
Building native extensions. This could take a while...
Successfully installed libxml-ruby-2.8.0
1 gem installed
but the same error occurs again when I use bundle install...
When I try
gem install libxml-ruby -v '2.2.2'
I get this error:
Building native extensions. This could take a while...
ERROR: Error installing libxml-ruby:
ERROR: Failed to build gem native extension.
/home/camillavk/.rvm/rubies/ruby-2.1.5/bin/ruby -r ./siteconf20150122-7254-1rcd0x0.rb extconf.rb
extconf.rb:17:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
extconf.rb:17:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
checking for socket() in -lsocket... no
checking for gethostbyname() in -lnsl... yes
checking for atan() in -lm... yes
checking for inflate() in -lz... yes
checking for iconv_open() in -liconv... no
checking for libiconv_open() in -liconv... no
checking for libiconv_open() in -llibiconv... no
checking for iconv_open() in -llibiconv... no
checking for iconv_open() in -lc... yes
checking for xmlParseDoc() in -lxml2... yes
checking for libxml/xmlversion.h... no
checking for libxml/xmlversion.h in /opt/include/libxml2,/usr/local/include/libxml2,/usr/include/libxml2... yes
creating extconf.h
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling ruby_xml_html_parser_options.c
compiling ruby_xml_cbg.c
compiling ruby_xml_html_parser.c
compiling ruby_xml_relaxng.c
compiling ruby_xml_schema.c
compiling ruby_xml_xpath_expression.c
compiling ruby_xml_parser.c
compiling ruby_xml_io.c
compiling ruby_xml_error.c
compiling ruby_xml_html_parser_context.c
ruby_xml_html_parser_context.c: In function ‘rxml_html_parser_context_options_set’:
ruby_xml_html_parser_context.c:307:7: warning: variable ‘result’ set but not used [-Wunused-but-set-variable]
int result;
^
compiling ruby_xml_node.c
ruby_xml_node.c: In function ‘rxml_node_to_s’:
ruby_xml_node.c:585:54: error: dereferencing pointer to incomplete type
result = rxml_new_cstr((const char*) output->conv->content, xencoding);
^
ruby_xml_node.c:587:56: error: dereferencing pointer to incomplete type
result = rxml_new_cstr((const char*) output->buffer->content, xencoding);
^
make: *** [ruby_xml_node.o] Error 1
make failed, exit code 2
Gem files will remain installed in /home/camillavk/.rvm/gems/ruby-2.1.5/gems/libxml-ruby-2.2.2 for inspection.
Results logged to /home/camillavk/.rvm/gems/ruby-2.1.5/extensions/x86_64-linux/2.1.0/libxml-ruby-2.2.2/gem_make.out
I'm running this on linux -> does anyone have any idea how I can get around this or fix it?
Thanks

Installing nokogiri - Failed to build gem native extension

While installing Nokogiri on Ubuntu 12, I got an error:
Installing nokogiri (1.4.4) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
extconf.rb:10: Use RbConfig instead of obsolete and deprecated Config.
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... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... yes
checking for exsltFuncRegister() in -lexslt... yes
checking for xmlFirstElementChild()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetValidStructuredErrors()... yes
checking for xmlSchemaSetValidStructuredErrors()... yes
checking for xmlSchemaSetParserStructuredErrors()... yes
creating Makefile
make
compiling html_sax_parser_context.c
compiling xml_io.c
compiling xml_entity_reference.c
compiling xml_schema.c
compiling xml_element_content.c
compiling xml_reader.c
compiling xml_sax_push_parser.c
compiling xml_sax_parser.c
compiling xslt_stylesheet.c
compiling xml_element_decl.c
compiling xml_node.c
compiling xml_cdata.c
compiling xml_processing_instruction.c
compiling xml_entity_decl.c
compiling xml_attribute_decl.c
compiling xml_xpath_context.c
xml_xpath_context.c: In function ‘xpath_generic_exception_handler’:
xml_xpath_context.c:184:3: error: format not a string literal and no format arguments [-Werror=format-security]
cc1: some warnings being treated as errors
make: *** [xml_xpath_context.o] Error 1
Gem files will remain installed in /home/alex/.bundler/tmp/22194/gems/nokogiri-1.4.4 for inspection.
Results logged to /home/alex/.bundler/tmp/22194/gems/nokogiri-1.4.4/ext/nokogiri/gem_make.out
An error occurred while installing nokogiri (1.4.4), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.4.4'` succeeds before bundling.
I already installed libxslt-dev and libxml2-dev, but as you see, it didn't help.
How do I solve it?
I stumbled at this trying to install bigbluebutton on ubuntu 13.04
I solved it doing this trick to compile reverting the -Wformat-security gcc flag systemwide
Be careful doing the first rm. It can break your whole system!!
rm /usr/bin/gcc
nano /usr/bin/gcc
## contents of /usr/bin/gcc
#!/bin/sh
gcc-4.7 $* -Wno-format-security
## save and exit
chmod u+x /usr/bin/gcc
gem install nokogiri -v '1.4.4'
Is there a specific reason you need 1.4.4 instead of the latest 1.5.6? Otherwise I suggest upgrading.
The Nokogiri changelog shows they fixed this in 1.5.4:
Build support on hardened Debian systems that use
-Werror=format-security. #680.
#Confusion has the right idea.
Bundler is probably locked to nokogiri-1.4.4 in the Gemfile and/or Gemfile.lock. #Confusion's answer of running bundle update should allow your Ruby Bundler environment to use the successfully installed nokogiri-1.5.6.

Resources