新的Vagrant安装无法正常工作
$ 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
新的Vagrant安装成功了!
$ 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.
如何从ruby应用程序目录之外bundle install
?
在CentOS 7 Vagrant框中安装单用户rvm:
$ 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 ]
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"
注意:我也有same exact issue when trying to install the puma
gem;当puma开始“使用本机扩展”安装时,安装将失败。起初,我以为是彪马,但现在我认为这是一个捆绑包(也许是rvm?)问题。
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
我确实找到了this related issue comment,这促使我去做:
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
但是我仍然遇到相同的错误:
Installing eventmachine 1.2.7 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.