在rails上安装ruby时出错,无法构建gem原生扩展

时间:2015-07-18 07:30:28

标签: ruby-on-rails ruby linux

尝试在我的linux mint中安装rails时出现以下错误:

sudo gem install rails
Fetching: activesupport-4.2.3.gem (100%)
Successfully installed activesupport-4.2.3
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

    /usr/bin/ruby2.2 -r ./siteconf20150718-15613-1wed0b4.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.2.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /var/lib/gems/2.2.0/extensions/x86_64-linux/2.2.0/nokogiri-1.6.6.2/gem_make.out

这是我的红宝石版本:

shafaet@shafaet-HP-ProBook ~ $ ruby -version
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux-gnu]
-e:1:in `<main>': undefined local variable or method `rsion' for main:Object (NameError)

非常感谢任何帮助,谢谢。

1 个答案:

答案 0 :(得分:2)

我相信没有安装ruby开发环境。编译ruby扩展需要开发环境。您可以运行以下命令:

sudo apt-get install ruby2.2-dev # as you're using the 2.2 version