How to remove the shallow clone warning from HomeBrew

后端 未结 3 1995
无人共我
无人共我 2020-12-31 05:22
➜  ~ brew info test 
Error: No available formula with the name \"test\" 
==> Searching for a previously deleted formula...
Warning: homebrew/core is shallow clone         


        
相关标签:
3条回答
  • 2020-12-31 06:06

    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.

    0 讨论(0)
  • 2020-12-31 06:14

    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.

    0 讨论(0)
  • 2020-12-31 06:17

    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 the below will be shown:

    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/or:

    Error: homebrew-cask is a shallow clone. To brew update first run:
    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 commands above (even without a desire for having access to the expanded history that this process provides).


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

    [Using shallow clones] 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.)

    -gromgit

    0 讨论(0)
提交回复
热议问题