安装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 can't 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
参考资料: