【问题标题】:Can't install json gem 1.8.6 - failed to build gem native extension on Ubuntu无法安装 json gem 1.8.6 - 无法在 Ubuntu 上构建 gem 本机扩展
【发布时间】:2017-11-02 08:17:42
【问题描述】:

Ubuntu 16.04 上的 Bundler 在尝试安装 JSON 时会产生以下错误。

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /tmp/bundler20170601-12986-10dsu07json-1.8.6/gems/json-1.8.6/ext/json/ext/generator
/usr/bin/ruby2.3 -r ./siteconf20170601-12986-op73sp.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 /tmp/bundler20170601-12986-10dsu07json-1.8.6/gems/json-1.8.6 for inspection.
Results logged to /tmp/bundler20170601-12986-10dsu07json-1.8.6/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.

In Gemfile:
  react-rails was resolved to 1.7.2, which depends on
    rails was resolved to 4.2.7.1, which depends on
      actionmailer was resolved to 4.2.7.1, which depends on
        actionpack was resolved to 4.2.7.1, which depends on
          actionview was resolved to 4.2.7.1, which depends on
            rails-dom-testing was resolved to 1.0.8, which depends on
              rails-deprecated_sanitizer was resolved to 1.0.3, which depends on
                activesupport was resolved to 4.2.7.1, which depends on
                  json

看起来好像由于缺少头文件而无法编译 gem 扩展。我能做什么?

【问题讨论】:

    标签: ruby-on-rails json ruby ubuntu bundler


    【解决方案1】:

    好像有similar problem on RedHat 7

    对于 Ubuntu,解决方案似乎是安装 ruby-dev 包。

    sudo apt-get install ruby-dev

    【讨论】:

      猜你喜欢
      • 2021-04-19
      • 1970-01-01
      • 2013-03-09
      • 2019-06-20
      • 1970-01-01
      • 2013-10-16
      • 2012-11-25
      • 2018-04-26
      • 2013-11-14
      相关资源
      最近更新 更多