Can't install a gem on CentOS 8 - ruby

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

Related

Rmagick - Gem::Ext::BuildError: ERROR: Failed to build gem native extension

I installed pkg-config and imagemagick:
brew install pkg-config imagemagick#6
Imagemagick version
identify -version
Version: ImageMagick 6.9.12-28 Q16 arm 2021-10-29 https://imagemagick.org
When trying to install rmagick
gem install rmagick
I get
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
current directory: /opt/homebrew/lib/ruby/gems/3.0.0/gems/rmagick-4.2.3/ext/RMagick
/opt/homebrew/opt/ruby/bin/ruby -I /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0 -r ./siteconf20211112-33588-cd2c64.rb extconf.rb
checking for brew... yes
checking for Ruby version >= 2.3.0... yes
checking for pkg-config... yes
/opt/homebrew/Library/Homebrew/shims/mac/super/pkg-config: line 9: /pkg-config/bin/pkg-config: No such file or directory
/opt/homebrew/Library/Homebrew/shims/mac/super/pkg-config: line 9: exec: /pkg-config/bin/pkg-config: cannot execute: No such file or directory
ERROR: Can't install RMagick 4.2.3.
Can't find the ImageMagick library or one of the dependent libraries.
Check the mkmf.log file for more detailed information.
*** 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=/opt/homebrew/Cellar/ruby/3.0.2_1/bin/$(RUBY_BASE_NAME)
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/opt/homebrew/lib/ruby/gems/3.0.0/extensions/arm64-darwin-20/3.0.0/rmagick-4.2.3/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /opt/homebrew/lib/ruby/gems/3.0.0/gems/rmagick-4.2.3 for inspection.
Results logged to /opt/homebrew/lib/ruby/gems/3.0.0/extensions/arm64-darwin-20/3.0.0/rmagick-4.2.3/gem_make.out
So I created a folder /opt/homebrew/Library/Homebrew/shims/mac/super/pkg-config/bin/ containing a symbolic link
ln -s /opt/homebrew/opt/pkg-config/bin/pkg-config pkg-config
And now when trying to install rmagick I get:
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
current directory: /opt/homebrew/lib/ruby/gems/3.0.0/gems/rmagick-4.2.3/ext/RMagick
/opt/homebrew/opt/ruby/bin/ruby -I /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0 -r ./siteconf20211112-33523-27c8up.rb extconf.rb
checking for brew... yes
checking for Ruby version >= 2.3.0... yes
checking for pkg-config... yes
checking for outdated ImageMagick version (<= 6.7.7)... no
checking for clang... yes
Warning: Found more than one ImageMagick installation. This could cause problems at runtime.
/opt/homebrew/opt/imagemagick#6/bin/Magick-config reports version 6.9.12-28 Q16 is installed in /opt/homebrew/Cellar/imagemagick#6/6.9.12-28
/opt/homebrew/bin/Magick-config reports version 6.9.12-28 Q16 is installed in /opt/homebrew/Cellar/imagemagick#6/6.9.12-28
Using 6.9.12-28 Q16 from /opt/homebrew/Cellar/imagemagick#6/6.9.12-28.
checking for __GNUC__... *** 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=/opt/homebrew/Cellar/ruby/3.0.2_1/bin/$(RUBY_BASE_NAME)
/opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:597:in `block in try_compile'
from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:546:in `with_werror'
from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:597:in `try_compile'
from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:864:in `macro_defined?'
from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:1006:in `block in have_macro'
from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:971:in `block in checking_for'
from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:361:in `block (2 levels) in postpone'
from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:331:in `open'
from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:361:in `block in postpone'
from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:331:in `open'
from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:357:in `postpone'
from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:970:in `checking_for'
from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:1005:in `have_macro'
from extconf.rb:99:in `configure_compile_options'
from extconf.rb:19:in `initialize'
from extconf.rb:398:in `new'
from extconf.rb:398:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/opt/homebrew/lib/ruby/gems/3.0.0/extensions/arm64-darwin-20/3.0.0/rmagick-4.2.3/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /opt/homebrew/lib/ruby/gems/3.0.0/gems/rmagick-4.2.3 for inspection.
Results logged to /opt/homebrew/lib/ruby/gems/3.0.0/extensions/arm64-darwin-20/3.0.0/rmagick-4.2.3/gem_make.out
It is specified I have to install development tools so I checked if it was installed:
gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: arm64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
I've been searching for a long time now and found several topics dealing with similar issues but none of them could help me...
Do you have an idea why this doesn't work ?
I'm using Mac OSX 11.6, ruby 3.0.2p107
Thanks a lot
Okay just by restarting the mac, uninstalling and reinstalling everything I managed to install rmagick v4.2.3.
Uninstall
brew uninstall pkg-config imagemagick#6
Reinstall
brew install pkg-config imagemagick#6
And installed Rmagick
gem install rmagick
I already tried to uninstall and reinstall before but without restarting the mac and the Rmagick installation was failing in the same way... So it seems that restart was needed, maybe one of the paths or environment variables needed this to be set properly for Rmagick...

