"brew update" command fails

Hi,

We are using CircleCi to build several iOS projects.

We’ve added the - brew update command in our circle.yml to ensure the last version of Homebrew is installed.

It was previously working, but now our builds are always failing with the following error:

$brew update
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
Error: update-report should not be called directly!

brew update returned exit code 1

Action failed: brew update

Was there any recent changes to containers that prevent to update Homebrew?

(Hacky solution at the bottom)

It seems that Homebrew isn’t able to detect the git client to use during the dependency cycle. The output from brew config reports this:

HOMEBREW_VERSION: 0.9.9
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: 656c713d6c549a1ae1dc25cdc1f9bb887dfd8440
Last commit: 7 weeks ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 56c928d35dfc33011ad5e17fc6b9182460002d17
Core tap last commit: 6 weeks ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: dual-core 64-bit ivybridge
Clang: 7.3 build 703
Perl: /usr/bin/perl
Python: /usr/bin/python
Ruby: /usr/local/bin/ruby => /usr/local/Cellar/ruby20/2.0.0-p648/bin/ruby
Java: 1.8.0_60
System Ruby: 2.0.0-p648
OS X: 10.11.4-x86_64
Xcode: 7.3.1 => /Applications/Xcode-7.3.app/Contents/Developer
CLT: 7.3.1.0.1.1461711523
X11: N/A

This should have an entry like:

Git: 2.8.2 => /usr/local/bin/git

Through trial and error, it seems that calling brew update twice resolves the issue temporarily. Our dependencies section now looks like:

dependencies:
  pre:
    - (brew update || brew update)
    - (brew upgrade xctool || true)

This is a hacky solution, but at least it gets our builds working again for now.

Thanks David, we’ll use this quick fix for now.

This is a confirmed issue with Homebrew, per them it should be fixed, but if not the following will correct.

cd "$(brew --repository)" && git fetch && git reset --hard origin/master

ref: Brew update error · Issue #557 · Homebrew/brew · GitHub

Check this also works
run:
brew upgrade
before
brew update
Like in this SOF question

April 2017, still having this issue. Running brew update twice works for me as well.

Output of brew config:

HOMEBREW_VERSION: >1.1.0 (no git repository)
ORIGIN: [omitted because it’s a link]
HEAD: 5d74069b98a9a4a923c748e33b5f101a45ceac83
Last commit: 6 hours ago
Core tap ORIGIN: [omitted because it’s a link]
Core tap HEAD: acfa4adc9d656c745863c67e1eb365fbd1ba55f2
Core tap last commit: 10 months ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: quad-core 64-bit sandybridge
Homebrew Ruby: 2.0.0-p648
Clang: 4.2 build 425
Git: 1.7.12.4 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Perl: /usr/local/bin/perl => /usr/local/Cellar/perl/5.24.0_1/bin/perl
Python: /usr/bin/python
Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
Java: N/A
macOS: 10.11.5-x86_64
Xcode: 4.6.3
CLT: 7.3.1.0.1.1461711523
X11: N/A