54

I can no longer run either brew upgrade or brew update: both abort with

Error: homebrew-core is a shallow clone. To `brew update` first run:
  git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" fetch --unshallow

and if I follow this suggestion and run git ... --unshallow and then try brew update or brew upgrade I still get the same error message.

If I then try the command again (maybe I didn't do it right the first time?) I get

fatal: --unshallow on a complete repository does not make sense

How do I get past this error message to run brew upgrade or brew update without errors?


HOMEBREW_VERSION: 2.6.0-82-gde1afcb
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: de1afcbfc58fb3cd5779bd8fbb6b9995700dda4c
Last commit: 30 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: a7c63b0f7f7ae416a2f961b263155281759ac3a7
Core tap last commit: 29 hours ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY: /private/tmp/com.apple.launchd.FwPJPzeLfq/org.macosforge.xquartz:0
HOMEBREW_EDITOR: /usr/local/bin/bbedit
HOMEBREW_MAKE_JOBS: 4
HOMEBREW_NO_ANALYTICS: set
HOMEBREW_NO_EMOJI: set
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: quad-core 64-bit haswell
Clang: 12.0 build 1200
Git: 2.29.2 => /usr/local/bin/git
Curl: 7.64.1 => /usr/bin/curl
Java: 1.8.0_172
macOS: 10.15.7-x86_64
CLT: 12.0.32.27
Xcode: 12.2
XQuartz: 2.7.11 => /opt/X11
orome
  • 45,163
  • 57
  • 202
  • 418

4 Answers4

72

It's asking you to unshallow both homebrew-core and homebrew-cask with:

git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" fetch --unshallow
git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask" fetch --unshallow
Eric3
  • 1,021
  • 9
  • 10
  • 1
    It solved my problem. Now 'brew upgrade && brew upgrade --cask' works normally. Thanks. – frekele Dec 10 '20 at 21:50
  • 1
    In my case only the first command was requested to get back brew update. – Andrea Leganza Dec 20 '20 at 08:54
  • What's difference between shallow and unshallow ? – vikramvi Mar 07 '21 at 02:05
  • 1
    When I try the `git homebrew-core` command I get the following errors: `fatal: the remote end hung up unexpectedly fatal: protocol error: bad pack header` any ideas? – Ricardo Sanchez Mar 18 '21 at 10:24
  • Likely an issue with your connection, so just re-run the commands. If the issue persists, try `brew update-reset`. – Eric3 Mar 30 '21 at 19:55
  • 1
    @RicardoSanchez the repos are pretty big, I was having the same behaviour, run the git command on verbose move (-v) and you should see some progress after a while. `git -C "/path/to/repo" fetch --unshallow -v` – Cesar Zapata May 21 '21 at 10:40
  • May be they should include both the command in one message to help. – sriram Jun 15 '21 at 16:23
  • @sriram [They did.](https://github.com/Homebrew/brew/pull/9501) – Eric3 Jun 26 '21 at 00:18
58

Nothing worked with me until I did:

cd /usr/local/Homebrew/Library/Taps/homebrew/
rm -rf homebrew-core
git clone https://github.com/Homebrew/homebrew-core.git

Note: For ARM-based Macs, Homebrew Taps are now: /opt/homebrew/Library/Taps/homebrew

user16217248
  • 3,119
  • 19
  • 19
  • 37
Fernando Martínez
  • 1,057
  • 10
  • 13
3

Seems that is has been a change in the Homebrew policy and there is not going to be a shallow clone any more.

The correct answer is unshallow, as requested —see Eric3 answer— or install it again, which is going to produce a unshallow / regular copy of the repo.

lpuerto
  • 301
  • 4
  • 16
0

This worked for me.

git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" fetch --unshallow
git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask" fetch --unshallow
remote: Enumerating objects: 561296, done.
remote: Counting objects: 100% (561255/561255), done.
remote: Compressing objects: 100% (200847/200847), done.
remote: Total 552295 (delta 355423), reused 545449 (delta 348597), pack-reused 0
Receiving objects: 100% (552295/552295), 214.42 MiB | 2.60 MiB/s, done.
Resolving deltas: 100% (355423/355423), completed with 4915 local objects.
From https://github.com/Homebrew/homebrew-core
   09e19b5c825..003302f81db master     -> origin/master
remote: Enumerating objects: 180904, done.
remote: Counting objects: 100% (166460/166460), done.
remote: Compressing objects: 100% (47394/47394), done.
remote: Total 155334 (delta 116608), reused 146431 (delta 107784), pack-reused 0
Receiving objects: 100% (155334/155334), 73.84 MiB | 4.87 MiB/s, done.
Resolving deltas: 100% (116608/116608), completed with 6054 local objects.
From https://github.com/Homebrew/homebrew-cask