Every build fails until we "clear cache and retry"

Hi! Every build I have is failing until I “clear cache and retry” the build; site name is bitio.netlify.app

We changed the target branch and directory in our build settings, and now all builds fail until we clear cache and retry.

Build log:
6:11:59 AM: Build ready to start
6:12:00 AM: build-image version: ca811f47d4c1cbd1812d1eb6ecb0c977e86d1a1d
6:12:00 AM: build-image tag: v3.3.20
6:12:00 AM: buildbot version: be8ecf2af866e16fa4301cc5c14de2ccbbb21cf4
6:12:01 AM: Fetching cached dependencies
6:12:01 AM: Starting to download cache of 92.3MB
6:12:02 AM: Finished downloading cache in 1.397960883s
6:12:02 AM: Starting to extract cache
6:12:03 AM: Finished extracting cache in 1.442692942s
6:12:03 AM: Finished fetching cache in 2.865987839s
6:12:03 AM: Starting to prepare the repo for build
6:12:04 AM: Preparing Git Reference pull/152/head
6:12:05 AM: Failing build: Failed to prepare repo
6:12:05 AM: Failed during stage ‘preparing repo’: exit status 1
6:12:05 AM: Finished processing build request in 4.838615589s

Build settings:

There’s nothing in www/site but static HTML/CSS/images - no node.js code or modules.

This is breaking our PR flow, so any ideas would be helpful. Thanks!

hi there, did you see this already?

Yep, and none of those appear to be our case - we’ve no node_modules/package.json/package-lock.json/yarn/etc, it’s just a static site.

Okay! So I think I figured this out. This issue occurs when the target production branch for the deploy doesn’t have an existing copy of the base directory to be deployed to. In my case, I had created a new directory on a branch, switched my deploy profile to use that new directory as the build target root, then made a PR to integrate the new directory into my main branch (the production deploy branch).

All netlify builds failed until a “clear cache and retry” until I merged that new branch with the production branch. Then, later netlify runs all worked without clearing the cache.

fantastic. thanks for sharing your solution!

I do think this is bug in netlify, tho - the missing directory case should be handled by the cache manager, where the cache manager should regard that as an invalid cache and clear the cache automatically, rather than failing the build. So my solution doesn’t fix the core issue of the builds all being broken when you are working on a branch that moves the base directory of the netlify build for the production branch.

@adamf, if you could share the failing deploy, I can take a look at our logs on our end to see the exact reason why it failed. But yea, a deploy shouldn’t fail before the build command even begins if the publish directory doesn’t exist so we’d like to get a better idea why it did. Thanks!