2014-10-28 83 views
13

我一直在谷歌上搜索下面這個錯誤,但我解決不了這個錯誤:Ruby on Rails的 - 捆綁時的錯誤安裝

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    /usr/bin/ruby2.1 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 /home/dyego/.bundler/tmp/9200/gems/sqlite3-1.3.9 for inspection. 
Results logged to /home/dyego/.bundler/tmp/9200/extensions/x86_64-linux/2.1.0/sqlite3-1.3.9/gem_make.out 
An error occurred while installing sqlite3 (1.3.9), and Bundler cannot continue. 
Make sure that `gem install sqlite3 -v '1.3.9'` succeeds before bundling. 
     run bundle exec spring binstub --all 
/usr/lib/ruby/vendor_ruby/bundler/resolver.rb:296:in `resolve': Could not find gem 'sqlite3 (>= 0) ruby' in the gems available on this machine. (Bundler::GemNotFound) 
    from /usr/lib/ruby/vendor_ruby/bundler/resolver.rb:168:in `start' 
    from /usr/lib/ruby/vendor_ruby/bundler/resolver.rb:129:in `block in resolve' 
    from /usr/lib/ruby/vendor_ruby/bundler/resolver.rb:128:in `catch' 
    from /usr/lib/ruby/vendor_ruby/bundler/resolver.rb:128:in `resolve' 
    from /usr/lib/ruby/vendor_ruby/bundler/definition.rb:179:in `resolve' 
    from /usr/lib/ruby/vendor_ruby/bundler/definition.rb:114:in `specs' 
    from /usr/lib/ruby/vendor_ruby/bundler/definition.rb:159:in `specs_for' 
    from /usr/lib/ruby/vendor_ruby/bundler/definition.rb:148:in `requested_specs' 
    from /usr/lib/ruby/vendor_ruby/bundler/environment.rb:18:in `requested_specs' 
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:13:in `setup' 
    from /usr/lib/ruby/vendor_ruby/bundler.rb:120:in `setup' 
    from /usr/lib/ruby/vendor_ruby/bundler/setup.rb:17:in `<top (required)>' 
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require' 
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require' 

所以我GOOGLE了這個錯誤:

mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

和我有這樣一個有些類似的問題: Error while installing json gem 'mkmf.rb can't find header files for ruby'

但我已經安裝了Ruby-dev的:

sudo apt-get install ruby-dev 
Reading package lists... Done 
Building dependency tree  
Reading state information... Done 
ruby-dev is already the newest version. 
0 upgraded, 0 newly installed, 0 to remove and 72 not upgraded. 

我真的很努力地解決這個問題(即使它看起來很簡單)。

+0

你試過安裝'sudo apt-get install ruby​​2.1-dev'嗎? – Alireza 2014-10-28 17:23:43

+0

運行'gem install sqlite3 -v'1.3.9''時會發生什麼? – Anthony 2014-10-28 17:26:59

+2

使用'rvm'。不要把Ruby放到你的環境中,因爲你可能會在你的項目中使用不同版本的Rubies。 – blelump 2014-10-28 17:28:10

回答

38

嘗試安裝ruby-dev庫你的Ruby版本,這是2.1

$ sudo apt-get install ruby2.1-dev 
+2

如果你懶惰,它不是一個生產系統,只需安裝'ruby-dev'也可以。是的,我意識到我爲這個評論付出了更多的努力,而不是爲了輸入版本特異性所需的額外3個字符。我責怪社會。 – 2015-08-12 01:06:41

+0

現在應該是'ruby-2.3-dev'。如果您使用的是基於Debian的發行版(例如Ubuntu,Mint),則可以通過運行'apt-cache search「ruby。* - dev」'來計算軟件包名稱。 – einpoklum 2017-01-28 13:07:58

3

嘗試安裝指南針SASS開發時對Fedora的類似錯誤

gem install compass 

失敗,

構建原生擴展。這可能需要一段時間... 錯誤:安裝指南針時出錯: 錯誤:無法生成gem原生擴展。

在/ usr/bin中/紅寶石extconf.rb在/usr/share/include/ruby.h

mkmf.rb找不到紅寶石頭文件冉這個

yum -y install gcc ruby-devel rubygems 

和然後能夠再次成功運行安裝。

+0

執行'yum -y install ruby​​-devel'時,我得到'沒有package ruby​​-devel available.'。 是否有更新的軟件包可以安裝? – 2016-01-14 00:17:13

+0

這是我嘗試安裝指南針時幫助我的答案。但是,rubygems是沒有必要的。我只是用sudo yum安裝ruby-devel gcc -y – 2016-06-16 04:11:27