ruby on rails 安装 JSON ubuntu 错误

ruby on rails installing JSON ubuntu error

提问人:Jakxna360 提问时间:12/1/2012 更新时间:11/12/2015 访问量:2261

问:

嘿,我是 rails(以及 linux)的新手,我一直收到这个错误:

Installing json (1.7.5) 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/jack/.bundler/tmp/10426/gems/json-1.7.5 for inspection.
Results logged to /home/jack/.bundler/tmp/10426/gems/json-1.7.5/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.7.5), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.5'` succeeds before bundling.
jack@jack-ThinkCentre:~/rails_projects/sample_app$ 

我无法单独安装gem或捆绑安装。我使用 rvm 来安装导轨。提前致谢。

Ruby-on-Rails 红宝石

评论

0赞 hrr 12/1/2012
当您单独尝试“gem install json”时会发生什么?
0赞 Jakxna360 12/1/2012
构建本机扩展。这可能需要一段时间......错误:安装 json 时出错:错误:无法构建 gem 本机扩展。/usr/bin/ruby1.9.1 extconf.rb /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require' from extconf.rb:1:in '<main>' Gem 文件将保留安装在 /var/lib/gems/1.9.1/gems/json-1.7.5 中以供检查。结果记录到 /var/lib/gems/1.9.1/gems/json-1.7.5/ext/json/ext/generator/gem_make.outrequire': cannot load such file -- mkmf (LoadError) from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in
0赞 hrr 12/1/2012
这是第一次使用 rails 吗?你的操作系统是什么?如果 OSX:您拥有哪个 XCode 版本 (xcodebuild -version)?
0赞 hrr 12/1/2012
尝试升级 Ruby 并重新安装 gems。
0赞 Jakxna360 12/1/2012
我收到此错误:构建本机扩展。这可能需要一段时间......错误:安装 rails 时出错:错误:无法构建 gem 原生扩展。/usr/bin/ruby1.9.1 extconf.rb /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require' from extconf.rb:1:in '<main>' Gem 文件将保留安装在 /var/lib/gems/1.9.1/gems/json-1.7.5 中以供检查。结果记录到 /var/lib/gems/1.9.1/gems/json-1.7.5/ext/json/ext/generator/gem_make.outrequire': cannot load such file -- mkmf (LoadError) from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in

答:

10赞 Gowri Naidu R 12/1/2012 #1

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

sudo apt-get install ruby1.9.1-dev
2赞 Leopold 11/12/2015 #2

“在运行 ruby 2.2.3 的 ubuntu-trusty-64 上存在同样的问题。解决方案是安装 libgmp3-dev。

sudo apt-get install libgmp3-dev