本文介绍了安装 rails 错误:无法构建 gem 本机扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 linux 操作系统有这个问题:

I have this problem on my linux OS:

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

    current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.8.1/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20171120-5536-amlck4.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.3.0/gems/nokogiri-1.8.1 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.1/gem_make.out

如何从上述日志中解决此问题?

How do I fix this issue from the above logs?

推荐答案

当我运行 sudo apt-get install ruby​​-dev zlib1g-dev liblzma-dev 我得到这些日志:

When I run sudo apt-get install ruby-dev zlib1g-dev liblzma-dev I got these logs:

build-essential patch
Reading package lists... Done
Building dependency tree
Reading state information... Done
build-essential is already the newest version (12.1ubuntu2).
patch is already the newest version (2.7.5-1).
zlib1g-dev is already the newest version (1:1.2.8.dfsg-2ubuntu4.1).
zlib1g-dev set to manually installed.
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 ruby-dev : Depends: ruby2.3-dev but it is not going to be installed
 slack-desktop : Depends: libappindicator1 but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

所以为了解决这个问题,我运行 apt-get -f install

So to solve this problem I run apt-get -f install

然后我运行 sudo apt-get install ruby​​-dev zlib1g-dev liblzma-dev 依赖就安装成功了.

Then I run sudo apt-get install ruby-dev zlib1g-dev liblzma-dev dependencies were successfully installed.

gem 原生扩展成功构建.

gem native extension successfully build.

这篇关于安装 rails 错误:无法构建 gem 本机扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 18:15