CLI & Bundler vs System Gem
The single most common source of mysterious CI build failures in Fastlane is version drift between developer machines and CI runners.
The Problem: System Gem Mutation
When you run:
gem install fastlane # ⚠️ Do not do this in productionfastlane betaYou are relying on whatever Ruby runtime and gem versions happened to be installed in your global environment. If Fastlane releases a breaking change to Xcode export options or Google Play API handling, your CI runner might pull the new version overnight and break your deployment.
The Solution: Bundler & Gemfile.lock
Bundler is Ruby’s equivalent to package.json + bun.lock (in Node/Bun) or pubspec.yaml + pubspec.lock (in Flutter).
1. Define Gemfile in your project root:
# Gemfilesource "https://rubygems.org"
gem "fastlane", "2.241.2"gem "dotenv", "~> 2.8"2. Install and Lock Dependencies:
bundle installThis generates a Gemfile.lock pinning the exact transitive dependency graph. Always commit Gemfile.lock to Git.
3. Always Execute with bundle exec:
# Correct executionbundle exec fastlane [lane_name]
# Example:bundle exec fastlane android deploy brand:pesantrenquBy prefixing with bundle exec, you guarantee that Ruby resolves the exact gem version locked in Gemfile.lock, ignoring any conflicting system gems.
Fastlane Version Guard in Fastfile
To prevent teammates or CI runners from accidentally running an outdated Fastlane version, put this at the very top of your Fastfile:
# frozen_string_literal: truefastlane_version "2.241.2"If anyone attempts to run your lanes with an older version, Fastlane aborts before performing any build or release actions.