更新:我运行sudo yum install ruby-devel
,然后sudo gem install mechanize
,这给了我这个错误:
ERROR: Error installing mechanize:
ERROR: Failed to build gem native extension.
/usr/bin/ruby2.0 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}/lib64
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby2.0
--with-static-libstdc++
--without-static-libstdc++
--with-stdc++lib
--without-stdc++lib
/usr/share/ruby/2.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/share/ruby/2.0/mkmf.rb:519:in `try_link0'
from /usr/share/ruby/2.0/mkmf.rb:534:in `try_link'
from /usr/share/ruby/2.0/mkmf.rb:720:in `try_func'
from /usr/share/ruby/2.0/mkmf.rb:950:in `block in have_library'
from /usr/share/ruby/2.0/mkmf.rb:895:in `block in checking_for'
from /usr/share/ruby/2.0/mkmf.rb:340:in `block (2 levels) in postpone'
from /usr/share/ruby/2.0/mkmf.rb:310:in `open'
from /usr/share/ruby/2.0/mkmf.rb:340:in `block in postpone'
from /usr/share/ruby/2.0/mkmf.rb:310:in `open'
from /usr/share/ruby/2.0/mkmf.rb:336:in `postpone'
from /usr/share/ruby/2.0/mkmf.rb:894:in `checking_for'
from /usr/share/ruby/2.0/mkmf.rb:945:in `have_library'
from extconf.rb:6:in `<main>'
Gem files will remain installed in /usr/local/share/ruby/gems/2.0/gems/unf_ext-0.0.7.2 for inspection.
Results logged to /usr/local/share/ruby/gems/2.0/gems/unf_ext-0.0.7.2/ext/unf_ext/gem_make.out
原文如下:
当我在我的Amazon AWS Linux虚拟机上运行sudo gem install mechanize
时,出现此错误:
ERROR: Error installing mechanize:
ERROR: Failed to build gem native extension.
/usr/bin/ruby2.0 extconf.rb
mkmf.rb can't find header files for ruby at /usr/share/ruby/include/ruby.h
Gem files will remain installed in /usr/local/share/ruby/gems/2.0/gems/unf_ext-0.0.7.2 for inspection.
Results logged to /usr/local/share/ruby/gems/2.0/gems/unf_ext-0.0.7.2/ext/unf_ext/gem_make.out
当我运行yum install ruby-dev
时,我收到此消息:
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main/latest | 2.1 kB 00:00
amzn-updates/latest | 2.3 kB 00:00
No package ruby-dev available.
Error: Nothing to do
我想在这台机器上安装Ruby gem Mechanize。我该怎么做才能实现这一目标?
答案 0 :(得分:1)
我必须先安装一堆软件包。
sudo yum install zlib-devel gcc gcc-c++ ruby-devel rubygems
然后:
sudo gem install mechanize