我正在尝试在MacBook上安装cocoapods,并将此代码运行到终端gem install cocoapods
中后,出现以下错误:
****** ~ % sudo gem install cocoapods
Password:
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.12.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20200413-663-1dklrnl.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/include/ruby.h
You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.12.2 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.12.2/gem_make.out
答案 0 :(得分:11)
您似乎尚未安装Ruby开发标头。
您可以通过执行以下两个命令来安装Xcode命令行工具来解决此问题:
xcode-select --install
sudo xcodebuild -license
更改将在计算机重新启动后应用。
答案 1 :(得分:0)
转到Xcode首选项,然后单击位置->命令行工具->单击下拉列表,然后检查是否有任何可用的。如果是,则选择并设置它。然后尝试安装可可豆荚,按预期工作。
如果命令行工具下拉菜单中没有可用选项,请使用以下命令
xcode-select --install
sudo xcodebuild -license