Failed to build gem native extension encountered while installing sass

error message

sudo gem install sass encountered the following error message

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

solution

looked at some of the solutions on the web, and finally solved by installing the full ruby.

: sudo apt install ruby

use the command sudo apt install ruby-full to install ruby, and then use the command sudo gem install sass to successfully install sass.

diff:

Replace the gem with the installation source

//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

Read More: