I’m running my app on ubuntu, ruby 2.7.8 using rbenv
When I do bundle install
I received error
An error occurred while installing nokogiri (1.6.8.1), and Bundler
cannot continue. Make sure thatgem install nokogiri -v '1.6.8.1' --source 'https://rubygems.org/'
succeeds before bundling.
Nokogiri installation attempt [all failed]
gem install nokogiri -v '1.6.8.1' --source 'https://rubygems.org/'
gem install nokogiri -v '1.6.8.1' --source 'https://rubygems.org/' -- --use-system-libraries
gem install nokogiri -v '1.6.8.1' -- --use-system-libraries --with-xml2-include=/usr/include/libxml2
bundle config build.nokogiri --use-system-libraries
thenbundle install
Got this error during installation (I cut short because error too long)
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
current directory: /home/adam/.rbenv/versions/2.7.8/lib/ruby/gems/2.7.0/gems/nokogiri-1.6.8.1/ext/nokogiri
/home/adam/.rbenv/versions/2.7.8/bin/ruby -I /home/adam/.rbenv/versions/2.7.8/lib/ruby/2.7.0 -r ./siteconf20240116-50988-10fdguc.rb extconf.rb --use-system-libraries --with-xml2-include\=/usr/include/libxml2
checking if the C compiler accepts ... yes
Building nokogiri using system libraries.
checking for xmlParseDoc() in libxml/parser.h... yes
checking for xsltParseStylesheetDoc() in libxslt/xslt.h... yes
checking for exsltFuncRegister() in libexslt/exslt.h... yes
checking for xmlHasFeature()... 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
current directory: /home/adam/.rbenv/versions/2.7.8/lib/ruby/gems/2.7.0/gems/nokogiri-1.6.8.1/ext/nokogiri
make "DESTDIR=" clean
current directory: /home/adam/.rbenv/versions/2.7.8/lib/ruby/gems/2.7.0/gems/nokogiri-1.6.8.1/ext/nokogiri
make "DESTDIR="
compiling html_document.c
In file included from /home/adam/.rbenv/versions/2.7.8/include/ruby-2.7.0/ruby.h:33:0,
from ./nokogiri.h:33,
from ./html_document.h:4,
from html_document.c:1:
/home/adam/.rbenv/versions/2.7.8/include/ruby-2.7.0/ruby/ruby.h: In function ‘rb_scan_args_set’:
/home/adam/.rbenv/versions/2.7.8/include/ruby-2.7.0/ruby/ruby.h:2594:40: warning: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion]
memcpy(ptr, argv, sizeof(VALUE)*argc);
^
/home/adam/.rbenv/versions/2.7.8/include/ruby-2.7.0/ruby/ruby.h:1763:54: note: in definition of macro ‘memcpy’
#define memcpy(p1,p2,n) ruby_nonempty_memcpy(p1, p2, n)
^
In file included from ./html_document.h:4:0,
from html_document.c:1:
./nokogiri.h: At top level:
./nokogiri.h:39:0: warning: "MAYBE_UNUSED" redefined
# define MAYBE_UNUSED(name) name __attribute__((unused))
In file included from /home/adam/.rbenv/versions/2.7.8/include/ruby-2.7.0/ruby/ruby.h:24:0,
from /home/adam/.rbenv/versions/2.7.8/include/ruby-2.7.0/ruby.h:33,
from ./nokogiri.h:33,
from ./html_document.h:4,
from html_document.c:1:
/home/adam/.rbenv/versions/2.7.8/include/ruby-2.7.0/x86_64-linux/ruby/config.h:161:0: note: this is the location of the previous definition
#define MAYBE_UNUSED(x) __attribute__ ((__unused__)) x
In file included from /home/adam/.rbenv/versions/2.7.8/include/ruby-2.7.0/ruby.h:33:0,
from ./nokogiri.h:33,
from ./html_document.h:4,
from html_document.c:1:
html_document.c: In function ‘new’:
/home/adam/.rbenv/versions/2.7.8/include/ruby-2.7.0/ruby/ruby.h:2510:48: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
(rb_scan_args_verify(fmt, varc), vars), (char *)fmt, varc)
^
......
^
/home/adam/.rbenv/versions/2.7.8/include/ruby-2.7.0/ruby/ruby.h:2342:9: note: in expansion of macro ‘rb_scan_args0’
rb_scan_args0(argc,argvp,fmt,\
^~~~~~~~~~~~~
xml_document.c:508:3: note: in expansion of macro ‘rb_scan_args’
rb_scan_args(argc, argv, "03", &mode, &incl_ns, &with_comments);
^~~~~~~~~~~~
xml_document.c:535:15: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
ns[i] = (xmlChar*) ptr;
^
Makefile:245: recipe for target 'xml_document.o' failed
make: *** [xml_document.o] Error 1
make failed, exit code 2
Gem files will remain installed in /home/adam/.rbenv/versions/2.7.8/lib/ruby/gems/2.7.0/gems/nokogiri-1.6.8.1 for inspection.
Results logged to /home/adam/.rbenv/versions/2.7.8/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/nokogiri-1.6.8.1/gem_make.out
I have libxslt-dev
and libxml2-dev
installed. Tried out all the solutions I found on the internet but nothing work. I don’t know what else to do. Any help would be much appreciated. Thank you!
Results logged to /home/adam/.rbenv/versions/2.7.8/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/nokogiri-1.6.8.1/gem_make.out
. Please scan the file for errors (not warnings), and paste the errors into your question.@Casper the content of the file is exactly the same as the one above
Possible dupe of: stackoverflow.com/questions/23233453/…
I only see warnings, no errors. Have you tried to search for the text “error” or “fail” in gem_make.out?
Can you install a newer version? Like 1.6.8 instead of 1.6.8.1, or even 1.6?