Failing build: Failed to prepare repo

User: angry-gates-bead98

6:02:30 PM: Build ready to start
6:02:32 PM: build-image version: 9d79ad851d6eff3969322d6e5b1df3d597650c41
6:02:32 PM: build-image tag: v3.3.19
6:02:32 PM: buildbot version: 2cc7ea668a3e8f63326d15aab17e62cd1997fa2e
6:02:32 PM: Fetching cached dependencies
6:02:32 PM: Starting to download cache of 796.5MB
6:02:40 PM: Finished downloading cache in 8.033078805s
6:02:40 PM: Starting to extract cache
6:03:06 PM: Finished extracting cache in 26.051000196s
6:03:06 PM: Finished fetching cache in 34.274934026s
6:03:06 PM: Starting to prepare the repo for build
6:03:07 PM: Preparing Git Reference refs/heads/master
6:03:09 PM: Failing build: Failed to prepare repo
6:03:09 PM: Failed during stage 'preparing repo': exit status 1
6:03:09 PM: Finished processing build request in 36.978391295s

We have not included node_modules and have not mixed yarn and npm

It seems to happen every time we merge a PR into master and I have to login and click clear cache and redeploy every time.

hmm, preparing repo usually means that we are having trouble connecting to your git hosting for some reason, which is confusing because it does seem to work for you when you clear the cache and deploy :thinking:

Seems like you already checked this article, yes?

do you have the situation described in bullet point 6?

If not, let us know, and we’ll keep thinking.

Yes I checked the article 1st.

Not sure we are doing anything like point 6, its a regular docusaurus build, it seems to work most of the time and has only recently started failing on every merge to master.

Hi, @pross, there is a possible solution in progress for this (or at least for one root cause of this issue).

The update isn’t rolled out to all accounts yet (we’re testing) but I did enable it for this site’s account now.

Would you please test deploying again and let us know it works or not? If you do see the error again, please let us know.

Likewise, if this does fix the issue we loved to hear about that as well. If there are any questions, we’ll be happy to answer.

Hi @luke we’ve done 2 deploys today and both were successful, so whatever you did under the covers seems to have worked, thankyou! :slight_smile:

1 Like

I’m experiencing the same problem. Deploys fail with a very similar log as above. If I login and manually clear cache and deploy it works.

10:10:21 AM: build-image version: a6bb34428a07e7de82f4df5dfe1843fbde91f670 (focal)
10:10:21 AM: build-image tag: v4.5.1
10:10:21 AM: buildbot version: 5284b4d1b8b4cf691b29019968d8e4eb3089acdd
10:10:21 AM: Fetching cached dependencies
10:10:21 AM: Failed to fetch cache, continuing with build
10:10:21 AM: Starting to prepare the repo for build
10:10:22 AM: git ref refs/heads/master does not exist or you do not have permission
10:10:22 AM: Did you change the name of your production branch? Don't forget to update your settings: https://docs.netlify.com/site-deploys/overview/#branches-and-deploys
10:10:22 AM: Creating deploy upload records
10:10:22 AM: Failing build: Failed to prepare repo
10:10:22 AM: Failed during stage 'preparing repo': git ref refs/heads/master does not exist
10:10:22 AM: Finished processing build request in 1.148082969s

Are you still waiting to roll out the possible solution? Can you do it for us?

Hey @oskarmodig,

Could you share the deploy ID?

Hey @hrishikesh!
Sure! This is it, right? 61b9b53d1ac3eeab2cf915eb

Also note that the manual deploy right after succeeded. 61b9b7fc1a0c42934a4545bc

Interesting, we’re not seeing anything additional logs that might be showing the cause of the error. Are you still seeing this issue? Does it occur if you create a new site or re-connect this site to the repo?

@hrishikesh I tried reconnecting the site to the repo without any improvements. We still have to manually clear the cache and rebuild.

Hey @oskarmodig,

Could you try to deploy a different site for testing without the Gatsby cache plugin? I believe there’s some wrong going on with your site’s build cache and removing the cache modifying plugin would be the first way to go.

We’re having the same issue. First build from API fails, with a subsequent manual deploy succeeding.

If we trigger the deploy via the API a few seconds after the initial script finishing, it also works.

This is for a Sanity deployment. We have used the exact same process for a Gatsby site without issue for 2+ years.

First deploy via API (triggered by configuring site): 61fcf5b64b4f808609cd33db
Second deploy via API (triggered by createSiteBuild): 61fcf5d50ba0308212d70e88

Hey @jonahark,

Did you try to relink the repo from the UI?