当前位置: 首页>>技术教程>>正文


为什么在Ubuntu中安装JSON gem时会出错?

, , , ,

问题描述

使用Ubuntu,当我运行“ bundle install”来设置我的Rails环境时,它会在JSON gem安装过程中引发错误:

Installing json (1.7.3) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb 
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from extconf.rb:1:in `<main>'

Gem files will remain installed in /home/danny/.bundler/tmp/2040/gems/json-1.7.3 for inspection.
Results logged to /home/danny/.bundler/tmp/2040/gems/json-1.7.3/ext/json/ext/parser/gem_make.out
An error occured while installing json (1.7.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.3'` succeeds before bundling.

当我尝试仅安装JSON 1.7.3 gem时,它也给我一个错误:

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

/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from extconf.rb:1:in `<main>'

Gem files will remain installed in /var/lib/gems/1.9.1/gems/json-1.7.3 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/json-1.7.3/ext/json/ext/parser/gem_make.out

我已经安装了RVM并正在运行Ruby 1.9.3;为什么它不能安装JSON gem?

最佳回答

安装ruby1.9.1-dev软件包应为您解决此问题:

sudo apt-get install ruby1.9.1-dev

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/10502.html,未经允许,请勿转载。