Gem :: Ext :: BuildError:错误:无法为rails版本4.2.6构建gem本机扩展

时间:2017-07-04 08:53:38

标签: ruby-on-rails ruby ruby-on-rails-3 rubygems

我创建了新的rails应用并试图运行捆绑安装它显示此错误,

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/json-1.8.6/ext/json/ext/generator/usr/bin/ruby2.3 -r ./siteconf20170704-11395-12tpg5u.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/json-1.8.6 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/json-1.8.6/gem_make.out

An error occurred while installing json (1.8.6), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.6'` succeeds before bundling

请寄给我一些建议,先谢谢。

3 个答案:

答案 0 :(得分:16)

如果您有Mac或Linux计算机,请尝试以下命令:

sudo apt-get install ruby-dev

如果失败,您的输出是什么:

gem install json -v '1.8.6'

(请复制并粘贴所有输出)。

Similar issue

答案 1 :(得分:0)

首先检查 ruby​​ 版本和 rvm 列表 如果 rvm 未安装,请安装 rvm

答案 2 :(得分:0)

如果任何人在Mac OS Big Sur上遇到此错误,请将ruby版本更新为至少2.7。我正在使用rvm解决此问题。