Gem 如何在 centos6 中正确的 gem install foo?

ioiioi · 2014年03月05日 · 最后由 pynix 回复于 2014年03月05日 · 8201 次阅读

我在 centos6.4 中通过 yum -y install ruby rubygems 安装了 ruby 和 rubygems,然后再通过 gem install fpm,发现出错,google 了一圈,只找到要更换成 taobao 源的方案,于是:

gem sources --remove http://rubygems.org/

gem sources -a http://ruby.taobao.org/

gem sources -l

*** CURRENT SOURCES ***

http://ruby.taobao.org/

再然后:

gem install fpm

出现以下错误: ... Exception Errno::EEXIST' at /usr/lib/ruby/1.8/fileutils.rb:243 - File exists - /usr/lib/r uby/gems/1.8/gems/json-1.8.1/tests Building native extensions. This could take a while... ExceptionGem::InstallError' at /usr/lib/ruby/site_ruby/1.8/rubygems/ext/builder.rb:49 - extconf failed:

/usr/bin/ruby extconf.rb mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h

Exception `Gem::Installer::ExtensionBuildError' at /usr/lib/ruby/site_ruby/1.8/rubygems/in staller.rb:483 - ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h

Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/json-1.8.1 for inspection. Results logged to /usr/lib/ruby/gems/1.8/gems/json-1.8.1/ext/json/ext/generator/gem_make.o ut

ERROR: Error installing fpm: ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h

Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/json-1.8.1 for inspection. Results logged to /usr/lib/ruby/gems/1.8/gems/json-1.8.1/ext/json/ext/generator/gem_make.o ut

怎么解决?我只想装 fpm 而已。

实际上,我昨天另外一个虚拟机 debian7 中,是可以直接 gem install fpm 的,都不需要更改 sources。

看样子好像是没有头文件,估计是没有安装 ruby-devel 包

ERROR: Error installing fpm: ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h

需要 登录 后方可回复, 如果你还没有账号请 注册新账号