ERROR: Failed to build gem native extension when installing Sablon gem - ruby

I am trying to install and use the Sablon ruby gem. I have installed xcode command line developer tools. However, I continue to get the following error:
ERROR: Error installing sablon:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
Using mini_portile version 2.1.0
checking for iconv.h... yes
checking for gzdopen() in -lz... yes
checking for iconv... yes
Any ideas as to what might be going on here?

try
gem install sablon -- --use-system-libraries=true
if it doesn't work may i ask how you installed xcode command line tools?

Related

How to FIX Zlib missing error on OSX 10.14?

I found this "Zlib missing" continously when installing gems for Rails on Ruby, please let me know a solution :
Fetching nokogiri 1.10.2
Installing nokogiri 1.10.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /usr/local/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.2/ext/nokogiri
/usr/local/opt/ruby/bin/ruby -I /usr/local/Cellar/ruby/2.6.2/lib/ruby/2.6.0 -r ./siteconf20190407-34092-u44l37.rb extconf.rb
checking if the C compiler accepts -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
Using mini_portile version 2.4.0
checking for iconv.h... yes
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** 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 also re-installed OSX 10.14 SDK header but didn't work.
It turned out that I have to manually download zlib from its site and then install it myself to make it work.
Extract the package then install as instruction :
./Configure
make
make install

Failed to install pg 0.18.2 on iOS 10.10.5

I uninstall version 0.18.1 and now I cannot install any of the versions.
I would like to install 0.18.2
I am running this command:
gem install pg -v '0.18.2'
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/Users/liviu-mac/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150901-1693-1wdi2b8.rb extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.
Don't know how to fix the installation?
I used a wrong path, the correct command in my case is:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
I used 9.3 instead of 9.4

Error installing ffi

Can seem to get around this.
$gem install ffi
Building native extensions. This could take a while...
ERROR: Error installing ffi:
ERROR: Failed to build gem native extension.
/remote/part/usern/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for rb_thread_blocking_region()... yes
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
checking for ffi_prep_cif_var()... no
creating extconf.h
creating Makefile
make
libffi.gnu.mk:16: Extraneous text after `else' directive
libffi.gnu.mk:18: *** only one `else' per conditional. Stop.
Gem files will remain installed in /remote/part/usern/.rvm/gems/ruby-1.9.3-p448#myrailsapp/gems/ffi-1.9.0 for inspection.
Results logged to /remote/part/usern/.rvm/gems/ruby-1.9.3-p448#myrailsapp/gems/ffi-1.9.0/ext/ffi_c/gem_make.out
Any ideas?
try this before
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
apt-get install ruby{version}-dev
bundle install ffi
it worked for me
I had to set the gcc to 4.2 and it worked. I also changed the ffi version to 1.0.9 in Gemfile.lock.
export PATH=/opt/gcc-4.2.0/bin/:$PATH
Hi that's related with the GCC compiler i updated mine and also did the trick that Harpreet mentioned (ffi version downgrade) BUT it's not necessary ffi-1.9.3 worked just fine as well :D
in the Gemfile.lock
ffi (1.9.3)
ffi (1.9.3-x86-mingw32)
https://github.com/kennethreitz/osx-gcc-installer
click here github repo with the .pkg installer for all OS (not only MacOSX)

Nokogiri native extension failing to build (Not libxml2 or libxslt missing issue)

As the title says, it doesn't seem to be failing because libxml2 or libxslt is missing. I'm not really sure what to make of the error. (Get it? Because the issue is during make? hehe...)
Anywho, here's the output I'm getting. Any ideas would be appreciated:
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
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 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
make
compiling xml_element_content.c
compiling xml_relax_ng.c
compiling xml_cdata.c
compiling xml_sax_parser_context.c
compiling xml_node_set.c
compiling xml_text.c
compiling xml_sax_parser.c
compiling xml_attribute_decl.c
compiling nokogiri.c
nokogiri.c: In function ‘ruby_strdup’:
nokogiri.c:43:31: warning: conversion to ‘size_t’ from ‘long int’ may change the sign of the result [-Wsign-conversion]
compiling xml_entity_reference.c
compiling xml_node.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 /var/lib/gems/1.9.1/gems/nokogiri-1.5.0 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/nokogiri-1.5.0/ext/nokogiri/gem_make.out
For context, I upgraded from Ubuntu 12.04 to 12.10 last night. I had previously built the Nokogiri native extension on this box, though I do not know if it was the same version or not.
I also checked that I have all packages specified in the second post on "error installing nokogiri 1.5.0 with rails 3.1.0 and ubuntu"
to no avail.
Took me some time to figure out how to append the cflags. Here is my command for nokogiri 1.4.7:
sudo gem install nokogiri -v '1.4.7' -- --with-cflags=\"-Wformat-nonliteral -Wno-format-security\"
If you're trying to install Nokogiri < 1.5.4, you'll have problems on hardened Debian systems like Ubuntu 12.
Details on the underlying issue are here: https://github.com/sparklemotion/nokogiri/issues/680
You should be able to upgrade to 1.5.4 or later and install without this problem.
Alternatively, you should be able to set the CFLAGS environment variable at gem-install time to include the string:
-Wno-error=format-security
or
-Wformat-nonliteral -Wno-format-security
Good luck!
Have you tried installing the following depencies for nokogiri??
# nokogiri requirements
sudo apt-get install libxslt-dev libxml2-dev
sudo gem install nokogiri
This may be happening due to this bug > https://leap.se/code/issues/7231
Run below before running the command:
sudo apt-get install zlib1g-dev

sudo gem install rmagick fails

I am getting this error when I try to install RMagick on my machine so I can play with Scruffy graph creator:
sudo gem install rmagick
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/richardjburton/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.
Any help would be awesome! Thanks.
Looks like you installed ImageMagick using a binary distro or something else which didn't include the headers. From your /Users directory you're probably using OSX. Assuming so, install ImageMagick using either Macports or Homebrew.

Resources