119
➜  ~ brew info test 
Error: No available formula with the name "test" 
==> Searching for a previously deleted formula...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.

I have modified the git remote address to mirror address of homebrew before. Maybe it's relevant to this but I don't know.

lucky yang
  • 1,609
  • 2
  • 13
  • 20

9 Answers9

179

As of Oct 2020 Homebrew no longer creates shallow clones when being installed, and as of Dec 2020 updating existing shallow clones is not allowed either.

(This makes the original question about silencing the warning moot).


If a shallow clone is configured, a message containing text like the below will be shown:

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

It is now required to perform the unshallow process by running the git command(s) in the error message.

Note: This process may take a long time to complete without providing feedback.


For some details about the motivation for this change, see this discussion on Homebrew's GitHub page, specifically:

There are two major downsides of shallow cloning:

  1. It places a massive computation burden on GitHub's servers, which have to dynamically compute a fresh delta between what you have and the latest commit, on every brew update. (With full clones, GitHub can simply send you all the commits that happened after your last pull, and your local Git client takes care of the rest.)
  2. Because of [1], it makes it far more likely that GitHub will rate-limit Homebrew operations, which will make it suck for everyone.

--gromgit Dec 5, 2020, 12:29 AM EST

And also this additional text added to the error message:

This restriction has been made on GitHub's request because updating shallow clones is an extremely expensive operation due to the tree layout and traffic of Homebrew/homebrew-core and Homebrew/homebrew-cask.

MrUpsidown
  • 21,592
  • 15
  • 77
  • 131
Grisha Levit
  • 8,194
  • 2
  • 38
  • 53
  • 4
    Thanks for all the details. Can you clarify what exactly is the problem with shallow clones? Shouldn't they be preferred since only the latest version is downloaded? – burger Dec 13 '20 at 05:36
  • 21
    It just hangs when you do this command though :-/ – Oliver Dixon Dec 25 '20 at 16:29
  • 2
    I thought mine had hung too, it just took forever to start doing something. First: `git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" fetch --unshallow`, then `git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask" fetch --unshallow`. This is all beyond me. – Greg Dec 25 '20 at 21:36
  • 2
    Does this mean that if we don't manually unshallow our homebrew install, that we won't receive updates even when running "brew update"? – TheKarateKid Dec 26 '20 at 18:39
  • 40
    @OliverDixon, wait longer, it's a gigantic repo, it took me minutes to execute this. – Marthyn Olthof Dec 28 '20 at 12:55
  • 4
    @TheKarateKid that's right. If you have an old (pre-Dec 2020) version of homebrew installed, it will let you update to the latest version, but then, when you try to update again, the latest version will prompt you to run the git unshallow commands and will refuse to update if you do not. – Grisha Levit Dec 30 '20 at 05:54
  • 19
    Came here to find the answer: "Note: This process may take a long time to complete without providing feedback." – Richard Tuin Jan 21 '21 at 19:43
  • 1
    I’ve waited a couple of hours, no feedback in Terminal, nothing seems to be happening in Activity Monitor either (shouldn’t something show somewhere)? – 2540625 Mar 29 '21 at 03:31
  • 9
    to whom wants to know if the git still pulling the changes, add `-v` (verbose move) to show progress after long wait. – Wei Jing Aug 17 '21 at 10:50
  • for me, it took almost 20 minutes to start (I am on a 400 MBPS connection if that gives a good reference point), and I used the verbose -v command, which helps. seriously, you simply run the command, and with no feedback whatsoever, just 'wait'. it's enough to drive even an experienced developer mad. but, it is what it is. – Jay Feb 16 '23 at 19:14
37

somehow the unshallow is not working for me, I wait like 10 mins but nothing show up, even with -v option.

Just found one possible solution that might working(at least working for me).

You can remove the repository and clone again to get latest one.

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

same command for homebrew-cask if you need to update that too

all the credits belong to this answer

Wei Jing
  • 613
  • 5
  • 11
31

Under the cover Homebrew uses Git for version control, and a shallow clone is one that doesn't contain all history revisions/commits, for efficiency and data volume.

Actually, in most cases the warning can be safely ignored, as the formulae being searched for probably isn't available.

But if you're really looking for some formulae which might existed in the past, Just do what it suggests:

To get complete history run:

