本文介绍了当我尝试sudo gem安装json时,出现以下错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要安装JSON gem来启动我的应用程序,但是当我尝试安装json gem时,我收到以下错误。谁能帮我吗。

  Arions-macbook-pro:.ssh arion $ sudo gem我使用rails 2.2.2和gems 1.3.1。安装json 
密码:
对不起,请重试。
密码:
构建原生扩展。这可能需要一段时间...
错误:安装json时出错:
错误:无法构建gem本机扩展。

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb安装json
找不到ruby的头文件。


Gem文件将被安装在/Library/Ruby/Gems/1.8/gems/json-1.1.4中进行检查。
结果记录到/Library/Ruby/Gems/1.8/gems/json-1.1.4/ext/json/ext/parser/gem_make.out


解决方案

使用Mavericks,您可以通过从命令行安装Xcode命令行工具来解决此问题:



xcode-select --install



更新:
安装或更新后不要忘记接受许可协议:

sudo xcodebuild -license


I need to install the JSON gem to start my app but I get the error below whenever I try to install the json gem. Can anyone help me out. I'm using rails 2.2.2 and gems 1.3.1.

Arions-macbook-pro:.ssh arion$ sudo gem install json
Password:
Sorry, try again.
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing json:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install json
can't find header files for ruby.


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/json-1.1.4 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/json-1.1.4/ext/json/ext/parser/gem_make.out
解决方案

With Mavericks, you can solve this problem by installing the Xcode Command Line Tools from the command line like this:

xcode-select --install

Update:Don't forget to accept the license agreement after you install or update:

sudo xcodebuild -license

这篇关于当我尝试sudo gem安装json时,出现以下错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 23:57