openSUSE 安装compass,mkmf.rb can't find,checking for ffi.h...extconf.rb failed

Posted wakasann

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了openSUSE 安装compass,mkmf.rb can't find,checking for ffi.h...extconf.rb failed相关的知识,希望对你有一定的参考价值。

安装compass时,提示

Fetching: sass-3.4.23.gem (100%)
Successfully installed sass-3.4.23
Fetching: ffi-1.9.18.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing compass:
    ERROR: Failed to build gem native extension.

    current directory: /usr/lib64/ruby/gems/2.1.0/gems/ffi-1.9.18/ext/ffi_c
/usr/bin/ruby.ruby2.1 -r ./siteconf20170501-19647-33n3uw.rb extconf.rb
mkmf.rb cant find header files for ruby at /usr/lib64/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /usr/lib64/ruby/gems/2.1.0/gems/ffi-1.9.18 for inspection.
Results logged to /usr/lib64/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0/ffi-1.9.18/gem_make.out

找资料有说明是缺少mkmf,而mkmf是存在于ruby dev开发包中的,需要安装 ruby1.9.1-dev版本,可是笔者的电脑中ruby的版本是:ruby 2.1.9p490 (2016-03-30 revision 54437) [x86_64-linux-gnu]

可以通过zypper search命令查看相关的ruby安装包

运行: zypper search ruby*

会列出和ruby相关的软件包,在列表中有:

i | ruby2.1                                                 | An In-> | 软件包  
  | ruby2.1                                                 | An In-> | 源代码包
  | ruby2.1-devel                                           | Devel-> | 软件包  

-dev和-devel 后缀应该都属于开发包,所以笔者运行了: zypper in ruby2.1-devel 

运行的结果是:新安装ruby2.1-devel 和升级libruby2_1-2_1 ruby2.1 ruby2.1-stdlib 3个软件包

再次尝试运行: gem install compass,提示

ERROR:  Error installing compass:
    ERROR: Failed to build gem native extension.

    current directory: /usr/lib64/ruby/gems/2.1.0/gems/ffi-1.9.18/ext/ffi_c
/usr/bin/ruby.ruby2.1 -r ./siteconf20170501-19967-1fry11r.rb extconf.rb
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

这提示的是缺少 ffi

在上面执行的:zypper serch ruby* 命令的搜索结果中有:

  | ruby2.1-rubygem-fastercsv-testsuite                     | Test -> | 软件包  
  | ruby2.1-rubygem-ffi                                     | Ruby -> | 软件包  
  | ruby2.1-rubygem-ffi-doc                                 | RDoc -> | 软件包

运行: zypper in ruby2.1-rubygem-ffi


最后执行: gem install compass之后,安装成功,暂时还不能直接运行compass命令,因为执行时,提示

If compass is not a typo you can use command-not-found to lookup the package that contains it, like this:
    cnf compass

 

参考资料:

  1. zypper命令使用示例
  2. linux下各种*-dev或*-devel包的作用
  3. 安装compass时出现ERROR: Failed to build gem native extension...... -- mkmf (Load Error)解决办法

以上是关于openSUSE 安装compass,mkmf.rb can't find,checking for ffi.h...extconf.rb failed的主要内容,如果未能解决你的问题,请参考以下文章

Windows MongoDB - 已安装的Compass但在系统中找不到Compass

无法构建 gem 原生扩展(安装 Compass)

由于版本冲突,无法安装 sass + compass + susy

compass安装教程

ruby镜像报错,compass安装报错

Sass 的安装