ruby - 通过 Ruby 安装 Cocoapods 会导致错误
问题描述
我尝试像这样安装 Cocoapods
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:in `try_do':编译器无法生成可执行文件。(RuntimeError) 你必须先安装开发工具。
我必须先安装哪些开发工具?xCode 以及 Xcode 命令行工具已安装。我在 OS X 10.15.7 上,Xcode 是最新的。
解决方案
几个小时后终于收到了。我按照这个说明做了一些改动
确保
brew
已安装。如果不/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
将外壳设置为
zsh
curl -L http://install.ohmyz.sh | sh
或者,设置 PATH
eval "$(rbenv init -)"
安装 Ruby 版本管理器
brew update
brew install rbenv ruby-build
安装 Ruby
rbenv install 2.6
# 我使用我的系统默认版本号,因为我不确定它是否与我的 OS X 系统版本混淆。rbenv global 2.6
rbenv rehash
将其添加到您的 zsh
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
source ~/.zshrc
那是为我做的。所有其他的东西,比如安装 Xcode,接受 Xcode 许可证,Xcode 命令行工具都没有这样做。
推荐阅读
- node.js - 从文件名数组生成多个签名 URL?
- c# - 无法防止双重输入 c# listview
- powershell - 网络使用 x: https://server/path vs new-psDrive x https://server/path
- kotlin - Divider 可组合在放置在带有 HorizontalScroll 修饰符集的可组合内时变得不可见。这是一个错误吗?
- json - 是否可以在需要时延迟加载几个小 json 文件,而不是加载 angular 中的大 json 文件?
- docker - Docker:复制失败:在构建上下文中找不到文件或被 .dockerignore 排除
- domain-driven-design - 防止项目属性在包含在订单中后被修改
- swift - 可以为 UICollectionView(列表样式)自定义 .outlineDisclosure 选项的位置和布局吗?
- javascript - 为什么我的“更改”事件没有按预期工作?
- ssl - influxdb 2.0 证书验证失败:证书已过期 (_ssl.c:1129)