How to solve fastlane installation error on macOS Mojave

August 25, 2019

What is fastlane

Fastlane is a very useful automation tool for publishing iOS / Android apps. It make the building and deployment process scriptable, which makes it less error prone, and lets you push updates automatically with no manual involvement.

The problem

One of the annoying things with fastlane though, is that it doesn’t work :) At least not if you follow the the setup instructions for iOS. According to the setup guide, you need to install Xcode command line tools:

xcode-select --install

And then install fastlane:

sudo gem install fastlane -NV

And then you get a bunch of cryptic errors like:

Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. 
Check the mkmf.log file for more details. 
You may need configuration options.


The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.


ERROR:  Error installing fastlane:
	ERROR: Failed to build gem native extension.


    Building has failed. See above output for more information on the failure.
To see why this extension failed to compile, please check the mkmf.log...


MacOS Mojave comes pre-installed with ruby version 2.3. Fastlane needs a newer ruby. So we need to upgrade ruby. This easiest way to upgrade is with brew.

1. Install brew (if you haven’t already)

Open a terminal window and run this (we’re using the old ruby to install brew that will update ruby — mind blown):

/usr/bin/ruby -e "$(curl -fsSL"

2. Install ruby

Run the following to install latest ruby version (2.6 at date of writing this):

brew install ruby

3. Add to bash profile

In order for this version to persist when you open a new terminal window, run:

echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile

4. Check the version

Run the following to check the version:

ruby -v

You should get ruby 2.6.0 or something similar. If it’s still 2.3, close the terminal window and open a new one.

5. Install fastlane

Now we can run the installation:

sudo gem install fastlane -NV

If you get this question, answer y twice:

bundler's executable "bundle" conflicts with /usr/local/lib/ruby/gems/2.6.0/bin/bundle. Overwrite executable?

Jonathan Perry
Written by@Jonathan Perry
Fullstack dev - I like making products fast