无法构建gem原生扩展

无法构建gem原生扩展

本文介绍了无法构建gem原生扩展 - Rails安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经根据edX online class的指令安装了Ruby on Rails。



这是一个终端命令列表,以及相关的输出:

  $ sudo apt-get install ruby​​1.9.1 

安装成功

  $ wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.24.tgz 
$ tar zxvf ruby​​-1.8.24.tgz
$ cd ruby​​-1..8.24
$ sudo ruby​​ setup.rb
安装了RubyGems 1.8.24

== 1.8.24 / 2012-04-27

* 1错误修复:

*正确安装.pem文件。修复#320
*从http代码路径中删除OpenSSL依赖项


---------------------- -------------------------------------------------- ------

RubyGems安装了以下可执行文件:
/usr/bin/gem1.9.1

到这里,一切看起来都不错,但我试图安装rails并失败:

  $ sudo gem install rails 
提取:i18n-0.6.1.gem(100%)
提取:multi_json-1.3.6.gem(100%)
提取:activesupport-3.2.8.gem(100%)
提取:builder-3.0.3.gem(100%)
提取:activemodel-3.2.8.gem(100%)
提取:rack-1.4.1.gem(100%)
提取:rack-cache-1.2.gem(100%)
提取:rack-test-0.6.1.gem 100%)
提取:journey-1.0.4.gem(100%)
提取:hike-1.2.1.gem(100%)
提取:tilt-1.3.3.gem (100%)
提取:sprockets-2.1.3.gem(100%)
提取:erubis-2.7.0.gem(100%)
提取:actio npack-3.2.8.gem(100%)
提取:arel-3.0.2.gem(100%)
提取:tzinfo-0.3.33.gem(100%)
提取:activerecord-3.2.8.gem(100%)
提取:activeresource-3.2.8.gem(100%)
提取:mime-types-1.19.gem(100%)
提取:polyglot-0.3.3.gem(100%)
提取:treetop-1.4.10.gem(100%)
提取:mail-2.4.4.gem(100%)
提取:actionmailer-3.2.8.gem(100%)
提取:rake-0.9.2.2.gem(100%)
提取:rack-ssl-1.3.2.gem(100%)
提取:thor-0.16.0.gem(100%)
提取:json-1.7.5.gem(100%)
构建原生扩展。这可能需要一段时间...
错误:安装rails出错:
错误:无法构建gem本机扩展。

/usr/bin/ruby1.9.1 extconf.rb
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in`require':can not加载这样的文件 - mkmf(LoadError)
from /usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in`require'
from extconf.rb:1:在`< main>'


中,Gem文件将保留安装在/usr/lib/ruby/gems/1.9.1/gems/json-1.7.5中进行检查。
结果记录到/usr/lib/ruby/gems/1.9.1/gems/json-1.7.5/ext/json/ext/generator/gem_make.out


解决方案 mkmf 是<$ c $的一部分c> ruby​​1.9.1-dev 包。该软件包包含Ruby 1.9.1扩展库所需的头文件。您需要安装 ruby​​1.9.1-dev 包:

  sudo apt-get install ruby​​1.9.1-dev 

然后,您可以像平常一样安装Rails。 / p>

一般来说,做起来容易:

  sudo apt-get install ruby-dev 


I have been installing Ruby on Rails based on the instruction from edX online class.

Here is a list of terminal commands, and, where relevant, corresponding output:

$ sudo apt-get install ruby1.9.1

installation successful

$ wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.24.tgz
$ tar zxvf ruby-1.8.24.tgz
$ cd ruby-1..8.24
$ sudo ruby setup.rb
RubyGems 1.8.24 installed

== 1.8.24 / 2012-04-27

* 1 bug fix:

  * Install the .pem files properly. Fixes #320
  * Remove OpenSSL dependency from the http code path


------------------------------------------------------------------------------

RubyGems installed the following executables:
    /usr/bin/gem1.9.1

Up to here, everything looked fine, but the I tried to install rails and failed:

$ sudo gem install rails
Fetching: i18n-0.6.1.gem (100%)
Fetching: multi_json-1.3.6.gem (100%)
Fetching: activesupport-3.2.8.gem (100%)
Fetching: builder-3.0.3.gem (100%)
Fetching: activemodel-3.2.8.gem (100%)
Fetching: rack-1.4.1.gem (100%)
Fetching: rack-cache-1.2.gem (100%)
Fetching: rack-test-0.6.1.gem (100%)
Fetching: journey-1.0.4.gem (100%)
Fetching: hike-1.2.1.gem (100%)
Fetching: tilt-1.3.3.gem (100%)
Fetching: sprockets-2.1.3.gem (100%)
Fetching: erubis-2.7.0.gem (100%)
Fetching: actionpack-3.2.8.gem (100%)
Fetching: arel-3.0.2.gem (100%)
Fetching: tzinfo-0.3.33.gem (100%)
Fetching: activerecord-3.2.8.gem (100%)
Fetching: activeresource-3.2.8.gem (100%)
Fetching: mime-types-1.19.gem (100%)
Fetching: polyglot-0.3.3.gem (100%)
Fetching: treetop-1.4.10.gem (100%)
Fetching: mail-2.4.4.gem (100%)
Fetching: actionmailer-3.2.8.gem (100%)
Fetching: rake-0.9.2.2.gem (100%)
Fetching: rack-ssl-1.3.2.gem (100%)
Fetching: thor-0.16.0.gem (100%)
Fetching: json-1.7.5.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 extconf.rb
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
    from /usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from extconf.rb:1:in `<main>'


Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/json-1.7.5 for inspection.
Results logged to /usr/lib/ruby/gems/1.9.1/gems/json-1.7.5/ext/json/ext/generator/gem_make.out
解决方案

mkmf is part of the ruby1.9.1-dev package. This package contains the header files needed for extension libraries for Ruby 1.9.1. You need to install the ruby1.9.1-dev package by doing:

sudo apt-get install ruby1.9.1-dev

Then you can install Rails as per normal.

Generally it's easier to just do:

sudo apt-get install ruby-dev

这篇关于无法构建gem原生扩展 - Rails安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 12:04