fastlane: setup_travis fails when run twice

New Issue Checklist

Issue Description

I have setup_travis at the top of my Fastfile, but use Fastlane to install dependencies, download certs via match, etc. as part of a before_install step in my .travis.yml. Fastlane is then used to run the tests in the script section.

This means that bundle exec fastlane NAME_OF_LANE is ran multiple times, with different lanes. This causes setup_travis to be ran multiple times, which appears to be failing because it is unable to create another temporary keychain with the same name.

Complete output when running fastlane, including the stack trace and command used
bundle exec fastlane bootstrap

±------------------------------------------------±--------±--------------------------------+

| Used plugins |

±------------------------------------------------±--------±--------------------------------+

| Plugin | Version | Action |

±------------------------------------------------±--------±--------------------------------+

| fastlane-plugin-latest_hockeyapp_version_number | 1.0.0 | latest_hockeyapp_version_number |

| fastlane-plugin-badge | 1.1.0 | add_badge |

±------------------------------------------------±--------±--------------------------------+

[14:52:16]: Sending anonymous analytics information

[14:52:16]: Learn more at https://docs.fastlane.tools/#metrics

[14:52:16]: No personal or sensitive data is sent.

[14:52:16]: You can disable this by adding opt_out_usage at the top of your Fastfile

[14:52:16]: ------------------------------

[14:52:16]: — Step: default_platform —

[14:52:16]: ------------------------------

[14:52:16]: --------------------------

[14:52:16]: — Step: setup_travis —

[14:52:16]: --------------------------

[14:52:16]: Creating temporary keychain: “fastlane_tmp_keychain”.

[14:52:16]: Enabling readonly mode for Travis

[14:52:16]: Driving the lane ‘ios bootstrap’ 🚀

[14:52:16]: ------------------------------------------------------

[14:52:16]: — Step: Switch to ios download_certificates lane —

[14:52:16]: ------------------------------------------------------

[14:52:16]: Cruising over to lane ‘ios download_certificates’ 🚖

[14:52:16]: -------------------

[14:52:16]: — Step: match —

[14:52:16]: -------------------

[…]

[14:52:18]: All required keys, certificates and provisioning profiles are installed 🙌

[14:52:18]: Setting Provisioning Profile type to ‘development’

[14:52:18]: -------------------

[14:52:18]: — Step: match —

[14:52:18]: -------------------

[…]

[14:52:20]: All required keys, certificates and provisioning profiles are installed 🙌

[14:52:20]: Setting Provisioning Profile type to ‘ad-hoc’

[14:52:20]: Cruising back to lane ‘ios bootstrap’ 🚘

[14:52:20]: -----------------------------------------------------

[14:52:20]: — Step: Switch to ios install_dependencies lane —

[14:52:20]: -----------------------------------------------------

[14:52:20]: Cruising over to lane ‘ios install_dependencies’ 🚖

±-----±--------------------------------------------------------------±------------+

| fastlane summary |

±-----±--------------------------------------------------------------±------------+

| Step | Action | Time (in s) |

±-----±--------------------------------------------------------------±------------+

| 1 | default_platform | 0 |

| 2 | setup_travis | 0 |

| 3 | Switch to ios download_certificates lane | 0 |

| 4 | match | 1 |

| 5 | match | 2 |

| 6 | Switch to ios install_dependencies lane | 0 |

±-----±--------------------------------------------------------------±------------+

[14:52:49]: fastlane.tools finished successfully 🎉

travis_time🔚04c7991f:start=1535986334279365000,finish=1535986369614674000,duration=35335309000 travis_fold🔚install.3 travis_time:start:2b339880 $ if [ “$TRAVIS_PULL_REQUEST” != “false” ]; then bundle exec fastlane perform_pr_checks; fi

travis_time🔚2b339880:start=1535986369639130000,finish=1535986369656110000,duration=16980000 

The command “if [ “$TRAVIS_PULL_REQUEST” != “false” ]; then bundle exec fastlane perform_pr_checks; fi” exited with 0.

travis_time:start:0e448de0 $ if [ “$TRAVIS_PULL_REQUEST” = “false” ]; then bundle exec fastlane test; fi

±------------------------------------------------±--------±--------------------------------+

| Used plugins |

±------------------------------------------------±--------±--------------------------------+

| Plugin | Version | Action |

±------------------------------------------------±--------±--------------------------------+

| fastlane-plugin-latest_hockeyapp_version_number | 1.0.0 | latest_hockeyapp_version_number |

| fastlane-plugin-badge | 1.1.0 | add_badge |

±------------------------------------------------±--------±--------------------------------+

[14:52:53]: ------------------------------

[14:52:53]: — Step: default_platform —

[14:52:53]: ------------------------------

[14:52:53]: --------------------------

[14:52:53]: — Step: setup_travis —

[14:52:53]: --------------------------

[14:52:53]: Creating temporary keychain: “fastlane_tmp_keychain”.

Looking for related GitHub issues on fastlane/fastlane…

➡️ Colour codes included in slack message

https://github.com/fastlane/fastlane/issues/48 [closed] 5 💬

22 Sep 2016

➡️ Fastlane won’t upload IPA to Crashlytics Beta

https://github.com/fastlane/fastlane/issues/12945 [closed] 7 💬

a week ago

➡️ Unable to upload ipa files to crashlytics

https://github.com/fastlane/fastlane/issues/12602 [closed] 7 💬

a day ago

