【发布时间】:2021-01-12 03:37:17
【问题描述】:
我知道这个问题有很多例子。我已经完成了这些答案中的所有操作,但 4 小时后却一无所获。
我正在尝试在 Catalina 10.15.7 上安装 gem 并获得越来越流行的
/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.
有了这个额外的上下文
ERROR: Error installing ffi:
ERROR: Failed to build gem native extension.
current directory: /Users/bmanica/.chefdk/gem/ruby/2.4.0/gems/ffi-1.13.1/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 ./siteconf20200925-10024-qilctf.rb extconf.rb --with-cflags\=-save-temps\=obj\ -o\ tmp/a.o
通过调用安装时
gem install ffi -- --with-cflags="-save-temps=obj -o tmp/a.o"
绕过 Catalina 严格的权限规则。
我刚刚下载了 XCode 和命令行工具:
> xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
> xcode-select -p
/Applications/Xcode.app/Contents/Developer
> ls /Applications/Xcode.app/Contents/Developer
Applications Library Makefiles Platforms Toolchains Tools usr
我通过以下方式至少接受了四次许可
sudo xcodebuild -license accept
我试过了
sudo xcode-select -switch /
正如Gem installation error: You have to install development tools first 建议的那样。我不在 Windows 上,所以 rubyinstaller 链接对我没有帮助。
Can't Find ffi.h When Installing ffi ruby gem 引用了我正在尝试安装的确切 gem,但如所示 xcode-select --install 不是答案。
Developer tools issues when installing Ruby gems 中的答案也无济于事;我已经有了brew install openssl 和brew install libffi 并导出了它告诉我的变量:
> set | grep FLAGS
CPPFLAGS=-I/usr/local/opt/libffi/include
LDFLAGS=-L/usr/local/opt/libffi/lib
> set | grep PATH
PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig
我也尝试过How to update Xcode from command line 中的建议 - xcode-select -r 什么都不做,xcode-select -s /Library/Developer/CommandLineTools 什么都不做,$ sudo rm -rf /Library/Developer/CommandLineTools 阻止 xcode-select --install 工作,另外我还是移动了它并重新下载了命令行 dmg来自 Apple 开发者网站的软件包。还是同样的问题。
接下来我应该怎么做才能安装这个 gem?
【问题讨论】:
-
接受 XCode 许可证:
sudo xcodebuild -license accept。另外,使用 Ruby 管理器; 不要在你的系统 Ruby 中安装 gems。 -
抱歉,我已经接受了至少四次许可。
-
一点建议。不要以“是的,我已经阅读了类似这样的其他问题”作为开头,而只是介绍您到目前为止所研究的内容。写得这么好的问题不需要它,它真的只是把它拖下来。
-
我遇到了同样的问题。我这样解决了stackoverflow.com/questions/66081684/…
标签: ruby rubygems macos-catalina