OK, I’ve had some more time to dig into the Ruby issues, and I think I have a good handle on it now. The issue is that Apple have changed the path where ruby
is installed to with Xcode 11. This means that after installing Xcode 11, the system Ruby is in some sense “corrupt”.
To explain a little more, if you try to install a gem with native extensions, you can see that it’s trying to search in /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include
for ruby.h
:
$ sudo gem install json
<snip>
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h
You can see this same search path here:
$ ruby -e 'puts $:'
<snip>
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/x86_64-darwin18
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/universal-darwin18
After installing Xcode 11, the ruby
headers are located in a different location on disk, in /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/
:
$ xcrun --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
So the act of installing Xcode 11 has moved the headers required for native Ruby extensions with the system Ruby to a location that is not searched.
Luckily, we install 2 other version of Ruby in the Xcode 11 image: 2.5 and 2.6. To swap to use one of these version of Ruby is straightforward - there are 2 steps:
- In your
job
in.circleci/config.yml
, change the shell parameter to/bin/bash --login -eo pipefail
to make the steps run in a login shell (by default CircleCI runs steps in a non-interactive, non-login shell, in which case neither.bashrc
nor.bash_profile
are loaded). - Add a step to set the version of Ruby that you require:
echo "ruby-2.6" > ~/.ruby-version
.
A sample configuration file looks like this:
version: 2.1
jobs:
build:
macos:
xcode: 11.0.0
steps:
- checkout
- run:
name: Set Ruby Version
command: echo "ruby-2.6" > ~/.ruby-version
This should unblock you and allow you build with Xcode 11.
In the meantime, we are going to ship a change to make the default shell on macOS be a login
shell, and we are going to change the default Ruby to be 2.6 in the Xcode 11 image. I hope to be able to ship this change tomorrow.
In related news, I’ve also got an Xcode 11.1 GM Seed image that is built, and all going well, it will be distributed tomorrow.