Error installing while installing unf_ext - ruby

I installed MacOS High Sierra yesterday, and I was testing my ruby code and it was failing due to one of my gems not being installed. I tried installing it today and got this back:
Fetching gem metadata from https://rubygems.org/.........
Fetching version metadata from https://rubygems.org/.
Using bundler 1.15.4
Fetching unf_ext 0.0.7.4
Your user account isn't allowed to install to the system RubyGems.
You can cancel this installation and run:
bundle install --path vendor/bundle
to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to RubyGems using sudo.
Password:
Installing unf_ext 0.0.7.4 with native extensions
Using mime-types-data 3.2016.0521
Using net-http-digest_auth 1.4.1
Using net-http-persistent 2.9.4
Using mini_portile2 2.1.0
Using ntlm-http 0.1.1
Using webrobots 0.1.2
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/private/var/folders/lq/mdp176gx3b90j7_mvygpydmr0000gn/T/bundler20170927-4407-1gh3fizunf_ext-0.0.7.4/gems/unf_ext-0.0.7.4/ext/unf_ext
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r
./siteconf20170927-4407-1twnwgt.rb extconf.rb
checking for main() in -lstdc++... *** 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:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/$(RUBY_BASE_NAME)
--with-static-libstdc++
--without-static-libstdc++
--with-stdc++lib
--without-stdc++lib
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:456:in
`try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:535:in
`block in try_link0'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/tmpdir.rb:89:in
`mktmpdir'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:532:in
`try_link0'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:556:in
`try_link'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:765:in
`try_func'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:997:in
`block in have_library'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:942:in
`block in checking_for'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:350:in
`block (2 levels) in postpone'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:320:in
`open'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:350:in
`block in postpone'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:320:in
`open'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:346:in
`postpone'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:941:in
`checking_for'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:992:in
`have_library'
from extconf.rb:6:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
/var/folders/lq/mdp176gx3b90j7_mvygpydmr0000gn/T/bundler20170927-4407-1gh3fizunf_ext-0.0.7.4/extensions/universal-darwin-17/2.3.0/unf_ext-0.0.7.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
/var/folders/lq/mdp176gx3b90j7_mvygpydmr0000gn/T/bundler20170927-4407-1gh3fizunf_ext-0.0.7.4/gems/unf_ext-0.0.7.4
for inspection.
Results logged to
/var/folders/lq/mdp176gx3b90j7_mvygpydmr0000gn/T/bundler20170927-4407-1gh3fizunf_ext-0.0.7.4/extensions/universal-darwin-17/2.3.0/unf_ext-0.0.7.4/gem_make.out
An error occurred while installing unf_ext (0.0.7.4), and Bundler
cannot continue.
Make sure that `gem install unf_ext -v '0.0.7.4'` succeeds before bundling.
In Gemfile:
mechanize was resolved to 2.7.5, which depends on
http-cookie was resolved to 1.0.3, which depends on
domain_name was resolved to 0.5.20170404, which depends on
unf was resolved to 0.1.4, which depends on
unf_ext
And then when I try and install unf_ext this happends
sudo gem install unf_ext -v '0.0.7.4'
Building native extensions. This could take a while...
ERROR: Error installing unf_ext:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.3.0/gems/unf_ext-0.0.7.4/ext/unf_ext
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20170927-4629-13u5zrr.rb extconf.rb
checking for main() in -lstdc++... *** 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:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/$(RUBY_BASE_NAME)
--with-static-libstdc++
--without-static-libstdc++
--with-stdc++lib
--without-stdc++lib
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:535:in `block in try_link0'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/tmpdir.rb:89:in `mktmpdir'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:532:in `try_link0'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:556:in `try_link'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:765:in `try_func'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:997:in `block in have_library'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:992:in `have_library'
from extconf.rb:6:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/unf_ext-0.0.7.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/unf_ext-0.0.7.4 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/unf_ext-0.0.7.4/gem_make.out
I have no idea what the issue is. I installed ruby and rbenv, but as soon as I installed the new MacOs I was unable to install any gems.

