[英]The compiler failed to generate an executable file. (RuntimeError) when install unf_ext in macOS
when I am using this command in macOS 10.15.7 to install unf_ext
:当我在 macOS 10.15.7 中使用此命令安装
unf_ext
:
sudo gem install unf_ext -v '0.0.7.7' --source 'https://gems.ruby-china.com'
shows this error:显示此错误:
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin19/rbconfig.rb:229: warning: Insecure world writable dir /Users/dolphin in PATH, mode 040777
Building native extensions. This could take a while...
ERROR: Error installing unf_ext:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.6.0/gems/unf_ext-0.0.7.7/ext/unf_ext
/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 ./siteconf20210121-81858-8bev42.rb extconf.rb
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin19/rbconfig.rb:229: warning: Insecure world writable dir /Users/dolphin in PATH, mode 040777
checking for -lstdc++... *** 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-static-libstdc++
--without-static-libstdc++
--with-stdc++lib
--without-stdc++lib
/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:789:in `try_func'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1016:in `block in have_library'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:357:in `postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1011:in `have_library'
from extconf.rb:6: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/unf_ext-0.0.7.7/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/unf_ext-0.0.7.7 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/unf_ext-0.0.7.7/gem_make.out
I have aready tried:我已经尝试过:
$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
still not work, what should I do to fix it?仍然无法正常工作,我应该怎么做才能解决它?
cat /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/unf_ext-0.0.7.7/gem_make.out can get the detail reason. cat /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/unf_ext-0.0.7.7/gem_make.out 可以得到详细的原因。
To me the dumped cause is: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: note: did not find header 'config.h' in framework 'ruby' (loaded from '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks') 1 error generated.对我来说,转储的原因是:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h: 24:10:注意:在框架 'ruby' 中没有找到 header 'config.h'(从 '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks' 加载)生成 1 个错误。
It seems an incompatible issue with Xcode and macOS versions. Xcode 和 macOS 版本似乎存在不兼容的问题。 macOS 10.15 and Xcode 12 don't work well together.
macOS 10.15 和 Xcode 12 不能很好地协同工作。 You can check https://github.com/CocoaPods/CocoaPods/issues/10286
您可以查看https://github.com/CocoaPods/CocoaPods/issues/10286
Just clarifying Robin Chen's answer, which I upvoted for providing the link to the CocoaPods ticket .只是澄清 Robin Chen 的回答,我赞成提供CocoaPods 票证的链接。
This does seem to be an issue with Xcode/macOS versions mismatch (I have Monterey 12.6.3 with Xcode 14.2).这似乎是 Xcode/macOS 版本不匹配的问题(我有 Monterey 12.6.3 和 Xcode 14.2)。
Following the method provided in this comment fixed the issue in my case (all credit to comment's author);按照此评论中提供的方法解决了我的问题(所有归功于评论的作者); namely:
即:
macos_major_vers=$(sw_vers -productVersion | sed 's/^\([^.]*\)\..*$/\1/')
echo $macos_major_vers # should show smth like '12'
export SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX${macos_major_vers}.sdk
sudo gem install ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.