mak*_*imr 5 ruby vim macos-mojave
当我尝试在macOS Mojave(10.14.1)上使用ruby支持( - enable-rubyinterp)构建vim(8.1.0509)时出现错误:
In file included from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby.h:33:
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/ruby.h:24:10: fatal error:
'ruby/config.h' file not found
#include "ruby/config.h"
Run Code Online (Sandbox Code Playgroud)
我已经安装了Xcode 10.1.
xcode-select -p
/Applications/Xcode.app/Contents/Developer
Run Code Online (Sandbox Code Playgroud)
谢谢
PS在我的问题上看到我的答案它解释了为什么我的问题与Xcode的问题不同
Jon*_*hoi 88
Catalina、Big Sur 等(截至 2020 年和 2021 年)
最新版本的 macOS 和 Xcode(例如 Catalina 10.15 和 Xcode 12.2)肯定会出现这种情况。重新安装 Xcode 并xcode-select --install没有帮助我(已经发布的解决方案似乎已经过时)。我不想使用,rvm因为它可能会导致一些烦人的问题。
我通过手动创建符号链接做了一个解决方法:
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby
ln -sf ../../../../Headers/ruby/config.h
Run Code Online (Sandbox Code Playgroud)
在哪里ruby/config.h可以找到:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/Headers/ruby/config.h。
您应该根据您当前的 xcode 安装更改 SDK 版本(例如上例中的 11.1)。
也很可能遇到另一个.../universal-darwin19/ruby/config.h找不到的错误(无法安装 Commonmarker gem(jekyll 需要)macos)。它可以通过以下方式快速修复:
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0
ln -sf universal-darwin20 universal-darwin19
Run Code Online (Sandbox Code Playgroud)
Ede*_*den 39
在 macOS Catalina 上
多次安装和卸载开发人员工具后,这是唯一对我有用的方法:
首先安装 Ruby 版本管理器 rvm:
curl -L https://get.rvm.io | bash -s stable
Run Code Online (Sandbox Code Playgroud)
然后安装最新版本的ruby:
rvm install ruby-2.7.2
Run Code Online (Sandbox Code Playgroud)
最后再次尝试安装 cocoapods:
sudo gem install cocoapods
Run Code Online (Sandbox Code Playgroud)
(来自这个答案:https : //stackoverflow.com/a/65033418/3605761)
编辑:可能需要rvm reinstall ruby-2.7.2而不是rvm install ruby-2.7.2在第 2 步。
ReD*_*ion 31
这个答案对我有帮助:https://stackoverflow.com/a/53194299/2105993
brew install rbenv ruby-build
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
rbenv install 2.6.3
rbenv global 2.6.3
Run Code Online (Sandbox Code Playgroud)
小智 15
如果您在 Mac Big Sur 中遇到此问题,重新安装CommandLineTools可以解决此问题。
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
Run Code Online (Sandbox Code Playgroud)
lea*_*vez 13
这是因为在编译 gem 的本机扩展时,某些版本的 Xcode 没有适用于其运行的操作系统的 macOS SDK。
确保 Xcode 版本和 macOS 版本相互匹配:
PS 我在 MacPorts 的文档中找到了类似的列表,它可能是最新的。(在https://www.macports.org/install.php13.1 or later for Monterey中搜索)
ata*_*man 12
我有同样的问题。无法安装具有本机扩展名的gem。跑步
$ open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
Run Code Online (Sandbox Code Playgroud)
失败,因为文件不存在。看起来Mojave可以破坏命令行工具。
我通过删除Xcode命令行工具,再次安装它们,然后安装缺少的标头来解决此问题:
$ sudo rm -rf /Library/Developer/CommandLineTools
$ xcode-select --install
$ open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
Run Code Online (Sandbox Code Playgroud)
在尝试使用以下脚本引导 React Native 项目时经历了这种无意义的事情: npx react-native@latest init <Project Name>按照官方文档。遇到以下错误:fatal error: 'ruby/config.h' file not found尽管在更新到 Ventura 13.6 后全新安装了 xcode 和命令行工具。
解决方案:
导航到有问题的文件夹:
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby
Run Code Online (Sandbox Code Playgroud)
复制缺少的头文件:
sudo cp ../../../../Headers/ruby/config.h .
Run Code Online (Sandbox Code Playgroud)
将“universal-darwin23”文件夹重命名为“universal-darwin22”:
sudo mv /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin23/ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin22/
Run Code Online (Sandbox Code Playgroud)
安装“activesupport”gem:
sudo gem install activesupport -v 6.1.7.6
Run Code Online (Sandbox Code Playgroud)
手动安装cocoapods:
sudo gem install cocoapods
Run Code Online (Sandbox Code Playgroud)
现在它终于按预期工作了。看起来某些开发人员同事在某个时候做了错事。
希望这可以帮助!
我的问题不同于 - Yosemite升级破坏了 ruby.h
正如您在问题描述中看到的,它是System的 ruby,而不是 Xcode 的 ruby,因此重新安装 Xcode 或符号链接在这里没有帮助。
答: 我已重新安装 macOS Mojave,没有丢失任何数据,这解决了问题。
| 归档时间: |
|
| 查看次数: |
3305 次 |
| 最近记录: |