I copied out the "extconf.rb" to my working folder and run "ruby extconf.rb" again, got a mkmf.log, turned out it was a missing "ruby/config.h". Then the problem was fixed by "xcode-select --install". See:
macOS Mojave 'ruby/config.h' file not found
My machine runs 10.13.6 macOS High Sierra.

It is telling you the error, you just need to pick through the output.
checking for main() in -lstdc++... *** extconf.rb failed ***
extconf.rb is the script that configures a gem for native compilation, here it's checking a pretty basic requirement: can you compile a C++ executable? And it fails. A bit later it repeats this
mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
mkmf.rb is a stdlib used by extconf.rb to test the capabilities of your compiler and then output a suitable makefile for building the extension. It's repeating that it couldn't even build a C++ executable (let alone check for any specific capability).
So either you don't have a C++ compiler installed or your paths aren't set up in a way that Ruby can find it.

Not specifically the same condition as OP (OSX) but I was getting the same error while creating/building an Ubuntu based docker container image. Thanks to this answer by Max, I fixed it by making sure that g++ was installed along-side build-essential
My Dockerfile
# syntax=docker/dockerfile:1.2
FROM ubuntu:jammy
ENV DEBIAN_FRONTEND=noninteractive
ENV GEM_HOME="/usr/local/bundle"
ENV PATH="$PATH:$GEM_HOME/bin:$GEM_HOME/gems/bin:/usr/local/bin"
ARG USER=${user:-ruby}
ENV USER=$USER
ENV HOME=/home/$USER
WORKDIR /var/tmp
RUN apt update && apt upgrade -y && \
apt install --no-install-recommends -y bash git curl ca-certificates \
build-essential unzip libffi-dev sudo libssl-dev zlib1g-dev \
g++ && \
curl -sL -o "awscliv2.zip" "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" && \
unzip awscliv2.zip && \
./aws/install && \
groupadd admin && \
useradd -ms /bin/bash $USER -G admin
# set passwd secretly
RUN --mount=type=secret,id=user_passwd < /run/secrets/user_passwd chpasswd
RUN chown -R $USER:$USER $HOME && \
chown -R $USER:$USER /var/tmp/*
USER ${USER}
ENV PATH="$PATH:$HOME/.rbenv/bin:$HOME/.rbenv/shims"
RUN curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash && \
eval "$(rbenv init - bash)" || true && \
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-doctor | bash && \
rbenv install 3.1.2 && \
rbenv global 3.1.2
USER root
RUN mkdir -p /usr/local/bundle && \
chown -R $USER:$USER /usr/local/bundle
USER ${USER}
RUN rbenv init > $HOME/.bashrc 2>&1 || true
#RUN echo 'eval "$(rbenv init - bash)"' > $HOME/.bashrc
WORKDIR /my-operator
COPY . .
RUN gem install bundler && \
bundler
USER root
RUN apt remove -y --purge build-essential git g++ libssl-dev zlib1g-dev libffi-dev && \
apt autoremove -y && \
rm -rf /var/lib/apt/lists/* /var/tmp/* /root/go
USER ${USER}
CMD ["bin/console"]

Related

Can't install a gem on CentOS 8

Use root user installed rubygems.
# yum install rubygems -y
When check ruby's version, got
# ruby -v
ruby 2.5.9p229 (2021-04-05 revision 67939) [x86_64-linux]
Gem's version:
# gem -v
2.7.6.3
When install a gem, got
# gem install fluent-plugin-kinesis
Building native extensions. This could take a while...
ERROR: Error installing fluent-plugin-kinesis:
ERROR: Failed to build gem native extension.
current directory: /usr/local/share/gems/gems/msgpack-1.4.2/ext/msgpack
/usr/bin/ruby -r ./siteconf20210825-20925-17fyw57.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/share/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /usr/local/share/gems/gems/msgpack-1.4.2 for inspection.
Results logged to /usr/local/lib64/gems/ruby/msgpack-1.4.2/gem_make.out
Should I install a high version ruby? It's the default one on the system.
update
I installed ruby-devel
# yum install ruby-devel.x86_64
Run install fluent-plugin-kinesis gem again
# gem install fluent-plugin-kinesis
Building native extensions. This could take a while...
ERROR: Error installing fluent-plugin-kinesis:
ERROR: Failed to build gem native extension.
current directory: /usr/local/share/gems/gems/msgpack-1.4.2/ext/msgpack
/usr/bin/ruby -r ./siteconf20210826-11878-18i9eps.rb extconf.rb
checking for ruby/st.h... *** 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:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib64
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/$(RUBY_BASE_NAME)
/usr/share/ruby/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/share/ruby/mkmf.rb:590:in `try_cpp'
from /usr/share/ruby/mkmf.rb:1098:in `block in have_header'
from /usr/share/ruby/mkmf.rb:948:in `block in checking_for'
from /usr/share/ruby/mkmf.rb:350:in `block (2 levels) in postpone'
from /usr/share/ruby/mkmf.rb:320:in `open'
from /usr/share/ruby/mkmf.rb:350:in `block in postpone'
from /usr/share/ruby/mkmf.rb:320:in `open'
from /usr/share/ruby/mkmf.rb:346:in `postpone'
from /usr/share/ruby/mkmf.rb:947:in `checking_for'
from /usr/share/ruby/mkmf.rb:1097:in `have_header'
from extconf.rb:3:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/usr/local/lib64/gems/ruby/msgpack-1.4.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /usr/local/share/gems/gems/msgpack-1.4.2 for inspection.
Results logged to /usr/local/lib64/gems/ruby/msgpack-1.4.2/gem_make.out
For other gems works well.
Take a look at the docs or this answer.
Install Ruby >= 2.4 on your local environment. In addition, install ruby-dev package via Package Manager to build native extension gems.
I believe in CentOS ruby-dev equivalent is ruby-devel. You can confirm it by running yum search ruby-dev
You'll find 2 packages, one i686 and another x86_64. You can find which one you need by running lscpu | grep Arch.
Then simply download the package, and rerun gem install

How to fix "ERROR: Failed to build gem native extension." when installing eventmachine on macOS Mojave

I am a novice with ruby and the command line.
Ruby -v: ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
Mac: Mojave 10.14.2
I am trying to open my Jekyll blog on my localhost, something which hasn't given me issues previously. However I ran
bundle exec jekyll serve
and get this error:
Could not find eventmachine-1.2.7 in any of the sources
Run `bundle install` to install missing gems.
As suggested, I then run
bundle install
and get this error:
Ignoring ffi-1.9.25 because its extensions are not built. Try: gem pristine ffi --version 1.9.25
Ignoring http_parser.rb-0.6.0 because its extensions are not built. Try: gem pristine http_parser.rb --version 0.6.0
Fetching gem metadata from https://rubygems.org/...........
Using rake 10.5.0
Using public_suffix 3.0.3
Using addressable 2.5.2
Using bundler 2.0.1
Using colorator 1.1.0
Using concurrent-ruby 1.0.5
Fetching eventmachine 1.2.7
Installing eventmachine 1.2.7 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/name/Desktop/GitHub/blog/vendor/bundle/ruby/2.3.0/gems/eventmachine-1.2.7/ext
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20190212-57509-l19d0i.rb extconf.rb
--with-cppflags=-I/usr/local/opt/openssl/include
checking for main() in -lcrypto... *** 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:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/$(RUBY_BASE_NAME)
--with-ssl-dir
--without-ssl-dir
--with-ssl-include
--without-ssl-include=${ssl-dir}/include
--with-ssl-lib
--without-ssl-lib=${ssl-dir}/lib
--with-openssl-config
--without-openssl-config
--with-pkg-config
--without-pkg-config
--with-cryptolib
--without-cryptolib
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to
generate an executable file. (RuntimeError)
You have to install development tools first.
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:535:in `block in try_link0'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/tmpdir.rb:89:in `mktmpdir'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:532:in `try_link0'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:556:in `try_link'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:765:in `try_func'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:997:in `block in have_library'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:992:in `have_library'
from extconf.rb:8:in `block in check_libs'
from extconf.rb:8:in `each'
from extconf.rb:8:in `all?'
from extconf.rb:8:in `check_libs'
from extconf.rb:95:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/name/Desktop/GitHub/blog/vendor/bundle/ruby/2.3.0/extensions/universal-darwin-18/2.3.0/eventmachine-1.2.7/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
/Users/nbame/Desktop/GitHub/blog/vendor/bundle/ruby/2.3.0/gems/eventmachine-1.2.7 for inspection.
Results logged to
/Users/name/Desktop/GitHub/blog/vendor/bundle/ruby/2.3.0/extensions/universal-darwin-18/2.3.0/eventmachine-1.2.7/gem_make.out
An error occurred while installing eventmachine (1.2.7), and Bundler cannot continue.
Make sure that `gem install eventmachine -v '1.2.7' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
jekyll was resolved to 3.8.3, which depends on
em-websocket was resolved to 0.5.1, which depends on
eventmachine
I have tried:
Using gem install eventmachine -v '1.2.7' --source 'https://rubygems.org/' which gives me the "ERROR: Failed to build gem native extension."
brew install coreutils as recommended here
Every answer to this question
The answers here relating to Mojave and gem update failing
gem pristine ffi --version 1.9.25 because it suggested so in the error message
My mkmf.log log is below
"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18 -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -I/usr/local/opt/openssl/include -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib -L. -lruby.2.3.0 -lpthread -ldl -lobjc "
In file included from conftest.c:1:
In file included from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby.h:33:
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found
#include "ruby/config.h"
^~~~~~~~~~~~~~~
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
"pkg-config --exists openssl"
package configuration for openssl is not found
I've had luck installing libffi with Homebrew, then using the recommended build flags:
$ brew install libffi
==> Downloading https://homebrew.bintray.com/bottles/libffi-3.2.1.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libffi-3.2.1.mojave.bottle.tar.gz
==> Caveats
libffi is keg-only, which means it was not symlinked into /usr/local,
because some formulae require a newer version of libffi.
For compilers to find libffi you may need to set:
export LDFLAGS="-L/usr/local/opt/libffi/lib"
For pkg-config to find libffi you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
$ LDFLAGS="-L/usr/local/opt/libffi/lib" PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig" bundle install
I have lots of projects that use FFI, but rather than exporting those variables (since they are global), I added an alias to my Bash profile so I can easily set them on the fly:
# ~/.bash_profile
alias ffi='LDFLAGS="-L/usr/local/opt/libffi/lib" PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"'
Now whenever I have a project that uses FFI, I can install the gem like this:
$ ffi bundle install
I had the same problem and also nothing worked. Turns out eventmachine used my python's anaconda environment with openssl installed. I created new clean anaconda environment and just run bundle install again.
According to the error, "You have to install development tools first.". To install the development tools, run this in your Terminal:
xcode-select --install
The Xcode command line tools often have to be re-installed after major operating system updates.

ERROR: Error installing sass: ERROR: Failed to build gem native extension

I was trying to install sass. I did manage to install it via npm (1.14.1 compiled with dart2js 2.0.0), however I need to install it with Ruby (Ruby Sass 3.5.6.). Now, here is the error when I run "sudo gem install sass"
Building native extensions. This could take a while...
ERROR: Error installing sass:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.25/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20181004-3909-1iytz3s.rb extconf.rb
checking for ffi.h... *** 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:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/$(RUBY_BASE_NAME)
--with-ffi_c-dir
--without-ffi_c-dir
--with-ffi_c-include
--without-ffi_c-include=${ffi_c-dir}/include
--with-ffi_c-lib
--without-ffi_c-lib=${ffi_c-dir}/lib
--with-libffi-config
--without-libffi-config
--with-pkg-config
--without-pkg-config
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:456:in 'try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:571:in `block in try_compile'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:524:in `with_werror'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:571:in `try_compile'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:1091:in `block in have_header'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:942:in `block in checking_for'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:320:in `open'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:350:in `block in postpone'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:320:in `open'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:346:in `postpone'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:941:in `checking_for'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/
2.3.0/mkmf.rb:1090:in `have_header'
from extconf.rb:16:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.9.25/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.25 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.9.25/gem_make.out
I have tried to update Ruby, delete sass installed via npm, update xcode dev-tools as some suggested. But nothing works. I have no idea what is the reason since I had sass before updating to new Mac OS Mojave from 0.
Here is the mkmf.log file:
package configuration for libffi is not found
"xcrun clang -o conftest -
I/System/Library/Frameworks/Ruby.framework
/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18 -
I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/
include/ruby-2.3.0/ruby/backward -
I/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/
ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -
D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -
DHAVE_GCC_ATOMIC_BUILTINS conftest.c -L. -
L/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib -L.
-lruby.2.3.0 -lpthread -ldl -lobjc "
In file included from conftest.c:1:
In file included from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/
ruby-2.3.0/ruby.h:33:
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/
ruby-2.3.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found
#include "ruby/config.h"
^~~~~~~~~~~~~~~
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
Any ideas?
Ok, so the solution was found. If you have this error. Do this:
Install rvm (https://rvm.io/)
Then I had to run this command to make rvm work:
if sudo grep -q secure_path /etc/sudoers; then sudo sh -c "echo export rvmsudo_secure_path=1 >> /etc/profile.d/rvm_secure_path.sh" && echo Environment variable installed; fi
next with rvm I deleted ruby:
rvm remove ruby
and lastly install ruby:
rvm install ruby
not sure if this step was required, but this is what I had in my console: Ruby was built without documentation, to build it run: rvm docs generate-ri
So I also ran this command. And after that I was finally able to sudo gem install sass.
Now it works!
Perform following steps in mac to install SASS error free
Install gpg
brew install -v gpg
Install gpg keys
gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
Allow curl to run without checking SSL (else command #4 will throw an error)
echo insecure >> ~/.curlrc
Install rvm
\curl -sSL -k https://get.rvm.io | bash
To use rvm, you will get an output after running command in #3 like:
To start using RVM you need to run source /Users/ymehta/.rvm/scripts/rvm
Copy paste command and hit Enter
Remove existing ruby version
rvm remove ruby
Install ruby
rvm install ruby
rvm docs generate-ri
Install sass
sudo gems install sass
Check sass version
sass --version
Same steps can be found at https://gist.github.com/Yashvi-Mehta/9ad81330d1703f12a00b63cf20c9cdb3

Ruby Gem Nokogiri Not Installing on Rails 3.2.11

I am trying to run a Rails app through Docker that is using Rails 3.2.11. The gem nokogiri is not being installed when I run bundle install.
I have this in my Gemfile:
gem 'nokogiri', '~> 1.6.8.rc2'
And this in my LOCK file:
nokogiri (1.6.8.rc2)
mini_portile2 (~> 2.1.0)
When I try running bundle install through docker, I get the following error messages:
************************************************************************
Extracting libxml2-2.9.3.tar.gz into tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.3... OK
Running 'configure' for libxml2 2.9.3... OK
Running 'compile' for libxml2 2.9.3... ERROR, review
'/var/www/docker_example/activemodel/ruby/1.9.1/gems/nokogiri-1.6.8.rc2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.3/compile.log'
to see what happened. Last lines are:
========================================================================
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/bash
/var/www/docker_example/activemodel/ruby/1.9.1/gems/nokogiri-1.6.8.rc2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.3/libxml2-2.9.3/missing
aclocal-1.15 -I m4
/var/www/docker_example/activemodel/ruby/1.9.1/gems/nokogiri-1.6.8.rc2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.3/libxml2-2.9.3/missing:
line 81: aclocal-1.15: command not found
WARNING: 'aclocal-1.15' is missing on your system.
You should only need it if you modified 'acinclude.m4' or
'configure.ac' or m4 files included by 'configure.ac'.
The 'aclocal' program is part of the GNU Automake package:
<http://www.gnu.org/software/automake>
It also requires GNU Autoconf, GNU m4 and Perl in order to run:
<http://www.gnu.org/software/autoconf>
<http://www.gnu.org/software/m4/>
<http://www.perl.org/>
make: *** [aclocal.m4] Error 127
========================================================================
*** 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:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby1.9.1
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--enable-cross-build
--disable-cross-build
/var/www/docker_example/activemodel/ruby/1.9.1/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:366:in `block
in execute': Failed to complete compile task (RuntimeError)
from /var/www/docker_example/activemodel/ruby/1.9.1/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:337:in
`chdir'
from /var/www/docker_example/activemodel/ruby/1.9.1/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:337:in
`execute'
from /var/www/docker_example/activemodel/ruby/1.9.1/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:111:in
`compile'
from /var/www/docker_example/activemodel/ruby/1.9.1/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:150:in
`cook'
from extconf.rb:288:in `block (2 levels) in process_recipe'
from extconf.rb:181:in `block in chdir_for_build'
from extconf.rb:180:in `chdir'
from extconf.rb:180:in `chdir_for_build'
from extconf.rb:287:in `block in process_recipe'
from extconf.rb:186:in `tap'
from extconf.rb:186:in `process_recipe'
from extconf.rb:477:in `<main>'
Gem files will remain installed in /var/www/docker_example/activemodel/ruby/1.9.1/gems/nokogiri-1.6.8.rc2 for
inspection.
Results logged to /var/www/docker_example/activemodel/ruby/1.9.1/gems/nokogiri-1.6.8.rc2/ext/nokogiri/gem_make.out
An error occurred while installing nokogiri (1.6.8.rc2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.8.rc2'` succeeds before bundling.
In Gemfile:
fog was resolved to 1.23.0, which depends on
nokogiri
I've tried modifying the Gem File a few times but it keeps resulting in Nokogiri not being installed properly.
Any help is greatly appreciated!
Make sure libxml2 is installed on your machine. Is it available to install with brew install or apt-get install depending on your OS.
Update: also if you're trying to run your app inside of docker container add libxml2 too and install nokogiri with RUN gem install nokogiri -v '1.6.8.1' in your Dockerfile

Mac Rmagick 2.13.2 ERROR: Failed to build gem native extension

Recently I've updated my Mac to El Capitan and re-installed (with Homebrew) ImageMagick 6.9.2-7
Unfortunately bundle install doesn't work because RMagick fails to build.
Here the stack trace:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/me/.rvm/rubies/ruby-1.9.3-p327/bin/ruby -r ./siteconf20151204-39308-uw4m6y.rb extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for /usr/local/opt/gcc46/bin/gcc-4.6... 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. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/me/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
/Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:931:in `block in have_header'
from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:930:in `have_header'
from extconf.rb:194:in `<main>'
extconf failed, exit code 1
I've tried several different solutions founded on Internet but nothing seems to fix this error.
With the operations below I receive always the errore above:
1) C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.9.2-7/include/ImageMagick-6/ gem install rmagick -v '2.13.2'
2) gem install rmagick --version=2.13.2 --platform=ruby -- --with-opt-lib="h:/ImageMagick-6.9.2-7/lib" --with-opt-include="h:/ImageMagick-6.9.2-7/include"
3) $ cd /usr/local/Cellar/imagemagick/6.9.2-7/lib
$ ln -s libMagick++-Q16.6.dylib libMagick++.dylib
$ ln -s libMagickCore-Q16.2.dylib libMagickCore.dylib
$ ln -s libMagickWand-Q16.2.dylib libMagickWand.dylib
The error still the same:
The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
I've also updated xcoce to 7.1.1
I'm using ruby-1.9.3-p327 with RVM
Thanks in advance.
You need to update Xcode and install Command Line Tools (xcode-select --install).
None of these worked in isolation for me, but the running of all of them seemed to do the trick:
xcode-select --install
brew unlink imagemagick
brew uninstall --force imagemagick
brew update
brew doctor
brew install imagemagick
That's likely overkill but in the end worked for me.

Resources