Mac版Docker-mkmf.rb找不到ruby的头文件 [英] Docker for Mac - mkmf.rb can't find header files for ruby

查看:124
本文介绍了Mac版Docker-mkmf.rb找不到ruby的头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac上更新了XCode,从那时起,当使用 docker-sync-stack start 启动Docker时,我收到以下错误消息:

I updated XCode on my Mac and since then when starting Docker using docker-sync-stack start I get this error message:

mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h

我尝试使用以下方法安装ruby: brew install rbenv ruby​​-构建,但这不会改变任何东西。

I tried installing ruby with this: brew install rbenv ruby-build but this does not change anything.

有人知道我该如何解决吗?

Does anybody know how I can fix it?

谢谢!

推荐答案

对于 macOS 10.14上的Xcode 11 ,即使在安装Xcode和安装命令行工具,并通过以下方式接受许可

For Xcode 11 on macOS 10.14, this can happen even after installing Xcode and installing command-line tools and accepting the license with

sudo xcode-select --install
sudo xcodebuild -license accept

问题是Xcode 11附带了macOS 10.15 SDK,其中包含ruby2.6的标头,但不包含macOS 10的标头。 14的ruby2.3。您可以通过运行

The issue is that Xcode 11 ships the macOS 10.15 SDK which includes headers for ruby2.6, but not for macOS 10.14's ruby2.3. You can verify that this is your problem by running

ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'

在带有Xcode 11的macOS 10.14上打印 non -存在的路径

which on macOS 10.14 with Xcode 11 prints the non-existent path

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0

但是,Xcode 11在 /Library/Developer/CommandLineTools/SDKs/MacOS10.14.sdk 。无需按照其他答案中的建议安装旧的头文件来污染系统目录。相反,通过选择该SDK,将找到适当的ruby2.3标头:

However, Xcode 11 installs a macOS 10.14 SDK within /Library/Developer/CommandLineTools/SDKs/MacOS10.14.sdk. It isn't necessary to pollute the system directories by installing the old header files as suggested in other answers. Instead, by selecting that SDK, the appropriate ruby2.3 headers will be found:

sudo xcode-select --switch /Library/Developer/CommandLineTools
ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'

现在应该正确打印

/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0

同样,选择该SDK时,宝石安装应该可以工作。

Likewise, gem install should work while that SDK is selected.

要切换回使用当前的Xcode 11 SDK,请使用

To switch back to using the current Xcode 11 SDK, use

sudo xcode-select --switch /Applications/Xcode.app

这篇关于Mac版Docker-mkmf.rb找不到ruby的头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