Can't Find ffi.h When Installing ffi ruby gem

Ruby version 2.2.4p230
RubyGem version 2.7.2
Ruby-devel and lib64ffi-devel installed.
64-bit OpenMandriva 3.0, urpmi and rpmdrake used.
Goal: to install compass, but the gem ffi is needed first.
I have scoured the internet so hard for the last two days and I'm so stumped... It's impossible for me to install an earlier version of ruby because of the dependency for an older ncurses. I feel like replacing ncurses would open a can of nasty worms.
However... I am also completely open to a compass alternative, where the config.rb project files could be somehow ported / copied so both compass and this other sass compiler could operate. (this is for work and we're not changing the sass builder any time soon).
/usr/share/gems/gems/ffi-1.9.18/ext/ffi_c totally exists, there is an ffi.c file in that directory but can't find any ffi.h file in the vicinity. In a moment of desperation I touched ffi.h in that dir and when I ran gem install it removed it. ;) I would try taking a copy of someone else's libs to see if that works.
Basically any way to get this working without breaking the rest of my packages. I don't use ruby for anything else, just compass.
Here is the output:
# sudo gem install ffi
Building native extensions. This could take a while...
ERROR: Error installing ffi:
ERROR: Failed to build gem native extension.
current directory: /usr/share/gems/gems/ffi-1.9.18/ext/ffi_c
/usr/bin/ruby -r ./siteconf20171110-17988-1lodsok.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}/lib64
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/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}/lib64
--with-libffi-config
--without-libffi-config
--with-pkg-config
--without-pkg-config
/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:587:in `try_cpp'
from /usr/share/ruby/mkmf.rb:1060:in `block in have_header'
from /usr/share/ruby/mkmf.rb:911:in `block in checking_for'
from /usr/share/ruby/mkmf.rb:351:in `block (2 levels) in postpone'
from /usr/share/ruby/mkmf.rb:321:in `open'
from /usr/share/ruby/mkmf.rb:351:in `block in postpone'
from /usr/share/ruby/mkmf.rb:321:in `open'
from /usr/share/ruby/mkmf.rb:347:in `postpone'
from /usr/share/ruby/mkmf.rb:910:in `checking_for'
from /usr/share/ruby/mkmf.rb:1059: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:
/usr/lib64/gems/ruby/ffi-1.9.18/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /usr/share/gems/gems/ffi-1.9.18 for inspection.
Results logged to /usr/lib64/gems/ruby/ffi-1.9.18/gem_make.out
Any help appreciated!
Your error message shows:
/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.
And that's how you can solve it:
xcode-select --install
(but make sure beforehand that xcode-select -p is returning the path to a stable Xcode version, like Xcode 10)
See also https://github.com/ffi/ffi/issues/647.

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

Ruby and RubyDev under Chocolately on Windows

I have installer ruby 2.3.1 ruby.devkit 4.5.2.20120101 from the chocolately repostory on windows 10
then i have modified conf.yml and run:
PS C:\tools\DevKit> ruby dk.rb install --force
[WARN] Updating (with backup) existing gem override for 'C:/tools/ruby23'
[WARN] Updating (with backup) DevKit helper library for 'C:/tools/ruby23'
All seem to me ok, but when I try to update gems, some of them show the following errors:
PS C:\tools\DevKit> gem update
Updating installed gems
Updating bigdecimal
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing bigdecimal:
ERROR: Failed to build gem native extension.
current directory: C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/bigdecimal-1.3.0/ext/bigdecimal
C:/tools/ruby23/bin/ruby.exe -r ./siteconf20170106-4004-rogg3v.rb extconf.rb
checking for labs() in stdlib.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=C:/tools/ruby23/bin/$(RUBY_BASE_NAME)
C:/tools/ruby23/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 C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:541:in `try_link0'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:556:in `try_link'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:765:in `try_func'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:1051:in `block in have_func'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:1050:in `have_func'
from extconf.rb:6:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
C:/tools/ruby23/lib/ruby/gems/2.3.0/extensions/x64-mingw32/2.3.0/bigdecimal-1.3.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/bigdecimal-1.3.0 for inspection.
Results logged to C:/tools/ruby23/lib/ruby/gems/2.3.0/extensions/x64-mingw32/2.3.0/bigdecimal-1.3.0/gem_make.out
Updating did_you_mean
ERROR: Error installing did_you_mean:
did_you_mean requires Ruby version >= 2.4.0dev.
Updating io-console
Building native extensions. This could take a while...
ERROR: Error installing io-console:
ERROR: Failed to build gem native extension.
current directory: C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/io-console-0.4.6
C:/tools/ruby23/bin/ruby.exe -r ./siteconf20170106-4004-impy5k.rb extconf.rb
*** 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=C:/tools/ruby23/bin/$(RUBY_BASE_NAME)
C:/tools/ruby23/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 C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:571:in `block in try_compile'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:524:in `with_werror'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:571:in `try_compile'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:835:in `macro_defined?'
from extconf.rb:7:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
C:/tools/ruby23/lib/ruby/gems/2.3.0/extensions/x64-mingw32/2.3.0/io-console-0.4.6/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/io-console-0.4.6 for inspection.
Results logged to C:/tools/ruby23/lib/ruby/gems/2.3.0/extensions/x64-mingw32/2.3.0/io-console-0.4.6/gem_make.out
Updating json
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
current directory: C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/json-2.0.2/ext/json/ext/generator
C:/tools/ruby23/bin/ruby.exe -r ./siteconf20170106-4004-dmzeq3.rb extconf.rb
creating Makefile
current directory: C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/json-2.0.2/ext/json/ext/generator
make "DESTDIR=" clean
current directory: C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/json-2.0.2/ext/json/ext/generator
make "DESTDIR="
generating generator-x64-mingw32.def
compiling generator.c
make: x86_64-w64-mingw32-gcc: Command not found
make: *** [generator.o] Error 127
make failed, exit code 2
Gem files will remain installed in C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/json-2.0.2 for inspection.
Results logged to C:/tools/ruby23/lib/ruby/gems/2.3.0/extensions/x64-mingw32/2.3.0/json-2.0.2/gem_make.out
Updating psych
Building native extensions. This could take a while...
ERROR: Error installing psych:
ERROR: Failed to build gem native extension.
current directory: C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/psych-2.2.2/ext/psych
C:/tools/ruby23/bin/ruby.exe -r ./siteconf20170106-4004-1rx9fhh.rb extconf.rb
checking for yaml.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=C:/tools/ruby23/bin/$(RUBY_BASE_NAME)
--with-libyaml-dir
--without-libyaml-dir
--with-libyaml-include
--without-libyaml-include=${libyaml-dir}/include
--with-libyaml-lib
--without-libyaml-lib=${libyaml-dir}/lib
--enable-bundled-libyaml
--disable-bundled-libyaml
C:/tools/ruby23/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 C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:587:in `try_cpp'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:1144:in `block in find_header'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
from C:/tools/ruby23/lib/ruby/2.3.0/mkmf.rb:1143:in `find_header'
from extconf.rb:10:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
C:/tools/ruby23/lib/ruby/gems/2.3.0/extensions/x64-mingw32/2.3.0/psych-2.2.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/psych-2.2.2 for inspection.
Results logged to C:/tools/ruby23/lib/ruby/gems/2.3.0/extensions/x64-mingw32/2.3.0/psych-2.2.2/gem_make.out
Gems updated: bigdecimal did_you_mean io-console json psych
i realy can't understand what is happen, any idea?
tl;dr - you should install ruby2.devkit instead.
In https://stackoverflow.com/a/41511890/18475 answer, it says that the ruby.devkit package is out of date. It's not, it just applies to a different Ruby.
Incorrect Package
You maybe missed this from https://chocolatey.org/packages/ruby.devkit:
As opposed to Ruby v2 DevKit (https://chocolatey.org/packages/ruby2.devkit):
You installed the incorrect package - https://chocolatey.org/packages/ruby2.devkit is the one you are looking for.
The compiler changed for Ruby v2+ for Ruby on Windows, which means you need to use the proper compilers. That DevKit is in the ruby2.devkit package.
Don't Forget to Refresh Your Environment
If you are using Chocolatey, you get refreshenv as a command you can call in cmd.exe or powershell.exe (With PowerShell, be sure you have tab completion in your profile so that the proper refreshenv is available).
Otherwise you will need to close and reopen your shell for the updated PATHs to happen.
More Details
Head out to http://rubyinstaller.org/downloads/:
More Fun With Ruby
Here's a gist that does a complete Ruby stack setup: https://gist.github.com/ferventcoder/947479688d930e28d632
It's a bit outdated, so here is an update (PowerShell):
# https://github.com/chocolatey/choco/wiki/CommandsReference#how-to-pass-options--switches
# Powershell specific argument passing
# You must be on the latest beta of chocolatey for this to work properly (redownload files)
choco upgrade chocolatey -y
$originalPath = $env:PATH
choco install ruby --version 2.1.8 -my -x86 --install-arguments '/verysilent /dir=""c:\tools\ruby21"" /tasks=""assocfiles""' --override-arguments
choco install ruby --version 2.1.8 -fmy --install-arguments '/verysilent /dir=""c:\tools\ruby21-x64"" /tasks=""assocfiles""' --override-arguments
choco install ruby --version 2.3.1 -my -x86 --install-arguments '/verysilent /dir=""c:\tools\ruby23"" /tasks=""assocfiles""' --override-arguments
choco install ruby --version 2.3.1 -fmy --install-arguments '/verysilent /dir=""c:\tools\ruby23-x64"" /tasks=""assocfiles,modpath""' --override-arguments
Write-Output "Attempting Good DevKit2 Installations"
# DevKit for Ruby 2.x x64
$env:PATH=$originalPath
choco install ruby2.devkit -y
Move-Item c:\tools\DevKit2 C:\tools\DevKit2-x64 -Force -EA Continue
# DevKit for Ruby 2.x x86
choco install ruby2.devkit -y -x86 -f
Write-Output "Fixing DevKit Installations"
#"
---
- c:/tools/ruby21
- c:/tools/ruby23
"# | Out-File c:\tools\DevKit2\config.yml -Force -Encoding UTF8
pushd c:\tools\DevKit2
ruby dk.rb install -f
popd
#"
---
- c:/tools/ruby21-x64
- c:/tools/ruby23-x64
"# | Out-File c:\tools\DevKit2-x64\config.yml -Force -Encoding UTF8
pushd c:\tools\DevKit2-x64
ruby dk.rb install -f
popd
choco install pik -y
cmd /c C:\tools\pik\pik.bat add c:\tools\ruby21\bin
cmd /c C:\tools\pik\pik.bat add c:\tools\ruby21-x64\bin
cmd /c C:\tools\pik\pik.bat add c:\tools\ruby23\bin
cmd /c C:\tools\pik\pik.bat add c:\tools\ruby23-x64\bin
The important part in the error messages is:
The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
In order to install compiled gems, you need a compiler installed. For Windows, you can install the Ruby DeveloperKit.
While you have it installed apparently, it doesn't seem to be recognized. This can have one of various reasons, the most common being the devkit not matching your ruby version or issues with the %PATH.

Installing Hpricot on Ruby 1.9.1 on Windows

I am trying to install hpricot using the command:
>gem install hpricot -v 0.8.2
Building native extensions. This could take a while...
ERROR: Error installing hpricot:
ERROR: Failed to build gem native extension.
C:/Ruby19/bin/ruby.exe extconf.rb
checking for stdio.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=C:/Ruby19/bin/ruby
C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:362:in try_do': The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:431:intry_cpp'
from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:809:in block in have_header'
from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:668:inblock in checking_for'
from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:274:in block (2 levels) in postpone'
from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:248:inopen'
from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:274:in block in postpone'
from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:248:inopen'
from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:270:in postpone'
from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:667:inchecking_for'
from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:808:in have_header'
from extconf.rb:2:in'
Gem files will remain installed in C:/Ruby19/lib/ruby/gems/1.9.1/gems/hpricot-0.8.2 for inspection.
Results logged to C:/Ruby19/lib/ruby/gems/1.9.1/gems/hpricot-0.8.2/ext/fast_xs/gem_make.out
it mentions I need to install "development tools" but I have no idea what that refers to. Any suggestions?
Try:
gem install hpricot --platform=mswin32
Install the devkit at rubyinstaller.org/downloads
Execute below command and it works:
gem install hpricot --platform=mswin32
An additional note that others may find useful, from my recent attempt to install on Windows using the Ruby devkit:
To install the devkit, you extract the bin and devkit directories to your Ruby directory which will place a few files in your Ruby bin and a devkit directory in your Ruby directory. Then, per the instructions, you set the proper location for mingw in the fstab file.
In my case, some gems, namely Hpricot and Ruby-Debug19, would not install on my system even with the devkit installed properly because of an error creating the makefile. I ended up installing the latest version of mingw separately from SourceForge, then changed the fstab file within the "ruby19/devkit/msys/1.0.11/etc" directory to point to the directory where I installed mingw. Both gems then installed correctly.
Execute the following command:
gem install hpricot

Resources