brew: brew update returns 403 Forbidden while accessing

I haven’t used brew and brew update since a while, I installed it along this HowTo

brew doctor shows only warnings, no errors. sudo chown -R $(whoami) $(brew --prefix) doesn’t show errors, all permissions of owner is set to user

Bug reports:

When I try to update brew (I tried many times) I get the error:

$ brew update
warning: Option "depth" is ignored for https://github.com/Homebrew/brew.git

error: The requested URL returned error: 403 Forbidden while accessing https://github.com/Homebrew/brew.git/info/refs

fatal: HTTP request failed

brew version is:

$ brew --version
Homebrew 0.9.8 (git revision dde20; last commit 2016-06-04)
Homebrew/homebrew-core (git revision d6ae; last commit 2016-06-07)

I have a MacBook Pro (Mid 2009) with OS 10.11.5 I read the Troubleshooting list without success. I read issue #11221 of brew legacy, but think that is not related. XCode 7.3.1 is uptodate (including CLT). What can be wrong? Thank, frank

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (10 by maintainers)

Commits related to this issue

Most upvoted comments

$ which git
/usr/local/git/bin/git

Where does this custom Git installation come from? That’s not the system Git and also not installed via Homebrew. Additionally, it is a bit outdated. Can you please try removing it from your PATH such that which git outputs /usr/bin/git and git --version outputs git version 2.7.4 (Apple Git-66)?

You might need to run hash -r if your shell prints an error message that is something like “No such file or directory” or continues to invoke the old Git even after you changed the PATH.

@UniqMartin sounds like we should follow that logic but also check the version to ensure that we only use a Git that’s got a high enough version to e.g. handle GitHub’s HTTPS.

Thanks for your input @dougreese and thank you for following up on my mail!

Turns out I had a version of git installed in /usr/local/git/libexec/git-core/git. It was a pretty old version 1.6.4 (from a previous OS version, I’m guessing), and it was in my path but not before the default installed /usr/bin/git. So the brew update command is using a different version of git than what is used when run from the command prompt manually. Why is that?

The lookup logic is actually quite complicated and does a lot more than just looking in PATH:

  1. If HOMEBREW_GIT is set in the environment, try that.
  2. If GIT is set in the environment, try that.
  3. If the git formula is installed, try that.
  4. Iterate over all git binaries in PATH, but exclude /usr/bin/git because it might be a non-functional popup stub if neither Xcode nor Command Line Tools are installed.
  5. Try locating a git binary using xcrun -find git.
  6. Try using git from Xcode if it is installed in /Applications/Xcode.app.
  7. Try /usr/bin/git if all else failed and we’re sure it’s not a popup stub.
  8. Give up.

The first item from that list that matches wins. Now that I’ve written down the logic, I’m no longer sure this is what should be happening. You might just have helped uncover a bug (or misfeature) in our code. I’ll ponder this a bit and check whether we want to improve on that. (In any case, this rundown should help understand why it was picking the “wrong” Git on your machine, probably in step 4.)

It might be helpful if the output brew config contained the path to git and its version as well as the other tools being used.

This is a good suggestion; I agree! Homebrew relies quite a bit on a working Git installation, thus including things like its version and installation path would be valuable information in brew config.

And: What is the output of which git and git --version? Are you using the system git on or did you install it via Homebrew? If the latter, could you temporarily unlink it via brew unlink git, check that git --version returns something like git version 2.7.4 (Apple Git-66), and then try brew update again?

To be honest, I’m also running out of ideas right now. Can you give it one more try, but this time with the --debug flag, i.e. brew update --debug --verbose and post the output? Hopefully this provides a bit more information and helps me understand where it’s actually failing and why …

Alright, first to fix the errors relating to /usr/local/share/man/man1/brew-cask.1:

brew remove --force brew-cask
rm /usr/local/share/man/man1/brew-cask.1
brew tap --repair

Back to the update issue, I’m not sure yet what is going on. Are you using a proxy that might be causing this issue? What is the output of env | grep -i proxy?

Please also try one more time with brew update --verbose and post the output of this command.

You have quite a few warnings in your brew doctor output, but nothing that would explain the trouble. Your Git configuration also looks fine and manually fetching with git fetch origin seems to work. I suppose you haven’t made any customizations to Homebrew itself, thus please try the following:

cd "$(brew --repository)"
git checkout --force -B master origin/master

If this doesn’t print an error, run brew --version first (it should be printing “Homebrew 0.9.9”) and then give brew update one more try. I’m somewhat hopeful it will work this time.


Unrelated to the problem at hand, but if you can, try to fix some of the warnings printed by brew doctor. E.g. the complaint about a duplicate brew-cask is because Homebrew Cask no longer needs to be installed as a formula. You can run brew remove brew-cask and brew cask will continue to work as usual.

brew doctor shows only warnings, no errors.

Can you please post the output of brew doctor? All it outputs is just warnings, but one of them might be responsible for the behavior you are seeing.

When I try to update brew (I tried many times) I get the error:

Can you please post the contents of /usr/local/.git/config and your own .gitconfig in your home directory? (Make sure the latter doesn’t contain sensitive information you don’t want to post publicly.) The update issue sounds like some Git configuration problem, so seeing those files would be really helpful.

What happens if you do the following? (Please also post the output of these commands.)

cd "$(brew --repository)"
git remote -v
git fetch origin

brew version is:

$ brew --version
Homebrew 0.9.8 (git revision dde20; last commit 2016-06-04)
Homebrew/homebrew-core (git revision d6ae; last commit 2016-06-07)

This looks really suspicious. Something went wrong with the migration to the new Homebrew repository and you’re stuck with Homebrew 0.9.8. It should be showing “Homebrew 0.9.9”, but the problem is probably related to the update issue (that might be related to a Git configuration problem).