and 20 more at: https://github.com/fastlane/fastlane/search?q=Shell command exited with exit status 48 instead of 0.&type=Issues&utf8=✓

🔗 You can ⌘ + double-click on links to open them directly in your browser.

/Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane_core/lib/fastlane_core/ui/interface.rb:153:in `shell_error!': [!] Shell command exited with exit status 48 instead of 0. (FastlaneCore::Interface::FastlaneShellError)

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane_core/lib/fastlane_core/ui/ui.rb:17:in `method_missing'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/helper/sh_helper.rb:80:in `sh_control_output'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/helper/sh_helper.rb:12:in `sh'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/actions/create_keychain.rb:25:in `run'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/actions/setup_travis.rb:18:in `run'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/runner.rb:253:in `block (2 levels) in execute_action'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/actions/actions_helper.rb:50:in `execute_action'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/runner.rb:232:in `block in execute_action'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/runner.rb:227:in `chdir'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/runner.rb:227:in `execute_action'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/runner.rb:157:in `trigger_action_by_name'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/fast_file.rb:149:in `method_missing'

from Fastfile:6:in `parsing_binding'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/fast_file.rb:56:in `eval'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/fast_file.rb:56:in `block in parse'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/fast_file.rb:45:in `chdir'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/fast_file.rb:45:in `parse'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/fast_file.rb:35:in `initialize'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/lane_manager.rb:16:in `new'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/lane_manager.rb:16:in `cruise_lane'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/command_line_handler.rb:36:in `handle'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/commands_generator.rb:108:in `block (2 levels) in run'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/commander-fastlane-4.4.6/lib/commander/command.rb:178:in `call'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/commander-fastlane-4.4.6/lib/commander/command.rb:153:in `run'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/commander-fastlane-4.4.6/lib/commander/runner.rb:476:in `run_active_command'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:74:in `run!'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/commander-fastlane-4.4.6/lib/commander/delegates.rb:15:in `run!'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/commands_generator.rb:333:in `run'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/commands_generator.rb:41:in `start'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/fastlane/lib/fastlane/cli_tools_distributor.rb:108:in `take_off'

from /Users/travis/.rvm/gems/ruby-2.4.3/gems/fastlane-2.102.0/bin/fastlane:20:in `<top (required)>'

from /Users/travis/.rvm/gems/ruby-2.4.3/bin/fastlane:23:in `load'

from /Users/travis/.rvm/gems/ruby-2.4.3/bin/fastlane:23:in `<main>'

from /Users/travis/.rvm/gems/ruby-2.4.3/bin/ruby_executable_hooks:15:in `eval'

from /Users/travis/.rvm/gems/ruby-2.4.3/bin/ruby_executable_hooks:15:in `<main>'

travis_time🔚0e448de0:start=1535986369678325000,finish=1535986374036503000,duration=4358178000 

The command “if [ “$TRAVIS_PULL_REQUEST” = “false” ]; then bundle exec fastlane test; fi” exited with 1.

I have cut down the log a little; I don’t want to leak some of the private URLs because this is for my job, plus the majority is output from successful steps inside the lanes. If the full output is required I will send it privately.

Environment

N/A (Problem on occurs on Travis)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 22 (7 by maintainers)

Most upvoted comments

@Titozzz any updates on this? Case you’re too busy I have the capacity to PR it.

@Pranit-Harekar The related PR is merged, and it has been released with Fastlane version 2.115.0 🎉 🍻 This issue can be closed now as it should be fixed 😄

This should get merged into fastlane directly, you should open a pull request! ( Or I can if you can’t )

thanks @ojizero you rock

Sorry still had no time to do that

This should get merged into fastlane directly, you should open a pull request! ( Or I can if you can’t )

@Titozzz go for it 👍

@RacingWang @JosephDuffy What workarounds were used to resolve this? We’re still experiencing this with the most up to date fastlane.

I had the same problem when running on Microsoft Azure DevOps ( or VSTS as it used to be called). I ended up creating my own action based on setup_circle_ci replacing the setup_keychain function with something like this:

def self.setup_keychain
        unless ENV["MATCH_KEYCHAIN_NAME"].nil?
          UI.message("Skipping Keychain setup as a keychain was already specified")
          return
        end

        keychain_name = "fastlane_tmp_keychain"
        ENV["MATCH_KEYCHAIN_NAME"] = keychain_name
        # setting a non empty password as suggested here https://docs.travis-ci.com/user/common-build-problems/#fastlane
        ENV["MATCH_KEYCHAIN_PASSWORD"] = "whateverYouWant"

        foundTemporaryKeychain = 1 # setting the initial value of foundTemporaryKeychain to false.
        Fastlane::Actions.sh("security list-keychains -d user | grep #{keychain_name}") do |status, result|
              foundTemporaryKeychain = status
        end

        if !foundTemporaryKeychain.success?
          UI.message("Creating temporary keychain: \"#{keychain_name}\".")
          Actions::CreateKeychainAction.run(
            name: keychain_name,
            default_keychain: true,
            unlock: true,
            timeout: 3600,
            lock_when_sleeps: true,
            password: ENV["MATCH_KEYCHAIN_PASSWORD"]
          )
        else
          UI.message("Found keychain: \"#{keychain_name}\". Skipping creation")
        end

        UI.message("Enabling match readonly mode.")
        ENV["MATCH_READONLY"] = true.to_s
      end

Hope this helps someone.