In the meantime, I’m using a workflow with two steps… one that installs gems using xcode 10, caches them, and another that just uses the cache. It’s dirty, but it works.
extconf failed, exit code 1 Gem files will remain installed in /var/folders/1b/gl7yt7ds26vcyr1pkgld6l040000gn/T/bundler20190920-668-480jr1json-2.2.0/gems/json-2.2.0 for inspection. Results logged to /var/folders/1b/gl7yt7ds26vcyr1pkgld6l040000gn/T/bundler20190920-668-480jr1json-2.2.0/extensions/universal-darwin-18/2.3.0/json-2.2.0/gem_make.out An error occurred while installing json (2.2.0), and Bundler cannot continue. Make sure that `gem install json -v '2.2.0' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: fastlane was resolved to 2.131.0, which depends on json Exited with code 5
I have same issue on xcode 11
issues when building with this image:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/distiller/code/vendor/bundle/ruby/2.3.0/gems/unf_ext-0.0.7.6/ext/unf_ext /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20190921-785-16ewadr.rb extconf.rb mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h extconf failed, exit code 1 Gem files will remain installed in /Users/distiller/code/vendor/bundle/ruby/2.3.0/gems/unf_ext-0.0.7.6 for inspection. Results logged to /Users/distiller/code/vendor/bundle/ruby/2.3.0/extensions/universal-darwin-18/2.3.0/unf_ext-0.0.7.6/gem_make.out An error occurred while installing unf_ext (0.0.7.6), and Bundler cannot continue. Make sure that `gem install unf_ext -v '0.0.7.6' --source 'https://rubygems.org/'` succeeds before bundling. ```
same issue here with bundle install for Xcode 11 builds
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
Same issue here on the gem installation. Is a new image in development to be released soon @marc? Or should we rely on using a custom ruby version for the time being…
GM 2 seems to be the same as the release version of Xcode 11.
Thanks for your work here @marc! Just a quick question: any idea when Catalina-based images might land? I’m starting to ship projects that use Combine and other iOS 13 / macOS 15 frameworks, and right now I can only run tests on the iOS Simulator because these frameworks aren’t available for macOS destinations yet.
So until there are adults in the room you can update (double) Ruby to
latest and use it when installing native extensions.
brew install ruby echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
worked in SSH shell prior to
Getting this error soon after updating to XCode 11.
An error occurred while installing json (2.2.0), and Bundler cannot continue. Make sure that `gem install json -v '2.2.0' --source 'https://rubygems.org/'` succeeds before bundling.
Any ETA for a fix?
Thanks in advance!
- run: name: Set up ruby latest version command: | brew install ruby echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
I added , but still not work.
Still having same issue… Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
@Roykk, @AlexanderPan19920718: you have to make sure the process that depends on
ruby knows that it has to use one installed by Homebrew.
/usr/local/opt/ruby/bin is the path to that executable. The
echo command simply adds it to user’s settings and will not take effect until those settings are
sourced, for example when the new shell session is opened or if you run
source ~/.bash_profile. This is only helpful when you are debugging via SSH. If you want to use it in a pipeline/build step — you need to make sure the
$PATH environment variable is already set to (includes) that directory when you run commands that need it. Look at the following documentation for more info on how to change the
$PATH context for your commands:
For some commands that need ruby you may also be able to specify the
--path-to-ruby in an argument to the command itself. Consult full documentation for tools like
gem to see if that’s possible (I suspect it may be, but I don’t know).
- run: name: install Ruby and run bundleinstall command: | brew install ruby echo "export PATH=/usr/local/opt/ruby/bin:$PATH" >> $BASH_ENV source $BASH_ENV sudo gem install bundler -u -f bundle install --path vendor/bundle
So it looks like Apple no longer ship the headers for the system Ruby with Xcode 11. We are building this image the same way as we built the Xcode 10.3 image, which does not exhibit this behaviour. I will build a new image where the version of Ruby is installed from
homebrew, and I’ll make this be the default system Ruby.
In the team time, you can do the following to work around the Ruby issue:
version: 2.1 jobs: build: macos: xcode: 11.0.0 shell: /bin/bash --login -eo pipefail steps: - checkout - run: name: Set Ruby Version command: echo "ruby-2.6" > ~/.ruby-version
Thanks @marc This works for me!
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
$ 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
$ 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
.circleci/config.yml, change the shell parameter to
/bin/bash --login -eo pipefailto make the steps run in a login shell (by default CircleCI runs steps in a non-interactive, non-login shell, in which case neither
- 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.
Thanks for the update.
Could you specify which ruby version for 2.6 is installed?
We had a .ruby-version file already on our project directory, I tried setting that to 2.6.4
(the last one) but I receive an error
#!/bin/bash --login -eo pipefail echo “ruby-2.6” > ~/.ruby-version
^D^Dchruby: unknown Ruby: 2.6.4 Exited with code 1
remove that file from our project seems to make it work on the CI, but I would still want to keep it in order to make sure locally we use the same version.
That’s an interesting one - since
chruby is now enabled in the image, it is detecting the
.ruby-version in your checkout and trying to select it. If you change the
.ruby-version in your repo to
2.6 you should be OK. We have
2.6.3 installed in the image, so you could change to that either.
The Xcode 11.1 GM image has Ruby 2.6.4: Xcode 11.1 GM Image released
OK, I’ve pushed a big change live:
The default shell for all images is now a
.bash_profilewill be executed on every step. This will also enable
chrubyautomatically, which will pick up any
.ruby-versionfiles and activate the requested version of Ruby
The default Ruby for Xcode 11 and 11.1 is now 2.6: I’ve also added a new file at
~/.ruby-versionfor Xcode 11 and 11.1 images. This file contains the string
ruby-2.6, which has the effect of setting the default Ruby to be 2.6.
These are breaking changes that might affect some of your builds, but it was the only way to fix the Ruby issues with Xcode 11 given our current setup.
As a headsup. Is posible that this affected old (before Xcode11) images? I have some jobs that use old Xcode images failing with
^D^Dchruby: unknown Ruby: 2.3.3 Exited with code 1
In any case is not a big deal, I will update those old jobs anyway. Just wanted to clarify it.
Changed our .ruby_version to that and it works fine now We use rvm and I think that only saying 2.6 is not enough. Anyway, we’re fine with .3.
Yeah, because of reasons we can’t change the shell for each image, only for each OS. I had to change to for all macOS jobs.
I’ve been back and forth in my head about whether it’s best to use
auto system or not in out images Or even
chruby at all. Should we just
brew install ruby and use the latest stable Ruby in the next image (and stop offering different versions?)
brew install Java, Python 2 and 3, and no-one ever has complains about those not working*. It’s only ruby that causes all the problems.
* Except for Xcode 10.2 when we accidentally installed a JRE instead of the JDK