Attempt 1: Installation from outside ruby app directory
Fresh Vagrant install and it doesn’t work:
$ bundle install --path=/var/ruby/test/ --gemfile=/var/ruby/test/Gemfile
Fetching gem metadata from https://rubygems.org/.........
Using bundler 1.16.3
Fetching daemons 1.2.6
Installing daemons 1.2.6
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: /var/ruby/test/ruby/2.3.0/gems/eventmachine-1.2.7/ext
/home/vagrant/.rvm/rubies/ruby-2.3.1/bin/ruby -r ./siteconf20180805-18844-1r8x9rm.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=/home/vagrant/.rvm/rubies/ruby-2.3.1/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
/home/vagrant/.rvm/rubies/ruby-2.3.1/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 /home/vagrant/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/mkmf.rb:541:in `try_link0'
from /home/vagrant/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/mkmf.rb:556:in `try_link'
from /home/vagrant/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/mkmf.rb:657:in `try_ldflags'
from /home/vagrant/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/mkmf.rb:1813:in `pkg_config'
from extconf.rb:65:in `pkg_config_wrapper'
from extconf.rb:92:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/ruby/test/ruby/2.3.0/extensions/x86_64-linux/2.3.0/eventmachine-1.2.7/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /var/ruby/test/ruby/2.3.0/gems/eventmachine-1.2.7 for inspection.
Results logged to /var/ruby/test/ruby/2.3.0/extensions/x86_64-linux/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:
thin was resolved to 1.7.2, which depends on
eventmachine
Attempt 2: Installation from app directory
Fresh Vagrant installation, and it works!
$ cd /var/ruby/test/
$ bundle install
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Using bundler 1.16.3
Fetching daemons 1.2.6
Installing daemons 1.2.6
Fetching eventmachine 1.2.7
Installing eventmachine 1.2.7 with native extensions
Fetching mustermann 1.0.2
Installing mustermann 1.0.2
Fetching rack 2.0.5
Installing rack 2.0.5
Fetching rack-protection 2.0.3
Installing rack-protection 2.0.3
Fetching tilt 2.0.8
Installing tilt 2.0.8
Fetching sinatra 2.0.3
Installing sinatra 2.0.3
Fetching thin 1.7.2
Installing thin 1.7.2 with native extensions
Bundle complete! 2 Gemfile dependencies, 9 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Question
How can I bundle install
from outside the ruby app directory?
Environment:
Single-user rvm installation on CentOS 7 Vagrant box:
$ cat /etc/centos-release
CentOS Linux release 7.5.1804 (Core)
$ uname -a
Linux localhost.localdomain 3.10.0-862.2.3.el7.x86_64 #1 SMP Wed May 9 18:05:47 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ rpm -qa | grep openssl
openssl-libs-1.0.2k-12.el7.x86_64
openssl-devel-1.0.2k-12.el7.x86_64
openssl-1.0.2k-12.el7.x86_64
$ rvm list
=* ruby-2.3.1 [ x86_64 ]
UPDATE 1
Contents of eventmachine-1.2.7/mkmf.log
:
$ cat /var/ruby/test/ruby/2.3.0/extensions/x86_64-linux/2.3.0/eventmachine-1.2.7/mkmf.log
# I ADDED NEWLINES FOR READABILITY – THIS WAS A ONE-LINE STRING WHEN OUTPUT TO THE CONSOLE:
"gcc -o conftest
-I/home/vagrant/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-linux
-I/home/vagrant/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward
-I/home/vagrant/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0 -I.
-O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter
-Wno-parentheses -Wno-long-long -Wno-missing-field-initializers
-Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement
-Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
-fPIC conftest.c -L.
-L/home/vagrant/.rvm/rubies/ruby-2.3.1/lib -Wl,-R/home/vagrant/.rvm/rubies/ruby-2.3.1/lib -L.
-fstack-protector -rdynamic -Wl,-export-dynamic
-Wl,-rpath,'/../lib' -Wl,-R'/../lib' -lruby -lpthread -ldl -lcrypt -lm -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
| pkg-config --libs openssl
=> "-lssl -lcrypto \n"
Note: I also had the same exact issue when trying to install the puma
gem; the installation would fail when puma started installation "with native extensions". At first, I thought it was puma, but now I believe it’s a bundler (perhaps rvm?) issue.
UPDATE 2
Contents of gem_make.out
:
$ cat /var/ruby/test/ruby/2.3.0/extensions/x86_64-linux/2.3.0/eventmachine-1.2.7/gem_make.out
current directory: /var/ruby/test/ruby/2.3.0/gems/eventmachine-1.2.7/ext
/home/vagrant/.rvm/rubies/ruby-2.3.1/bin/ruby -r ./siteconf20180806-22205-1cnr9v9.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=/home/vagrant/.rvm/rubies/ruby-2.3.1/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
/home/vagrant/.rvm/rubies/ruby-2.3.1/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 /home/vagrant/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/mkmf.rb:541:in `try_link0'
from /home/vagrant/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/mkmf.rb:556:in `try_link'
from /home/vagrant/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/mkmf.rb:657:in `try_ldflags'
from /home/vagrant/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/mkmf.rb:1813:in `pkg_config'
from extconf.rb:65:in `pkg_config_wrapper'
from extconf.rb:92:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/ruby/test/ruby/2.3.0/extensions/x86_64-linux/2.3.0/eventmachine-1.2.7/mkmf.log
extconf failed, exit code 1
I did find this related issue comment, which motivated me to do this:
sudo yum install -y ruby-devel
# … and then:
$ rpm -qa | grep ruby
ruby-libs-2.0.0.648-33.el7_4.x86_64
rubygem-psych-2.0.0-33.el7_4.x86_64
rubygem-rdoc-4.0.0-33.el7_4.noarch
ruby-irb-2.0.0.648-33.el7_4.noarch
rubygem-json-1.7.7-33.el7_4.x86_64
rubygem-io-console-0.4.2-33.el7_4.x86_64
ruby-2.0.0.648-33.el7_4.x86_64
ruby-devel-2.0.0.648-33.el7_4.x86_64
rubygem-bigdecimal-1.2.0-33.el7_4.x86_64
rubygems-2.0.14.1-33.el7_4.noarch
# … and then:
$ bundle install --path=/var/ruby/test/ --gemfile=/var/ruby/test/Gemfile
Yet I still get the same error:
Installing eventmachine 1.2.7 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.