fastlane - Error cloning certificates repo

Paul Dunne picture Paul Dunne · Feb 15, 2018 · Viewed 8.9k times · Source

I am having some issues with fastlane and cloning a git repo from BitBucket. I am getting following error:

fatal: could not read Username for 'https://bitbucket.org': terminal prompts disabled
[17:21:34]: Exit status: 128
[17:21:34]: Error cloning certificates repo, please make sure you have read access to the repository you want to use
[17:21:34]: Run the following command manually to make sure you're properly authenticated:

I can manually git clone the repo without issue but when I am running it with fastlane, I am facing issues.

Answer

Aaron Brager picture Aaron Brager · Feb 17, 2018

This error means git can't find the username for the repo when run with terminal prompts disabled. You should be able to reproduce this by trying to clone the repo yourself like so:

$ GIT_TERMINAL_PROMPT=0 git clone https://bitbucket.org/org_name/repo_name

git is requiring you to enter the username manually because it does not have a credential stored.

Since you're using fastlane, I'm going to assume the most likely cause: you're on macOS but you haven't configured the git-credential-osxkeychain tool which provides credentials from the keychain to the git command line tool.

  1. Run

    $ git credential-osxkeychain
    

    to verify the tool is installed.

    If this fails, either install Xcode command line tools, or run brew install git to install it.

  2. Run

    $ git config --global credential.helper osxkeychain
    

    to configure the tool.

  3. Clone your repo (git clone …) as normal and login

Now your BitBucket credentials should be stored in your keychain and both GIT_TERMINAL_PROMPT=0 git clone and fastlane match should succeed.

If you're not on macOS, you'll need to install and configure a similar credential.helper for your operating system.