这里是错误:
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/json-1.8.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
我在谷歌上搜索了 7 个小时,但找不到适合我的解决方案。 我都试过了
请扶我起来
编辑: *安装 RVM 后我仍然得到同样的错误
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/json-1.8.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
使用此命令行:sudo gem install cocoapods
最佳答案
您使用的是 Mac 操作系统。获得:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h
您正在尝试将 gems 安装到您的系统 Ruby 中,这是由 Apple 安装供他们使用的。
不要那样做。
相反,使用 rbenv或 RVM在单独的沙箱中管理/安装 Rubies,您可以随心所欲地折叠/旋转/毁坏。
如果您选择 RVM,请在开始前*阅读完整安装说明*。 RVM 功能非常齐全,而且非常灵活,而这些都是在安装时以额外的“选项”(又名“复杂性”)为代价的。以单用户身份执行,永远不要使用 sudo
,你应该没问题。
我们可以借助 Apple 系统安装的 Ruby,但除非您真正了解自己在做什么,否则不要修改它;上面的错误让我认为情况并非如此。
要安装 Apple 预装 Ruby 以外的 Ruby,很有可能您需要最新的 Xcode 以及命令行扩展。这将提供编译 native 扩展所需的工具,以及所需的所有 header :
关于ruby - 安装 cocoapods 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20330410/