麻烦在我的mac上安装ruby gem json

时间:2022-09-19 00:20:03

I get this warning when trying to install the json module via ruby gems.

尝试通过ruby gems安装json模块时,我收到此警告。

Any ideas?

有任何想法吗?

Mac-Mini poulh$ sudo gem install json

Mac-Mini poulh $ sudo gem install json

Password:

密码:

WARNING: File '/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 /specifications/json-1.2.0.gemspec' does not evaluate to a gem specification

警告:文件'/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 /specifications/json-1.2.0.gemspec'未评估为gem规范

Building native extensions. This could take a while...

构建原生扩展。这可能需要一段时间......

ERROR: Error installing json:

错误:安装json时出错:

ERROR: Failed to build gem native extension.

错误:无法构建gem原生扩展。

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

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install json mkmf.rb在/System/Library/Frameworks/Ruby.framework/Versions/找不到ruby的头文件1.8 / usr / lib中/红宝石/ ruby​​.h

3 个解决方案

#1


2  

I think most Mac developers would recommend that you run your own version of ruby instead of the system version that shipped with the Mac. This will give you more control over versioning and avoid environment issues like the one you are experiencing.

我想大多数Mac开发人员会建议您运行自己的ruby版本,而不是Mac附带的系统版本。这将使您可以更好地控制版本控制,并避免出现您遇到的环境问题。

This is amazingly easy to do using the Ruby Version Manager. You can install multiple versions of ruby (1.8.6, 1.8.7, 1.9.1) and switch between them with ease. As a side-effect of using rvm, you no longer will have to use sudo to install gems.

使用Ruby Version Manager非常容易。您可以安装多个版本的ruby(1.8.6,1.8.7,1.9.1)并轻松切换它们。作为使用rvm的副作用,您不再需要使用sudo来安装gem。

#2


1  

I'm running Snow Leopard and did not have a problem installing the JSON gem with the native version of ruby. It looks like that gem is being compiled from source. Did you install XCode developer tools from the OS X disc?

我正在运行Snow Leopard并且在使用原生版本的ruby安装JSON gem时没有问题。看起来gem正在从源代码编译。您是否从OS X光盘安装了XCode开发人员工具?

#3


1  

I agree that you should install your own ruby version and XCode developer tools, but in the scenario where you want to get it working for people who don't have these things installed, switch to the "json_pure" gem, which is a pure-ruby implementation (so not the fastest, but super compatible).

我同意您应该安装自己的ruby版本和XCode开发人员工具,但是在您想要让没有安装这些东西的人工作的场景中,切换到“json_pure”gem,这是一个纯粹的ruby实现(所以不是最快,但超级兼容)。

Require 'json' will use it automatically.

要求'json'会自动使用它。

#1


2  

I think most Mac developers would recommend that you run your own version of ruby instead of the system version that shipped with the Mac. This will give you more control over versioning and avoid environment issues like the one you are experiencing.

我想大多数Mac开发人员会建议您运行自己的ruby版本,而不是Mac附带的系统版本。这将使您可以更好地控制版本控制,并避免出现您遇到的环境问题。

This is amazingly easy to do using the Ruby Version Manager. You can install multiple versions of ruby (1.8.6, 1.8.7, 1.9.1) and switch between them with ease. As a side-effect of using rvm, you no longer will have to use sudo to install gems.

使用Ruby Version Manager非常容易。您可以安装多个版本的ruby(1.8.6,1.8.7,1.9.1)并轻松切换它们。作为使用rvm的副作用,您不再需要使用sudo来安装gem。

#2


1  

I'm running Snow Leopard and did not have a problem installing the JSON gem with the native version of ruby. It looks like that gem is being compiled from source. Did you install XCode developer tools from the OS X disc?

我正在运行Snow Leopard并且在使用原生版本的ruby安装JSON gem时没有问题。看起来gem正在从源代码编译。您是否从OS X光盘安装了XCode开发人员工具?

#3


1  

I agree that you should install your own ruby version and XCode developer tools, but in the scenario where you want to get it working for people who don't have these things installed, switch to the "json_pure" gem, which is a pure-ruby implementation (so not the fastest, but super compatible).

我同意您应该安装自己的ruby版本和XCode开发人员工具,但是在您想要让没有安装这些东西的人工作的场景中,切换到“json_pure”gem,这是一个纯粹的ruby实现(所以不是最快,但超级兼容)。

Require 'json' will use it automatically.

要求'json'会自动使用它。