V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
ioiioi
V2EX  ›  Ruby on Rails

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

  •  
  •   ioiioi · 2014-03-05 17:40:43 +08:00 · 4635 次点击
    这是一个创建于 3901 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我在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。
    1 条回复    1970-01-01 08:00:00 +08:00
    ioiioi
        1
    ioiioi  
    OP
       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的问题。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2786 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 14:05 · PVG 22:05 · LAX 06:05 · JFK 09:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.