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

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.

Related

Installing rbtrace 0.4.14 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension

This happened to me several times while trying to install Discourse:
Cannot install rbtrace with native extensions.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
*** 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=/Users/setoelka/.rbenv/versions/2.7.3/bin/$(RUBY_BASE_NAME)
extconf.rb:6:in `sys': make install failed, please report to https://github.com/tmm1/rbtrace/issues (RuntimeError)
from extconf.rb:43:in `block (2 levels) in <main>'
from extconf.rb:34:in `chdir'
from extconf.rb:34:in `block in <main>'
from extconf.rb:30:in `chdir'
from extconf.rb:30:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/setoelka/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/extensions/arm64-darwin-21/2.7.0/rbtrace-0.4.14/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/setoelka/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rbtrace-0.4.14 for inspection.
Results logged to /Users/setoelka/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/extensions/arm64-darwin-21/2.7.0/rbtrace-0.4.14/gem_make.out
An error occurred while installing rbtrace (0.4.14), and Bundler cannot continue.
Make sure that `gem install rbtrace -v '0.4.14' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
rbtrace
Does anyone know about the problem? I tried running:
gem install rbtrace -v '0.4.14' --source 'http://rubygems.org/' -- --with-cflags=-Wno-implicit-function-declaration
No luck so far.
I solved this problem by myself by looking at the mkmf.log content.
TLDR;
Use the selected Xcode with standar naming, i.e, Xcode.app.
It turned out that Ruby will compile the gem using the compiler from the default Xcode. I have multiple version of Xcodes and use the xcode-select to switch between them.
The thing is, the ruby setup will always looking for the default Xcode.app naming. If you name your selected Xcode something else, you'll get this error.

pg gem installation is giving error in Redhat

I am executing gem install pg to install the pg and execute chef scripts afterwards in Redhat AWS machine. I am getting following error:
gem install pg Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/pg-1.1.4/ext/opt/chef/embedded/bin/ruby -r ./siteconf20190924-20230-k0ngu5.rb extconf.rb
checking for pg_config... yes
Using config values from /bin/pg_config
checking for libpq-fe.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=/opt/chef/embedded/bin/$(RUBY_BASE_NAME)
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
/opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first.
from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:601:in `try_cpp'
from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:1162:in `block in find_header'
from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:959:in `block in checking_for'
from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:350:in `block (2 levels) in postpone'
from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:320:in `open'
from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:350:in `block in postpone'
from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:320:in `open'
from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:346:in `postpone'
from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:958:in `checking_for'
from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:1161:in `find_header'
from extconf.rb:54:in `<main>'
To see why this extension failed to compile, please check the mkmf.log
which can be found here:
/opt/chef/embedded/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/pg-1.1.4/mkmf.log
extconf failed, exit code 1
I am trying this with root user. I have installed postgresql-devel too using yum and tried to provide --with-pg-include too where libpq-fe.h resides (suggested in some other posts) but couldn't resolve the issue.
You first need to install build tools (i.e. a C compiler and related tools) as well as development headers for your postgres server to be able to compile the gem.
For RedHat, you should be able to get all required tools with
yum install autoconf bison flex gcc gcc-c++ gettext kernel-devel make m4 ncurses-devel patch
yum install postgresql-devel
With Chef 14, you can use the built-in build_essential resource to install the required compiler packages. On older versions, you can use the build-essential cookbook.

When attempting to install jekyll appears an error

I'm having some trouble installing jekyll. Can't quite figure out how to patch the missing link.
Heres the full post:
root#cherob:~# gem install jekyll
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
/usr/bin/ruby2.1 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=/usr/bin/ruby2.1
--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
/usr/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
from /usr/lib/ruby/2.1.0/mkmf.rb:1067:in `block in have_header'
from /usr/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
from /usr/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
from /usr/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from /usr/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
from /usr/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from /usr/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
from /usr/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
from /usr/lib/ruby/2.1.0/mkmf.rb:1066:in `have_header'
from extconf.rb:16:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.1.0/gems/ffi-1.9.18 for inspection.
Results logged to /var/lib/gems/2.1.0/extensions/x86_64-linux/2.1.0
/ffi-1.9.18/gem_make.outstrong text
Ruby is installed:
root#cherob:~# ruby -v
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
Debain 8 is installed
-
Apache2 is installed:
root#cherob:~# apache2 -v
Server version: Apache/2.4.10 (Debian)
Server built: Sep 20 2017 04:37:43
If you have an idea I would be glad if you forward me it.
Other thanks already times in advance
Robin
Such error usually means that you don't have build tools installed.
As far as I understood you are using linux, so you can run something like
apt-get install build-essential
This command is for deb-bases distros. So you can use something similar if you use a different distro.
I had the same error while installing. You will have to install des Ruby dev packacke:
sudo apt-get install ruby2.4-dev
This will install the developement package for 2.4. You should install 2.1 as you are using this version. I had the problem, that the package could not be found in the repositories. So I used the following PPA:
$ sudo apt-add-repository ppa:brightbox/ruby-ng
$ sudo apt-get update
https://launchpad.net/~brightbox/+archive/ubuntu/ruby-ng
Version 2.1 is also available in this repository.

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.

How to install sqlite3 gem on the remote server

I have a remote linux server, it does not have internet and its behind firewall. Its does not have gcc compiler. So I cant install or compile .
The linux server has got the rvm installed with ruby 1.9.3
Usually , I would install the gem on my local Mac OSX and then copy the gems to the linux server i.e ( xxxx.gem file from cache directory and xxx folder from gem directory of the ruby). So far it has been working fine. As part of the new test, I installed sqlite3 gem and copied its .gem file to the linux server and did a gem install sqlite on the linux server. It did work and got the below error
gem install sqlite3
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
/ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/bin/ruby extconf.rb
checking for sqlite3.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=/ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/bin/ruby
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib
--without-sqlite3-lib=${sqlite3-dir}/lib
--enable-local
--disable-local
/ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/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 /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:970:in `block in find_header'
from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
from /ngs/app/athenat/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/mkmf.rb:969:in `find_header'
from extconf.rb:34:in `<main>'
Gem files will remain installed in /ngs/app/athenat/.rvm/gems/ruby-1.9.3-p374#11.4.0-1/gems/sqlite3-1.3.8 for inspection.
Results logged to /ngs/app/athenat/.rvm/gems/ruby-1.9.3-p374#11.4.0-1/gems/sqlite3-1.3.8/ext/sqlite3/gem_make.out
I googled and saw many have suggested to install apt-get install libsqlite3-dev. I can't do this on my remote linux server.
Can anyone please suggest how to resolve this.
I followed few of the suggestion posted in the below post but it did not work.
Problem installing sqlite3-ruby!
sqlite3 gem fails to install
Not having a compiler is going to make this sort of thing nearly impossible.
You can't just compile for OS X and sling those binaries over to Linux. They're not the same format.
You may be able to create an environment compatible with your Linux target using a virtual environment in VMWare Fusion or VirtualBox, such as when using Vagrant, to compile for your target OS and architecture and them ship those binaries over. This is usually a last resort, as you will have to link against exactly the same libraries you have available on the remote system. To do this correctly could take a lot of time.

Resources