我使用的是Ubuntu 14.04
我尝试了这个命令sudo gem install compass
,但它给了我这个错误:
Fetching: multi_json-1.11.2.gem (100%)
Fetching: compass-core-1.0.3.gem (100%)
Fetching: compass-import-once-1.0.5.gem (100%)
Fetching: chunky_png-1.3.5.gem (100%)
Fetching: rb-fsevent-0.9.6.gem (100%)
Fetching: ffi-1.9.10.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing compass:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:4:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/ffi-1.9.10 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/ffi-1.9.10/ext/ffi_c/gem_make.out
我正在使用的 ruby 版本ruby 1.9.3p484
我也尝试使用安装 ruby2.0sudo apt-get install ruby2.0
甚至提供了相同的错误
检查了这些 stackoverflow 问题这里。他们没有提供我需要的答案。大多数答案都是针对 Mac 操作系统的
答案1
您也可以尝试仅安装 ruby-dev 包:
sudo apt-get install ruby-dev
答案2
下载最新版本的ruby这里。
执行以下命令(也出现在上面的 url 中):
curl -sSL https://get.rvm.io | bash -s stable --ruby
然后执行rvm -v
:
rvm 1.26.11 (latest) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
和ruby -v
:
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]
然后执行gem install compass
就像一个魅力