其他分享
首页 > 其他分享> > 安装sass时遇到Failed to build gem native extension

安装sass时遇到Failed to build gem native extension

作者:互联网

错误信息

执行命令: sudo gem install sass时遇到下面的错误信息

Building native extensions. This could take a while...
ERROR:  Error installing sass:
    ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.5.0/gems/ffi-1.11.1/ext/ffi_c
/usr/bin/ruby2.5 -r ./siteconf20190522-24821-9c6o4.rb 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 /var/lib/gems/2.5.0/gems/ffi-1.11.1 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/ffi-1.11.1/gem_make.out

解决

看了网上的一些解决方案,最后通过装的完整ruby解决的。

原先安装ruby用的命令是: sudo apt install ruby

改用命令sudo apt install ruby-full安装ruby,然后再用命令sudo gem install sass成功安装sass。

题外话:

更换gem的安装源

//1.删除原gem源
gem sources --remove https://rubygems.org/

//2.添加国内镜像
gem source -a https://gems.ruby-china.com

//3.打印是否替换成功
gem sources -l

//4.更换成功后打印如下
*** CURRENT SOURCES ***
 https://gems.ruby-china.com

标签:gems,extension,sass,Failed,2.5,ffi,ruby,gem
来源: https://www.cnblogs.com/youpeng/p/11446078.html