brew: MBP M1 fails to 'brew update' and 'brew upgrade'

Bug report

Please note we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again.

  • ran brew update and can still reproduce the problem?
  • ran brew doctor, fixed all issues and can still reproduce the problem?
  • ran brew config and brew doctor and included their output with your issue?

What you were trying to do (and why)

Every time i try to install with brew install something it gives me the following warning and error. When i try to update or upgrade it gave me only the warning and the error. Trying ‘brew install git’ or ‘brew reinstall git’ doesn’t solved.

What happened (include command output)

brew upgrade (the same output with brew update) fails with this warning and error.

alberto@MacBook-Pro ~ % brew upgrade Warning: git 2.30.0 is already installed and up-to-date To reinstall 2.30.0, runbrew reinstall git/opt/homebrew/Library/Homebrew/cmd/update.sh: line 18: 6334 Killed: 9 "$GIT_EXECUTABLE" "$@" /opt/homebrew/Library/Homebrew/cmd/update.sh: line 18: 6342 Killed: 9 "$GIT_EXECUTABLE" "$@" /opt/homebrew/Library/Homebrew/cmd/update.sh: line 18: 6343 Killed: 9 "$GIT_EXECUTABLE" "$@" /opt/homebrew/Library/Homebrew/cmd/update.sh: line 18: 6361 Killed: 9 "$GIT_EXECUTABLE" "$@" /opt/homebrew/Library/Homebrew/cmd/update.sh: line 18: 6362 Killed: 9 "$GIT_EXECUTABLE" "$@" /opt/homebrew/Library/Homebrew/cmd/update.sh: line 18: 6380 Killed: 9 "$GIT_EXECUTABLE" "$@" /opt/homebrew/Library/Homebrew/cmd/update.sh: line 18: 6381 Killed: 9 "$GIT_EXECUTABLE" "$@" ==> Homebrew has enabled anonymous aggregate formula and cask analytics. Read the analytics documentation (and how to opt-out) here: https://docs.brew.sh/Analytics No analytics have been recorded yet (or will be during thisbrew` run).

Error: Failure while executing; git config --replace-all homebrew.analyticsmessage true was terminated by uncaught signal KILL.

`

Command output
`alberto@MacBook-Pro ~ % brew update
Warning: git 2.30.0 is already installed and up-to-date
To reinstall 2.30.0, run `brew reinstall git`
/opt/homebrew/Library/Homebrew/cmd/update.sh: line 18:  6947 Killed: 9               "$GIT_EXECUTABLE" "$@"
/opt/homebrew/Library/Homebrew/cmd/update.sh: line 18:  6963 Killed: 9               "$GIT_EXECUTABLE" "$@"
/opt/homebrew/Library/Homebrew/cmd/update.sh: line 18:  6975 Killed: 9               "$GIT_EXECUTABLE" "$@"
Error: Fetching /opt/homebrew failed!
Fetching /opt/homebrew/Library/Taps/homebrew/homebrew-cask failed!
Fetching /opt/homebrew/Library/Taps/homebrew/homebrew-core failed!
/opt/homebrew/Library/Homebrew/cmd/update.sh: line 18:  6986 Killed: 9               "$GIT_EXECUTABLE" "$@"
/opt/homebrew/Library/Homebrew/cmd/update.sh: line 18:  6994 Killed: 9               "$GIT_EXECUTABLE" "$@"
/opt/homebrew/Library/Homebrew/cmd/update.sh: line 18:  6995 Killed: 9               "$GIT_EXECUTABLE" "$@"
/opt/homebrew/Library/Homebrew/cmd/update.sh: line 18:  7013 Killed: 9               "$GIT_EXECUTABLE" "$@"
/opt/homebrew/Library/Homebrew/cmd/update.sh: line 18:  7014 Killed: 9               "$GIT_EXECUTABLE" "$@"
/opt/homebrew/Library/Homebrew/cmd/update.sh: line 18:  7032 Killed: 9               "$GIT_EXECUTABLE" "$@"
/opt/homebrew/Library/Homebrew/cmd/update.sh: line 18:  7033 Killed: 9               "$GIT_EXECUTABLE" "$@"
==> Homebrew has enabled anonymous aggregate formula and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics have been recorded yet (or will be during this `brew` run).

