Docker for Mac - mkmf.rb can't find header fil

2020-02-16 07:59发布

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

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?

Thanks!

标签: ruby docker
9条回答
太酷不给撩
2楼-- · 2020-02-16 08:16

If you want to get a deeper insight into the issue:

Mac OS X 10.14 has stopped placing the include libraries in their usual location, /usr/include, keeping them only inside the XCode directory.

To confirm that this is the problem, simply run ls /usr/include. If the result comes out empty, its really this problem.

Apple ships a “legacy installer” for you to be able to install the headers in the “old location”. To fix the problem just run this:

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

https://silvae86.github.io/sysadmin/mac/osx/mojave/beta/libxml2/2018/07/05/fixing-missing-headers-for-homebrew-in-mac-osx-mojave/

查看更多
We Are One
3楼-- · 2020-02-16 08:17

As of Xcode 11, it seems like the ruby development headers are no longer included, so you will need to manually install them outside of Xcode Command Line Tools.

E.g. for me using rbenv i did

rbenv install 2.6.4
rbenv global 2.6.4
eval "$(rbenv init -)"

Then ran bundle install and everything worked as expected.

查看更多
ゆ 、 Hurt°
4楼-- · 2020-02-16 08:20

When upgrading XCode you need to install the Command-Line Tools and additionally accept the terms and conditions:

sudo xcode-select --install

Then:

sudo xcodebuild -license
查看更多
贼婆χ
5楼-- · 2020-02-16 08:24

None of the other solutions worked for me, here's what I ran to resolve the issue on Mac OS 10.14.x:

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
sudo xcodebuild -license accept
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
查看更多
甜甜的少女心
6楼-- · 2020-02-16 08:27

As @bdorfman said in his comment, the Ruby headers are no longer included as of Xcode 11 build but they seem to try to make a new build for this as soon as possible (?): https://discuss.circleci.com/t/xcode-11-gm-seed-2-released/32505/12.

What worked for me was to use rbenv like @bdorfman said:

rbenv install 2.6.4
rbenv global 2.6.4
eval "$(rbenv init -)"

But with the extra step of adding docker-sync to your new ruby version. Since after you change the ruby version (for example)

$ ruby -v
ruby 2.6.4p104 (2019-08-28 revision 67798) [x86_64-darwin18]

And then running gem list:

$ gem list
bigdecimal (default: 1.4.1)
bundler (default: 1.17.2)
cmath (default: 1.0.0)
csv (default: 3.0.9)
date (default: 2.0.0)
dbm (default: 1.0.0)
did_you_mean (1.3.0)
e2mmap (default: 0.1.0)
etc (default: 1.0.1)
fcntl (default: 1.0.0)
fiddle (default: 1.0.0)
fileutils (default: 1.1.0)
forwardable (default: 1.2.0)
io-console (default: 0.4.7)
ipaddr (default: 1.2.2)
irb (default: 1.0.0)
json (default: 2.1.0)
logger (default: 1.3.0)
matrix (default: 0.1.0)
minitest (5.11.3)
mutex_m (default: 0.1.0)
net-telnet (0.2.0)
openssl (default: 2.1.2)
ostruct (default: 0.1.0)
power_assert (1.1.3)
prime (default: 0.1.0)
psych (default: 3.1.0)
rake (12.3.2)
rdoc (default: 6.1.2)
rexml (default: 3.1.9)
rss (default: 0.2.7)
scanf (default: 1.0.0)
sdbm (default: 1.0.0)
shell (default: 0.7)
stringio (default: 0.0.2)
strscan (default: 1.0.0)
sync (default: 0.5.0)
test-unit (3.2.9)
thwait (default: 0.1.0)
tracer (default: 0.1.0)
webrick (default: 1.4.2)
xmlrpc (0.3.0)
zlib (default: 1.0.0)

(does not contains docker-sync)

If you run the gem install for docker-sync you will use the docker-sync for your rbenv managed ruby.

$ gem install docker-sync

查看更多
我想做一个坏孩纸
7楼-- · 2020-02-16 08:28

For Xcode 11 I fixed this by also installing of /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg package.

查看更多
登录 后发表回答