如何解决 centos6 中 gem install foo 失败的问题

2014-03-05 17:40:43 +08:00
 ioiioi
我在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...
Exception `Gem::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。
4635 次点击
所在节点    Ruby on Rails
1 条回复
ioiioi
2014-03-05 18:10:43 +08:00
我找到原因了:
# yum -y install ruby-devel
然后
gem install fpm
就可以了。

虽然我执行了:

# gem sources --remove http://ruby.taobao.org/
# gem sources -a https://rubygems.org/
但是,我觉得不是repos的问题。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/102993

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX