我知道这个问题有很多例子。我已经完成了这些答案中的所有内容,但 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 /
as Gem安装错误:必须先安装开发工具建议。我不在 Windows 上,所以 rubyinstaller 链接对我没有帮助。
安装 ffi ruby gem 时找不到 ffi.h引用了我正在尝试安装的确切 gem,但如所示xcode-select --install
不是答案。
中没有任何答案安装 Ruby gems 时的开发人员工具问题也有帮助;我已经brew install openssl
and 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
我也尝试过中的建议如何从命令行更新 Xcode - xcode-select -r
什么也没做,xcode-select -s /Library/Developer/CommandLineTools
什么都不做,并且$ sudo rm -rf /Library/Developer/CommandLineTools
防止xcode-select --install
工作,另外我还是移动了它并从苹果的开发者网站重新下载了命令行 dmg 包。还是同样的问题。
接下来我该怎么做才能安装这个 gem?