git -C "$(brew --repo homebrew/core)" fetch --unshallow

This way Homebrew could search for formula that existed only in the past but removed at some point.

ryenus
  • 15,711
  • 5
  • 56
  • 63
  • 2
    I had same question as OP. Perhaps they are wondering as I am why I need to do that (I never saw this warning until relatively recently), what purpose it serves, do I need to do that every time I do a `brew info`. Is this just a temporary glitch? I use git on a regular basis but have no experience with shallow vs. deep clones. – Michael Welch Oct 30 '17 at 12:40
  • 1
    Decided to try it and find out: > $ git -C "$(brew --repo homebrew/core)" fetch --unshallow > error: cannot open .git/FETCH_HEAD: Permission denied – Michael Welch Oct 30 '17 at 12:41
  • 3
    Simplest explanation for a "shallow clone" is that it's simply a clone of the git repository without the revision history thereby reducing the git repo footprint. You can also specify "depth" to reduce the amount of revision history obtained from a git clone. Essentially you get the latest version of the codebase without the bloat. – Jarrett Barnett Nov 16 '17 at 19:36
  • 1
    Pulling a deep clone of a large, old and active repo can use a huge amount of bandwidth and time. The historic versions are obsolete and so of no value for ”typical” usage. So it is a good optimisation for brew to shallow clone. The warning is simply that as it doesn't have the entire history it cannot distinguish a typo from a deletion. The vast majority of times it will be a typo. – simbo1905 Jun 20 '18 at 07:27
15

I have update repo through git pull --unshallow

Update homebrew-core

cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
git pull --unshallow

Update homebrew-cask

cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
git pull --unshallow
Nanhe Kumar
  • 15,498
  • 5
  • 79
  • 71
11

I would advise against unshallowing the clone because it cramps disk space, makes the lookups slower and enables you only to install obsolete or unmaintaned applications.

There is currently no way to silence this warning. It was proposed in this Github issue but then ignored.

The function deleted_reason which prints the message contains a silent argument but afaik there is no way to use to use something like silent from the CLI commands which later call deleted_reason.

Hedge
  • 16,142
  • 42
  • 141
  • 246
  • 3
    This is the better answer, IMO. My takeaway is: if you're a developer, fetch the unshallow clone, as in ryenus' answer. If you're a user, just leave it. –  Jul 30 '20 at 03:31
10

Fetch the repo using the --unshallow flag:

git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
Z4-tier
  • 7,287
  • 3
  • 26
  • 42
Rohit Mandiwal
  • 10,258
  • 5
  • 70
  • 83
  • 3
    How long should it normally take? I'm not sure if it's running. It's just stalling. – Eric Jul 09 '21 at 01:28
1

At the time of writing this, the logic Homebrew uses for checking if your clone is shallow is by checking if either of /usr/local/Homebrew/Library/Taps/homebrew/homebrew-{cask,core}/.git/shallow exists.

One can work around that check by moving the .git directory out of the repo; example command to do so (run in the Terminal):

for tap in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-{cask,core}; do \
  mv $tap{/,}.git ; \
  echo "gitdir: $tap.git" >$tap/.git ; \
done

Reference: Setting up .git folder in a custom location

Homebrew foundation is unfortunately incredibly hostile towards their community and I wouldn't be surprised if they patched this soon.

Nonetheless, this is a lifesaver for me and possibly other people in similar situation to mine. However, if your life doesn't immediately depend on this, perhaps do them a favor and just unshallow.

Fluffish
  • 11
  • 1
  • 1
-1
git -C "$(brew --repo homebrew/core)" fetch --unshallow

This command should run with sudo and it would work.

sudo git -C "$(brew --repo homebrew/core)" fetch --unshallow

Terminal Picture

Greenonline
  • 1,330
  • 8
  • 23
  • 31
-1

I don't know if this is the right way but does work

git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow

Wait some minutes. After that you'll see something like this.

Resolving deltas: 100% (723461/723461), completed with 4329 local objects.
From https://github.com/Homebrew/homebrew-core
   4d2aadabe6c..eab34538365 master     -> origin/master

then you could paste this again to update Homebrew and that's it.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

grg
  • 5,023
  • 3
  • 34
  • 50
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/29963989) – eglease Oct 01 '21 at 09:03