Search code examples
continuous-integrationcontinuous-deploymentcirclecifastlanefastlane-gym

CircleCI fastlane gym - bundler: failed to load command: fastlane


Setting up CircleCI Pipeline for ios build using fastlane.

I'm running into an issue with the gym build process as per below with the gym process that's displaying the error message - bundler: failed to load command: fastlane (/Users/distiller/project/vendor/bundle/ruby/2.7.0/bin/fastlane)

FASTLANE GYM ERROR

+------+--------------------------------------+-------------+
|                     fastlane summary                      |
+------+--------------------------------------+-------------+
| Step | Action                               | Time (in s) |
+------+--------------------------------------+-------------+
| 1    | default_platform                     | 0           |
| 2    | setup_circle_ci                      | 0           |
| 3    | Switch to ios sync_certificates lane | 0           |
| 4    | app_store_connect_api_key            | 0           |
| 5    | match                                | 1           |
| 6    | automatic_code_signing               | 0           |
| 💥   | gym                                  | 41          |
+------+--------------------------------------+-------------+

DEBUG [2022-07-28 03:10:48.07]: All plugins are up to date
ERROR [2022-07-28 03:10:48.07]: fastlane finished with errors
DEBUG [2022-07-28 03:10:48.07]: All plugins are up to date
bundler: failed to load command: fastlane (/Users/distiller/project/vendor/bundle/ruby/2.7.0/bin/fastlane)
Traceback (most recent call last):
    49: from /Users/distiller/.gem/ruby/2.7.6/bin/bundle:23:in `<main>'
    48: from /Users/distiller/.gem/ruby/2.7.6/bin/bundle:23:in `load'
    47: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/exe/bundle:36:in `<top (required)>'
    46: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
    45: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/exe/bundle:48:in `block in <top (required)>'
    44: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/cli.rb:25:in `start'
    43: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
    42: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/cli.rb:31:in `dispatch'
    41: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
    40: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
    39: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    38: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/cli.rb:483:in `exec'
    37: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/cli/exec.rb:23:in `run'
    36: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/cli/exec.rb:58:in `kernel_load'
    35: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/cli/exec.rb:58:in `load'
    34: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/bin/fastlane:23:in `<top (required)>'
    33: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/bin/fastlane:23:in `load'
    32: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/bin/fastlane:23:in `<top (required)>'
    31: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/cli_tools_distributor.rb:123:in `take_off'
    30: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/commands_generator.rb:43:in `start'
    29: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/commands_generator.rb:354:in `run'
    28: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/commander-4.6.0/lib/commander/delegates.rb:18:in `run!'
    27: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:124:in `run!'
    26: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/commander-4.6.0/lib/commander/runner.rb:444:in `run_active_command'
    25: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/commander-4.6.0/lib/commander/command.rb:157:in `run'
    24: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/commander-4.6.0/lib/commander/command.rb:187:in `call'
    23: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/commands_generator.rb:110:in `block (2 levels) in run'
    22: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/command_line_handler.rb:36:in `handle'
    21: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/lane_manager.rb:47:in `cruise_lane'
    20: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/runner.rb:45:in `execute'
    19: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/runner.rb:45:in `chdir'
    18: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/runner.rb:49:in `block in execute'
    17: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/lane.rb:33:in `call'
    16: from Fastfile:41:in `block (2 levels) in parsing_binding'
    15: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/fast_file.rb:159:in `method_missing'
    14: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/runner.rb:157:in `trigger_action_by_name'
    13: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/runner.rb:229:in `execute_action'
    12: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/runner.rb:229:in `chdir'
    11: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/runner.rb:255:in `block in execute_action'
    10: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/actions/actions_helper.rb:69:in `execute_action'
     9: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/runner.rb:263:in `block (2 levels) in execute_action'
     8: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/actions/build_app.rb:68:in `run'
     7: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/gym/lib/gym/manager.rb:19:in `work'
     6: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/gym/lib/gym/runner.rb:18:in `run'
     5: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/gym/lib/gym/runner.rb:110:in `build_app'
     4: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane_core/lib/fastlane_core/command_executor.rb:84:in `execute'
     3: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/gym/lib/gym/runner.rb:114:in `block in build_app'
     2: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/gym/lib/gym/error_handler.rb:73:in `handle_build_error'
     1: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane_core/lib/fastlane_core/ui/ui.rb:17:in `method_missing'
/Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane_core/lib/fastlane_core/ui/interface.rb:163:in `build_failure!': Error building the application - see the log above (FastlaneCore::Interface::FastlaneBuildFailure)
    49: from /Users/distiller/.gem/ruby/2.7.6/bin/bundle:23:in `<main>'
    48: from /Users/distiller/.gem/ruby/2.7.6/bin/bundle:23:in `load'
    47: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/exe/bundle:36:in `<top (required)>'
    46: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
    45: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/exe/bundle:48:in `block in <top (required)>'
    44: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/cli.rb:25:in `start'
    43: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
    42: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/cli.rb:31:in `dispatch'
    41: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
    40: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
    39: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    38: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/cli.rb:483:in `exec'
    37: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/cli/exec.rb:23:in `run'
    36: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/cli/exec.rb:58:in `kernel_load'
    35: from /Users/distiller/.gem/ruby/2.7.6/gems/bundler-2.3.17/lib/bundler/cli/exec.rb:58:in `load'
    34: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/bin/fastlane:23:in `<top (required)>'
    33: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/bin/fastlane:23:in `load'
    32: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/bin/fastlane:23:in `<top (required)>'
    31: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/cli_tools_distributor.rb:123:in `take_off'
    30: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/commands_generator.rb:43:in `start'
    29: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/commands_generator.rb:354:in `run'
    28: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/commander-4.6.0/lib/commander/delegates.rb:18:in `run!'
    27: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:124:in `run!'
    26: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/commander-4.6.0/lib/commander/runner.rb:444:in `run_active_command'
    25: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/commander-4.6.0/lib/commander/command.rb:157:in `run'
    24: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/commander-4.6.0/lib/commander/command.rb:187:in `call'
    23: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/commands_generator.rb:110:in `block (2 levels) in run'
    22: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/command_line_handler.rb:36:in `handle'
    21: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/lane_manager.rb:47:in `cruise_lane'
    20: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/runner.rb:45:in `execute'
    19: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/runner.rb:45:in `chdir'
    18: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/runner.rb:49:in `block in execute'
    17: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/lane.rb:33:in `call'
    16: from Fastfile:41:in `block (2 levels) in parsing_binding'
    15: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/fast_file.rb:159:in `method_missing'
    14: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/runner.rb:157:in `trigger_action_by_name'
    13: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/runner.rb:229:in `execute_action'
    12: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/runner.rb:229:in `chdir'
    11: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/runner.rb:255:in `block in execute_action'
    10: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/actions/actions_helper.rb:69:in `execute_action'
     9: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/runner.rb:263:in `block (2 levels) in execute_action'
     8: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane/lib/fastlane/actions/build_app.rb:68:in `run'
     7: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/gym/lib/gym/manager.rb:19:in `work'
     6: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/gym/lib/gym/runner.rb:18:in `run'
     5: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/gym/lib/gym/runner.rb:110:in `build_app'
     4: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane_core/lib/fastlane_core/command_executor.rb:84:in `execute'
     3: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/gym/lib/gym/runner.rb:114:in `block in build_app'
     2: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/gym/lib/gym/error_handler.rb:73:in `handle_build_error'
     1: from /Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane_core/lib/fastlane_core/ui/ui.rb:17:in `method_missing'
/Users/distiller/project/vendor/bundle/ruby/2.7.0/gems/fastlane-2.208.0/fastlane_core/lib/fastlane_core/ui/interface.rb:163:in `build_failure!': \e[31m[!] Error building the application - see the log above\e[0m (FastlaneCore::Interface::FastlaneBuildFailure)

Exited with code exit status 1
CircleCI received exit code 1

FASTFILE

# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
#     https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
#     https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

default_platform(:ios)

platform :ios do
  before_all do
    setup_circle_ci
  end
  desc "Sync certificates"
  lane :sync_certificates do
  app_store_connect_api_key(
    key_id: "redacted",
    issuer_id: "redacted",
    key_content: "redacted",
    is_key_content_base64: true,
    in_house: false #boolean value if team is Enterprise or not
)
   #read-only disables match from overriding the existing certificates.
   match({readonly: true, type: "development"})
 end

 desc "Create ipa"
 lane :build do
   #update profiles
   sync_certificates
   # Creates a signed file
   disable_automatic_code_signing(path: "redacted-ios.xcodeproj")
   gym(export_method: "development")
 end
 
 desc "Upload to TestFlight"
 lane :beta do
  sync_certificates 
  build
  # pilot  
 end
end

CirclCI Config File

# .circleci/config.yml

version: 2.1

orbs:
    ruby: circleci/[email protected]
    slack: circleci/[email protected]

aliases:
    - &restore_gem_cache
        name: Restore gem cache
        keys:
        - gem-cache-v1-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
        - gem-cache-v1-{{ arch }}-{{ .Branch }}
    # Fall back to using the latest cache if no exact match is found.
    - gem-cache-v1
    - &save_gem_cache
        name: Save gem cache
        key: gem-cache-v1-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
        paths:
          - vendor/bundle
    - &bundle_install
        name: Install Gems via Bundler
        command: bundle install --path vendor/bundle
    - &restore_pods_cache
        name: Restore pods cache
        key: 2-pods-{{ checksum "Podfile.lock" }}
    - &pod_install
        name: Install Pods
        command: |
          if [ ! -d "Pods" ]
          then
             curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
            bundle exec pod install
          fi
    - &save_pods_cache
        name: Save pods cache
        key: 2-pods-{{ checksum "Podfile.lock" }}
        paths: ./Pods
jobs:
  test_app:
    macos:
      xcode: "14.0.0"
    working_directory: /Users/distiller/project
    environment:
      FL_OUTPUT_DIR: output
      FASTLANE_LANE: build
    shell: /bin/bash --login -o pipefail
    steps:
      - checkout
      - run: bundle install
      - run: bundle update
      - ruby/install-deps
      - restore_cache: *restore_pods_cache
      - run:
          name: pod Install
          command: pod install
      - save_cache: *save_pods_cache
      - run:
          name: add to ssh pub
          command: echo $SSH_PUB > ~/.ssh/redacted.pub
      - run:
          name: add to ssh pvt
          command: echo $SSH_PVT > ~/.ssh/redacted
      - run: 
          name: ssh check
          command: cat ~/.ssh/known_hosts
      - run:
          name: check all env var
          command: printenv
      - run:
          name: fastlane build
          command: bundle exec fastlane $FASTLANE_LANE --verbose
      - run:
          name: check keychain status
          command: security find-identity -v -p codesigning
      - store_artifacts:
          path: /Users/distiller/Library/Logs/gym
      - store_test_results:
          path: output/scan
      # - slack/notify:
      #     event: pass
      #     template: basic_success_1
      # - slack/notify:
      #     event: fail
      #     template: basic_fail_1

workflows:
  verify:
    jobs:
      - test_app:
          context:
            - Slack Integration

Any help would be greatly appreciated!


Solution

  • Issue ended up being that match wasn't applying the certificate properly.