107

I upgraded from Mohave to Big Sur and found that homebrew is not working any more. I installed the command line tools using the command

xcode-select --install

After I run brew list, I get the following error

~ brew list
Traceback (most recent call last):
    11: from /usr/local/Homebrew/Library/Homebrew/brew.rb:23:in `<main>'
    10: from /usr/local/Homebrew/Library/Homebrew/brew.rb:23:in `require_relative'
     9: from /usr/local/Homebrew/Library/Homebrew/global.rb:37:in `<top (required)>'
     8: from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
     7: from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
     6: from /usr/local/Homebrew/Library/Homebrew/os.rb:3:in `<top (required)>'
     5: from /usr/local/Homebrew/Library/Homebrew/os.rb:21:in `<module:OS>'
     4: from /usr/local/Homebrew/Library/Homebrew/os/mac.rb:58:in `prerelease?'
     3: from /usr/local/Homebrew/Library/Homebrew/os/mac.rb:24:in `version'
     2: from /usr/local/Homebrew/Library/Homebrew/os/mac.rb:24:in `new'
     1: from /usr/local/Homebrew/Library/Homebrew/os/mac/version.rb:26:in `initialize'
/usr/local/Homebrew/Library/Homebrew/version.rb:368:in `initialize': Version value must be a string; got a NilClass () (TypeError)

I tried by deleting the folder /Library/Developer/CommandLineTools and installing the Command Line Tools for Xcode 12.3 beta but still I am getting the same error. Is there any way to make brew work?

3
  • 2
    You should run brew doctor, fix the warnings, then try again. I don’t have any issue.
    – bfontaine
    Commented Nov 13, 2020 at 13:52
  • 1
    I faced the same error. The reason was the installed Homebrew's version was too old. I've run cd /opt/homebrew; git fetch; git reset --hard origin/master (my homebrew's dir is /opt/homebrew). It worked well for me. Commented Nov 14, 2020 at 12:43
  • Try resetting the xcode-select with sudo xcode-select -r xcode-select -p should give /Applications/Xcode.app/Contents/Developer ~
    – sdayal
    Commented Nov 14, 2020 at 12:48

11 Answers 11

202

You should update brew;

brew update-reset
9
  • Works for me. The warning message is gone.
    – Leonardo
    Commented Nov 20, 2020 at 14:35
  • 1
    I was performing a brand new install, not an update, on Big Sur, and got a completely different error message, but the update-reset command worked for me. Thanks! Here was my error message in case it helps anyone else: "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." Commented Jan 19, 2021 at 1:03
  • 7
    I had to do this before I could do brew upgrade.
    – John
    Commented Jan 29, 2021 at 1:34
  • 1
    This worked for me, thank you so much for the help. I'd tried brew update but didn't know about the update-reset command. Cheers!
    – nhuesmann
    Commented Jul 2, 2021 at 22:28
  • 1
    This should be the answer - cleared up the many problems brew was having. After I ran brew update-reset I could then run brew upgrade and the many outdated packages installed successfully!
    – rushkeldon
    Commented Aug 10, 2021 at 1:06
103

I had the same problem. Try upgrading brew - this solved it for me.

brew upgrade
2
  • 1
    I encountered a handful of errors while running this on macOS Big Sur, including: File ownership, File permissions, Xcode outdated
    – vsm
    Commented Feb 23, 2021 at 17:55
  • 10
    I got the same error running this command.
    – Searene
    Commented Mar 16, 2021 at 8:49
16

I have solved my problem reinstalling brew with this script (install.sh):

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

Then:

brew --version

output:

Homebrew 3.0.1
Homebrew/homebrew-core (git revision 47e5d; last commit 2021-02-14)

Then just proceed with: xcode-select --install

12

After upgrading brew

brew upgrade

I got the following message:

Your Command Line Tools (CLT) does not support macOS 11.
It is either outdated or was modified.
Please update your Command Line Tools (CLT) or delete it if no updates are 
available.
Update them from Software Update in System Preferences or run:
  softwareupdate --all --install --force

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/more/.

Error: An exception occurred within a child process:

According to the instructions I ran the following commands:

sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install

and again ran

brew upgrade

And finally it worked.

1
  • That's exactly what I did. There are no updates for command line tools available yet homebrew refuses to run.
    – VityaSchel
    Commented Oct 7, 2024 at 5:36
7

If you run brew upgrade still meet the error, maybe you should run brew update first.

My experience is:

1. brew update
2. brew doctor
3. brew upgrade
1
  • 1
    Warning: You are using macOS 11.0. We do not provide support for this released but not yet supported version. You will encounter build failures with some formulae. Please create pull requests instead of asking for help on Homebrew's GitHub, Twitter or any other official channels. You are responsible for resolving any issues you experience while you are running this released but not yet supported version.
    – Takatjuta
    Commented Nov 18, 2020 at 3:00
6

I had MacOS Big Sur & nothing work for me even all answers of this question But Except one thing works with me:

brew update-reset
1
  • 1
    This also gives the same error as the OP in Sonoma for me
    – Dwebtron
    Commented Aug 6, 2024 at 4:21
5

I had the same problem, "brew update" wouldn't work, "brew upgrade" also didn't work, did the following:

brew update-reset

and then

brew upgrade

Now working fine.

Cheers,

H

1

When I follow @andrmu instructions, I received an error stating Homebrew: Your CLT does not support macOS 11.0.. I had to first follow the instructions to clean upgrade my command line tools as per the top answer on this issue, then it worked..

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

This worked for me

0

After brew upgrade this did the trick to avoid tmp/mysql.sock error. Use commandline command:

sudo chmod -R 0777 /usr/local/var/mysql/
0

This error occurred due to a path issue for me. The following instructions are part of the installation itself. Just need to pay attention :)

echo >> /Users/wolverinemaho/.zprofile

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/wolverinemaho/.zprofile

eval "$(/opt/homebrew/bin/brew shellenv)"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.