Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brew update on clean M2 MacOS .pkg install prints "fatal: cannot force update the branch 'master' checked out at '/opt/homebrew'" #847

Closed
4 tasks done
johnmcdowell opened this issue May 2, 2024 · 4 comments · Fixed by Homebrew/brew#17259
Labels

Comments

@johnmcdowell
Copy link

johnmcdowell commented May 2, 2024

brew gist-logs <formula> link OR brew config AND brew doctor output

john@Johns-Air homebrew % brew config
HOMEBREW_VERSION: 4.2.20
ORIGIN: https://github.com/Homebrew/brew
HEAD: c2ed3327c605c3e738359c9807b8f4cd6fec09eb
Last commit: 4 days ago
Core tap JSON: 02 May 18:56 UTC
Core cask tap JSON: 02 May 18:56 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 3.1.4 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/bin/ruby
CPU: octa-core 64-bit arm_blizzard_avalanche
Clang: 15.0.0 build 1500
Git: 2.39.3 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 8.4.0 => /usr/bin/curl
macOS: 14.4.1-arm64
CLT: 15.3.0.0.1.1708646388
Xcode: N/A
Rosetta 2: false
john@Johns-Air homebrew % brew doctor
Your system is ready to brew.

Verification

  • My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

Perform an initial brew update after .pkg installation on Apple Silicon without seeing a fatal error in the output

What happened (include all command output)?

Used GUI .pkg installer of latest homebrew from Releases -> Assets

Ran brew update:

john@Johns-Air ~ % brew update
==> Updating Homebrew...
fatal: cannot force update the branch 'master' checked out at '/opt/homebrew'
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:d783cbeb6e6ef0d71c0b442317b54554370decd6fac66bf2d4938c07a63f67be
######################################################################### 100.0%
==> Pouring portable-ruby-3.1.4.arm64_big_sur.bottle.tar.gz
==> Homebrew collects anonymous analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics have been recorded yet (nor will be during this `brew` run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations

Updated 2 taps (homebrew/core and homebrew/cask).
==> New Formulae
espeak-ng                  task@2                     traefik@2
[...]

What did you expect to happen?

Not see any fatal errors on first invocation of brew update

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

  • Clean install latest MacOS (14.4.1)
  • Install latest homebrew (4.2.20) via the .pkg installer at GitHub brew->Releases->Assets
  • brew update

Observe:

john@Johns-Air ~ % brew update
==> Updating Homebrew...
fatal: cannot force update the branch 'master' checked out at '/opt/homebrew'
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-[...]

Note that brew update DOES fix the problem and subsequent brew updates do not have this fatal error.

However, it seems unacceptable that a clean install of brew via the .pkg should reproducibly produce a fatal error when clean installed. This is an ugly look for what should be considered a first class package manager. There is no way to submit an issue to homebrew-core with issues that only occur on the first brew update, but we should not require users to have to ignore errors marked fatal.

I think EITHER there should be code in brew update to handle whatever was handled without showing a fatal error OR the pkg installer should not install the state that brew update generates a fatal error. (I'm not sure which.)

I did not run these commands before running brew update, but perhaps it's useful or interesting that after the first brew update after install prints:

==> Updating Homebrew...
fatal: cannot force update the branch 'master' checked out at '/opt/homebrew'

Then I see a different branch here:

john@Johns-Air ~ % cd /opt/homebrew
john@Johns-Air homebrew % git status
On branch stable
nothing to commit, working tree clean
@carlocab carlocab transferred this issue from Homebrew/homebrew-core May 2, 2024
@dkav
Copy link

dkav commented May 7, 2024

I am experiencing this issue in an existing install. It has occurred a couple of times. I haven't been able to isolate the pattern yet.

@dkav
Copy link

dkav commented May 8, 2024

I can repeat the error consistently with following:

brew developer on 
brew update
git reset --hard 3d31594e39
brew developer off 
brew update

Obviously this is just a test scenario, so I am not exactly sure what pattern is causing the issue for me in more normal usage.

brew update --debug output with error attached:
brew_update_debug.txt

@dkav
Copy link

dkav commented May 8, 2024

@johnmcdowell
Copy link
Author

Issue also referenced in discussion - Error message "fatal: cannot force update the branch 'master' checked out at '/opt/homebrew'" when installing Homebrew #5113

This other thread also refers to the error only directly after install on Apple Silicon macs, which is where I saw the issue also.

It's interesting that you also have seen it in a case not right after install-- maybe there are multiple ways to hit the state with the fatal error.

Perhaps it'd be helpful if someone doing a fresh install of homebrew on Apple Silicon ran their first brew update with --debug. (I'm hesitant to try to fully uninstall on my work machine with other packages installed.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants