Can't install homebrew formula, says "Error: File exists - build"
I ran into this same problem when I was trying to upgrade jasper

The issue appears to be that the formula wants you to build in a subdirectory called build but there is already a directory called build in the repository.

My fix was to modify line 21 of the formula.

You can edit the formula with

brew edit jasper


and change line 21 to read

mkdir "build2" do


or similar.