通过Ruby安装Cocoapods会导致错误 [英] Installing Cocoapods via Ruby causes Error
问题描述
我尝试像这样安装Cocoapods
I try to install Cocoapods like so
sudo gem install cocoapods
这是我得到的输出:
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.14.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 ./siteconf20210206-1353-ybitkb.rb extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
--with-ffi_c-dir
--without-ffi_c-dir
--with-ffi_c-include
--without-ffi_c-include=${ffi_c-dir}/include
--with-ffi_c-lib
--without-ffi_c-lib=${ffi_c-dir}/lib
--enable-system-libffi
--disable-system-libffi
--with-libffi-config
--without-libffi-config
--with-pkg-config
--without-pkg-config
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:546:in `block in try_link0'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tmpdir.rb:93:in `mktmpdir'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:543:in `try_link0'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:570:in `try_link'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:672:in `try_ldflags'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1832:in `pkg_config'
from extconf.rb:9:in `system_libffi_usable?'
from extconf.rb:42:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.14.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.14.2/gem_make.out
基本上是这个
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:在try_do中:编译器无法生成可执行文件.(RuntimeError)您必须先安装开发工具.
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first.
我必须首先安装哪些开发工具?xCode以及Xcode命令行工具已安装.我使用的是OS X 10.15.7,Xcode是最新的.
What development tools do I have to install first? xCode is installed, as well as the Xcode command line tools. I am on OS X 10.15.7, Xcode is up to date.
推荐答案
几个小时后终于明白了.我遵循了此指令,对其进行了一些更改
Finally got it after hours. I followed this instruction, changed it a bit
-
确保已安装
brew
.如果不/bin/bash -c" $(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
将shell设置为 zsh
curl -L http://install.ohmyz.sh |sh
或设置PATH
-
eval``$(rbenv init-)''
安装Ruby版本管理器酿造更新
brew install rbenv ruby-build
Install Ruby Version Manager
brew update
brew install rbenv ruby-build
安装Ruby rbenv install 2.6
#我使用了系统默认版本号,因为我不确定它是否与OS X系统版本混淆. rbenv global 2.6
rbenv rehash
Install Ruby
rbenv install 2.6
# I used my systems default version number because I was not sure if it messes with my OS X system version.
rbenv global 2.6
rbenv rehash
将其添加到您的zsh echo'eval" $(rbenv init-)"'>>〜/.zshrc
source〜/.zshrc
Add it to your zsh
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
source ~/.zshrc
对我来说就做到了.其他所有东西,例如安装Xcode,接受Xcode许可,Xcode命令行工具都没有.
That did it for me. All the other stuff like installing Xcode, accept the Xcode License, Xcode command line tools did not do it.
这篇关于通过Ruby安装Cocoapods会导致错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!