2012-09-23 126 views
70

我一直在基於edX在線類的指令安裝Ruby on Rails。無法構建gem原生擴展 - Rails安裝

這裏是終端命令的列表,並在相關的,相應的輸出:

$ sudo apt-get install ruby1.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 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 

到這裏,一切似乎都很正常,但我試圖安裝導軌和失敗:

$ 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 
+0

的可能重複[無法安裝寶石 - 無法建立寶石原生擴展 - 無法加載這樣的文件 - MKMF(LoadError)(http://stackoverflow.com/questions/13767725 /無法安裝gem-failed-to-build-gem-native-extension-can-load-such) –

回答

149

mkmfruby1.9.1-dev包。該軟件包包含Ruby 1.9.1擴展庫所需的頭文件。你需要做安裝ruby1.9.1-dev包:

sudo apt-get install ruby1.9.1-dev 

然後你就可以安裝Rails按正常。

一般來說它更容易只是做:

sudo apt-get install ruby-dev 
+0

必須編寫'sudo apt-get install ruby​​1.9.1-dev'而不是'sudo apt - 請安裝ruby1.9-dev'。否則工作得很好,謝謝。 –

+0

非常感謝兄弟!我得到了與rb-inotify依賴性問題的堅果...(帶sass -watch) – jossemarGT

+0

我已經完成了這個工作,並且仍然得到了rb-inotify問題 - sass --watch ... –

4

建議的答覆只適用於紅寶石的某些版本。一些評論者建議使用ruby-dev;那也不適合我。

sudo apt-get install ruby-all-dev 

爲我工作。

1
sudo apt-get install ruby-dev 

工作對我來說

相關問題