193

Running brew update I get the following:

/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
[etc..]
Error: update-report should not be called directly!

Calling brew config reports the following:

HOMEBREW_VERSION: 0.9.9
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: 90e84453f9adda65de6b9274987d06e46caa5d37
Last commit: 4 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 05ce2548bad01807c6be2aece21ab70d221755e6
Core tap last commit: 8 weeks 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 ivybridge
Homebrew Ruby: 2.0.0-p648
Clang: 7.3 build 703
Git: 2.7.0 => /usr/local/bin/git
Perl: /usr/bin/perl
Python: /Users/username/anaconda/bin/python => /Users/username/anaconda/bin/python2.7
Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
Java: 1.7.0_79, 1.6.0_65-b14-468
OS X: 10.11.4-x86_64
Xcode: 7.3
CLT: 7.3.0.0.1.1457485338
X11: 2.7.8 => /opt/X11

Any idea how to fix this? I wonder if Sophos Antivirus might be causing problems again..

geotheory
  • 22,624
  • 29
  • 119
  • 196
  • IIRC homebrew moved files a couple of weeks ago. For me it actually calls `/usr/local/Library/Homebrew/brew.sh` - For me, `/usr/local/Library/brew.sh` does not exist anymore. Maybe things went wrong in the transition? – cel Jul 16 '16 at 12:35

4 Answers4

210

brew upgrade will upgrade all installed packages. If you need to maintain a specific version of any binary, consider using @thanh-hải's answer: https://stackoverflow.com/a/38464247/868724

I just got this error. I ran brew upgrade and then brew update again and the problem seemed to resolve itself.

Alternatively, try just running brew update again as suggested by @ashley-willis.

Community
  • 1
  • 1
aboutaaron
  • 4,869
  • 3
  • 36
  • 30
  • 7
    It upgrades all installed packages. I have huge binary ones, e.g. Apache Spark, looks like weird solution for me – ololobus Jul 19 '16 at 23:35
  • 2
    `cd /usr/local; git reset --hard origin/master; brew update` Accidentally helped – ololobus Jul 19 '16 at 23:39
  • 13
    A naked `brew upgrade` is very dangerous if your dev stack depends on specific versions of packages (as dev stacks are wont to do). It will upgrade all your packages to latest versions, thus breaking anything depending on an older release. Highly recommend avoiding this answer, and going with @Thanh Hải below. – Peter H. Boling Jul 20 '16 at 02:01
  • 2
    Please add a word of caution that this will update ALL of the installed packages. – Carl G Jul 20 '16 at 18:09
  • ... which will take a long time and (if you're on OS X) will make your laptop heat up like crazy as you recompile all your `brew` apps. – Matt Andrews Jan 24 '17 at 15:30
  • @PeterH.Boling Isn't it possible to create an upgrade exception as it is with linux's `apt-get` – geotheory Apr 02 '17 at 08:42
  • @geotheory - not that I know of, no. But it could well be there and I not know it ;) – Peter H. Boling Apr 04 '17 at 04:48
92

Running brew update again after getting this error works, as I saw suggested on https://discuss.circleci.com/t/brew-update-command-fails/5211 and worked for me as well, without doing any upgrades nor git-fu

ashley willis
  • 1,601
  • 1
  • 13
  • 10
63

Edit : run cd "$(brew --repository)" && git fetch && git reset --hard origin/master will solve!

Refer to https://github.com/Homebrew/brew/issues/557

Thanh Hải
  • 739
  • 4
  • 8
  • 13
    This is actually a much better answer than the accepted answer. It links to the issue on the tracker, and will work on more systems. Also, this answer worked for me, for the OP error on brew v0.9.9. Also the accepted answer (with a naked `brew upgrade`) may *break* many things the user depends on. Blindly upgrading all brew packages can result in a disaster that can take hours to untangle. --1 for @geotheory, do you even brew? – Peter H. Boling Jul 20 '16 at 01:53
  • @PeterH.Boling worked fine for me, albeit the other answers are better alternatives. I don't rely on my daily driver OS to provide specific package versions when there are myriad better solutions to do the same. – ntwrkguru Apr 04 '17 at 12:32
  • @ntwrkguru - I don't follow. `brew` (homebrew) is not part of the OS, and depending on what tools use use from the brew universe upgrading them *all* can be disastrous for a development environment. – Peter H. Boling May 10 '17 at 23:05
  • @PeterH.Bowing what I mean is, for me, I don't use whatever is on my Mac, be it via brew, source, or Apple for development and so I don't care what version a given brew package is. That's all. – ntwrkguru May 11 '17 at 23:47
0

I met the same problem when I tried

brew tap homebrew/science
brew install opencv3
brew update

However, typing

brew update

again has solved my problem.

Updated 2 taps (caskroom/cask, homebrew/core).
==> Cleaning up /Library/Caches/Homebrew...
Removing: /Library/Caches/Homebrew/ant-1.9.7.yosemite.bottle.tar.gz... (5.4MB)
Removing: /Library/Caches/Homebrew/cmake-3.2.1.yosemite.bottle.1.tar.gz... (10.4MB)
Removing: /Library/Caches/Homebrew/gecode-4.3.3.yosemite.bottle.tar.gz... (2.8MB)
Removing: /Library/Caches/Homebrew/leptonica-1.71_1.yosemite.bottle.tar.gz... (1.9MB)
Removing: /Library/Caches/Homebrew/libpng-1.6.16.yosemite.bottle.tar.gz... (431.8KB)
Removing: /Library/Caches/Homebrew/libtiff-4.0.3.yosemite.bottle.tar.gz... (1MB)
Removing: /Library/Caches/Homebrew/minizinc-1.6.tar.gz... (18.2MB)
Removing: /Library/Caches/Homebrew/pkg-config-0.28.yosemite.bottle.2.tar.gz... (220.1KB)
Removing: /Library/Caches/Homebrew/tesseract-3.02.02_3.yosemite.bottle.tar.gz... (19MB)
==> Migrating /Library/Caches/Homebrew to /Users/zenglinwang/Library/Caches/Homebrew...
==> Deleting /Library/Caches/Homebrew...
Warning: Failed to delete /Library/Caches/Homebrew.
Please do so manually.
==> New / Updated / Deleted Formulae
.................
==> Migrating HOMEBREW_REPOSITORY (please wait)...
==> Migrated HOMEBREW_REPOSITORY to /usr/local/Homebrew!
Homebrew no longer needs to have ownership of /usr/local. If you wish you can
return /usr/local to its default ownership with:
  sudo chown root:wheel /usr/local
WZL
  • 21
  • 2