Error: Failure while executing; git config --replace-all homebrew.analyticsmessage true was terminated by uncaught signal KILL. `

What you expected to happen

I expect it updates and upgrade what i have installed 😅

Step-by-step reproduction instructions (by running brew commands)

brew update or brew upgrade on apple silicon macbook pro (the same error is given with brew install but the installation goes fine)

Output of brew config and brew doctor commands


alberto@MacBook-Pro ~ % brew config
HOMEBREW_VERSION: >=2.5.0 (shallow or no git repository)
ORIGIN: (none)
HEAD: (none)
Last commit: never
Core tap ORIGIN: (none)
Core tap HEAD: (none)
Core tap last commit: never
Core tap branch: (none)
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit arm_firestorm_icestorm
Clang: 12.0 build 1200
Git: N/A
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.1-arm64
CLT: 12.3.0.0.1.1607026830
Xcode: 12.3
Rosetta 2: false
alberto@MacBook-Pro ~ % brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Git could not be found in your PATH.
Homebrew uses Git for several internal functions, and some formulae use Git
checkouts instead of stable tarballs. You may want to install Git:
  brew install git

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 8
  • Comments: 85 (38 by maintainers)

Most upvoted comments

Your Homebrew-installed git is probably broken. This seems to have come up a bunch of times, but I have no idea how it happens.

Please read the following message before trying the steps below

Please make a note of the steps you took to encounter this problem, and the output of brew config and brew doctor. Then, share that information with us in this issue if the steps below fix it for you. Thanks!


Do

brew uninstall git
brew update
brew reinstall pcre2 gettext
brew install git

and let me know if that helps.

Simple fix that worked for me after upgrading to 11.2 on an M1:

  • xcode-select --install
    • Now which git returns /opt/homebrew/bin/git but it doesn’t work
  • brew uninstall git
    • Now which git returns /usr/bin/git and git --version returns git version 2.24.3 (Apple Git-128)
  • brew update
    • Now brew doctor returns Your system is ready to brew. Seems to be working.
    • I suppose you could reinstall brew’s git at this point. Does it matter?
brew uninstall git
brew update
brew reinstall pcre2 gettext
brew install git

and let me know if that helps.

I was having the same issue after I upgraded to Big Sur 11.2 The above fixed it for me

Do

brew update
brew reinstall pcre2 gettext

then try reinstalling git. See also https://github.com/Homebrew/discussions/discussions/439.

Every Big Sur update deletes most of my CLT (I do not have Xcode installed on this machine). That breaks brew update etc.

I reinstalled CLT, and everything works again.

Hey! I’m having this issue today on a fresh M1 Macbook Air.

What I’ve done:

  • Open terminal
  • run /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • Hit an error

Reading through the terminal logs it seems:

  • Homebrew directories created
  • CLT installed
  • Homebrew install starts
  • Tapping homebrew/core starts but hits an error

Output from there:

==> Tapping homebrew/core
remote: Enumerating objects: 26, done.
remote: Counting objects: 100% (26/26), done.
remote: Compressing objects: 100% (17/17), done.
fatal: the remote end hung up unexpectedly68.73 MiB | 6.77 MiB/s
fatal: early EOF
fatal: index-pack failed
Failed during: git fetch --force origin refs/heads/master:refs/remotes/origin/master

Running git version gives version 2.24.3

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

==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /usr/sbin/chown -R gregorthomson:admin /opt/homebrew
==> Downloading and installing Homebrew...
HEAD is now at 066ef6b43 Merge pull request #10512 from iMichka/gcc5
error: Not a valid ref: refs/remotes/origin/master
fatal: ambiguous argument 'refs/remotes/origin/master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
Error: Fetching /opt/homebrew/Library/Taps/homebrew/homebrew-core failed!
fatal: invalid upstream 'origin/master'
Failed during: /opt/homebrew/bin/brew update --force --quiet

Yes that seems to work

% which brew
/opt/homebrew/bin/brew
% brew update
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
Updated 1 tap (homebrew/core).
==> Updated Formulae
solidity                                 vsh

A clean install works for me

% /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" && /opt/homebrew/bin/brew install git && /opt/homebrew/bin/git --version
...
git version 2.30.0

Your Homebrew-installed git is probably broken. This seems to have come up a bunch of times, but I have no idea how it happens.

Do

brew uninstall git
brew update
brew reinstall pcre2 gettext
brew install git

and let me know if that helps.

Great, this works for me. I managed to fix the git

I’m guessing the problem comes from doing brew install git before running brew update after a fresh brew install using the standard installer.

Doing this (i.e. brew install git without brew update) installs an old, broken version of git, which is evidenced by the output of brew config in the first post of this issue and in https://github.com/Homebrew/discussions/discussions/439#discussioncomment-261027. This shouldn’t be happening, since brew install, by default, should do brew update before anything else.

Right now the way to avoid this seems to be to brew update manually before brew install git, but you shouldn’t have to do that.

To clarify, the sequence of events was:

  1. Installed Xcode CLT
  2. Installed homebrew
  3. brew install git

Which resulted in a broken git installation in /opt/homebrew. I had to brew uninstall git to be able to do anything else with git (and pretty much everything I do depends on it).

The git issue happened for me on a completely fresh install of homebrew and git on a brand new M1 Mac mini. It was literally one of the first things I did on this computer and the git install was immediately broken. I didn’t even do a brew update before the issues started, much less any upgrades. Perhaps it’s an issue with how one of the dependent libraries is getting bootstrapped on first install?

Sorry, i tried to paste everything correctly but it does in one line (i’m not confident with markdown 😅). In the terminal everything is correctly spaced

Try

brew update
brew reinstall $(brew deps neovim)

then reinstall neovim. It also has a bottle now, so you shouldn’t need to be building it from source if you just want the latest stable release.

I suggest taking your case to https://github.com/Homebrew/discussions/discussions. You have a date-3.1.1 still there which is causing issues. Post the output of gem list when you create a thread.

#10533 has been merged and will be a part of Homebrew 3.0.1. This should hopefully prevent some scenarios that resulted in systems getting into this broken git state. The change enforces that you have development tools installed (Xcode or CLT) on Apple Silicon.

Notably, it helps prevent the scenario where if you run brew install git or brew upgrade without development tools installed (Xcode or CLT) then you may be left with broken binaries. I believe this may have been why some people had issues updating to 11.2 - the update deletes the CLT and thus a subsequent brew upgrade could have broken your installation.

This will not fix systems already in a broken state. The aforementioned fix is the way to repair your installation.

@kingkool68, I think yours is actually a different, unrelated issue, but thanks very much for providing the debug information. (It’s actually how I could tell the issue is different.)

I believe I have this issue and before I go about fixing it here is the output of brew config:

| => brew config
HOMEBREW_VERSION: 2.7.7
ORIGIN: https://github.com/Homebrew/brew
HEAD: cd191a7f6c4c8e053336d0ea34a9886b12d06470
Last commit: 7 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: d22625eb2e4aee75d45b55c39664cb711297d6e6
Core tap last commit: 3 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: vim
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit westmere
Clang: N/A
Git: 2.30.0 => /usr/local/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.2-x86_64
CLT: N/A
Xcode: N/A
Rosetta 2: true

and brew doctor

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Unknown support status

Warning: No developer tools installed.
Install the Command Line Tools:
  xcode-select --install


Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause formulae that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  coreutils

Warning: Your Xcode does not support macOS 11.
It is either outdated or was modified.
Please update your Xcode or delete it if no updates are available.
Xcode can be updated from the App Store.


Warning: Homebrew's "sbin" was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting your PATH for example like so:
  echo 'export PATH="/usr/local/sbin:$PATH"' >> /Users/rheimlich/.bash_profile

Warning: Broken symlinks were found. Remove them with `brew cleanup`:
  /usr/local/share/man/man1/npm-exec.1
  /usr/local/share/man/man1/npm-explain.1
  /usr/local/share/man/man1/npm-set-script.1
  /usr/local/share/man/man1/npm-unstar.1
  /usr/local/share/man/man7/workspaces.7
  /usr/local/share/zsh/site-functions/_brew_cask

I did just install Bug Sur 11.2 last night. I tried to figure out what version of xcode tools I have installed by running this:

xcodebuild -version
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

The steps mentioned in https://github.com/Homebrew/brew/issues/10275#issuecomment-757351887 worked for me!

I have a brand new m1 air on 11.2 - it has no rosetta, brew, Xcode, etc installed at all.

If you want to provide a step-by-step you’d like following/reporting back on, I’d be happy to follow it.

@AlbertoPimpo any luck with that repro? It seems this is affecting lots of users, but we currently have no idea how to fix it.

Now it works, thanks. Congrats for the amazing project and thanks for the responsiveness, it’s really incredible. If you need some telemetry for the error let me know.