brew update returns 403 Forbidden while accessing

Created on 7 Jun 2016  ·  18Comments  ·  Source: Homebrew/brew

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

user configuration

Most helpful comment

$ 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.

All 18 comments

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).

brew doctor result on gist

Content of /usr/local/.git/config:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
        autocrlf = false
[remote "origin"]
        url = https://github.com/Homebrew/brew.git
        fetch = +refs/heads/*:refs/remotes/origin/*

Content of ~/.gitconfig:

[user]
        name = franc walter
        email = [email protected]
[filter "lfs"]
        clean = git-lfs clean %f
        smudge = git-lfs smudge %f
        required = true
$ git remote -v
origin  https://github.com/Homebrew/brew.git (fetch)
origin  https://github.com/Homebrew/brew.git (push)
$ git fetch origin
remote: Counting objects: 58144, done.
remote: Compressing objects: 100% (15252/15252), done.
remote: Total 58144 (delta 41619), reused 57743 (delta 41231), pack-reused 0
Receiving objects: 100% (58144/58144), 8.58 MiB | 326.00 KiB/s, done.
Resolving deltas: 100% (41619/41619), completed with 390 local objects.
From https://github.com/Homebrew/brew
 + dde20cd...21ca138 master     -> origin/master  (forced update)

Thank for the help!

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.

OK, after:

$ git checkout --force -B master origin/master
Branch master set up to track remote branch master from origin.
Reset branch 'master'
FRANC-MACBOOK:local f$ brew --version
Homebrew 0.9.9 (git revision 21ca; last commit 2016-06-07)
Homebrew/homebrew-core (git revision d6ae; last commit 2016-06-07)

This shows indeed 0.9.9! But then:

$ brew update
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/Homebrew/homebrew-core/info/refs

fatal: HTTP request failed
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/caskroom/homebrew-cask/info/refs

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

fatal: HTTP request failed
Error: Fetching /usr/local/Library/Taps/homebrew/homebrew-core failed!
Fetching /usr/local/Library/Taps/caskroom/homebrew-cask failed!
Fetching /usr/local failed!
==> Homebrew has enabled anonymous aggregate user behaviour analytics
Read the analytics documentation (and how to opt-out) here:
  https://git.io/brew-analytics
==> Cleaning up /Library/Caches/Homebrew...
Removing: /Library/Caches/Homebrew/ffmpeg-3.0.el_capitan.bottle.tar.gz... (18.2M)
Removing: /Library/Caches/Homebrew/openssl-1.0.2d_1.el_capitan.bottle.tar.gz... (3.5M)
Removing: /Library/Caches/Homebrew/openssl-1.0.2g.el_capitan.bottle.tar.gz... (3.6M)
Removing: /Library/Caches/Homebrew/x264-r2601.el_capitan.bottle.tar.gz... (1.3M)
==> Migrating /Library/Caches/Homebrew to /Users/f/Library/Caches/Homebrew...
==> Deleting /Library/Caches/Homebrew...
Error: Could not link caskroom/cask manpages to:
  /usr/local/share/man/man1/brew-cask.1

Please delete these files and run `brew tap --repair`.

Again I did brew update:

$ brew update
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/Homebrew/homebrew-core/info/refs

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

fatal: HTTP request failed
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/caskroom/homebrew-cask/info/refs

fatal: HTTP request failed
Error: Fetching /usr/local/Library/Taps/homebrew/homebrew-core failed!
Fetching /usr/local failed!
Fetching /usr/local/Library/Taps/caskroom/homebrew-cask failed!
Error: Could not link caskroom/cask manpages to:
  /usr/local/share/man/man1/brew-cask.1

Please delete these files and run `brew tap --repair`.

And I dont know which file I should delete...
And the repair:

$ brew tap --repair
Error: Could not link caskroom/cask manpages to:
  /usr/local/share/man/man1/brew-cask.1

Please delete these files and run `brew tap --repair`.

tells me again to delete these files. Which? The /usr/local/share/man/man1/brew-cask.1 ?

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.

$ brew remove --force brew-cask
Uninstalling brew-cask... (2,731 files, 1.5M)

did uninstall it.

$ rm /usr/local/share/man/man1/brew-cask.1
rm: Entfernen von „/usr/local/share/man/man1/brew-cask.1“ nicht möglich: No such file or directory

and then the brew-cask.1 file seems gone.

$ brew tap --repair and env | grep -i proxy
gives no result.

But the update keeps errors:

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

fatal: HTTP request failed
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/Homebrew/homebrew-core/info/refs

fatal: HTTP request failed
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/caskroom/homebrew-cask/info/refs

fatal: HTTP request failed
Error: Fetching /usr/local failed!
Fetching /usr/local/Library/Taps/homebrew/homebrew-core failed!
Fetching /usr/local/Library/Taps/caskroom/homebrew-cask failed!
Current branch master is up to date.
Current branch master is up to date.
Current branch master is up to date.

Why do I get this 403 Forbidden error? This seems unnormal!

I just don't see the cause of this error

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 …

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?

brew update --debug --verbose on gist

$ which git
/usr/local/git/bin/git
$ git --version
git version 2.4.3
$ brew unlink git
Error: No such keg: /usr/local/Cellar/git
$ 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.

Hurra:

$ brew update
Updated Homebrew from 21ca138 to 11d47e8.
Updated 2 taps (caskroom/cask, homebrew/core).
==> Updated Formulae
app-engine-go-32       doctl                  gst-libav              hevea                  passenger              swiftlint            
app-engine-go-64       emojify                gst-plugins-bad        homebank               postgrest              the_platinum_searcher
app-engine-python      git                    gst-plugins-base       hunspell               psql2csv               vim                  
aws-sdk-cpp            gitup                  gst-plugins-good       imagemagick            qt5                    wakatime-cli         
awscli                 gnutls                 gst-plugins-ugly       kobalt                 rack                   webkitgtk            
bitrise                gor                    gst-python             loudmouth              redpen                 wimlib               
cake                   groovy                 gst-validate           macosvpn               snappystream           wireshark            
cgrep                  groovysdk              gstreamer              msgpack                stlink                 xonsh                
chromedriver           gst-editing-services   headphones             nim                    swiftgen               zsh-navigation-tools 
==> Deleted Formulae
memo                                                                   powerline  

You did it!
You exactly right, the git was wrong. Long ago I had (think from a previous OS) a very and too old git version, I vaguely remember, 1.6.5, and I updated to this at that time new 2.4.3, put it in the path and forgot it.
Now I had three versions of git, still this old 1.6.5 in:
/usr/local/bin/git, so I renamed it:
mv /usr/local/bin/git /usr/local/bin/git.1.6.5
and I took off the path of this also old 2.4.3 and renamed it too:
mv /usr/local/git/bin/git /usr/local/git/bin/git.2.4.3
and now I get a true:

$ git --version
git version 2.7.4 (Apple Git-66)
$ which git
/usr/bin/git

The system git now is acutal enough I hope, I mean more actual than my older stuff which I had needed once, why ever (dont remember).

Thank you very much and for your patience!

You're welcome! I'm glad we were able to figure out the problem at last. 😺

Just to add another data point on this issue, I was facing a similar issue:

$ brew update
error: The requested URL returned error: 403 Forbidden while accessing
https://github.com/Homebrew/homebrew-core/info/refs

fatal: HTTP request failed
Error: Fetching /usr/local/Library/Taps/homebrew/homebrew-core failed!

Doing the update manually enables things to work again:

cd /usr/local/Library/Taps/homebrew/homebrew-core
git reset
git fetch

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?

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.

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.

@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.

@MikeMcQuaid I agree that a version check could be useful, at least in brew doctor. I think we can basically keep the lookup order, but we should really avoid shifting /usr/bin to the end of the list so that other custom paths in PATH get prioritized. I think this is very counterintuitive (as the above two cases illustrate nicely). I have experimented with a few modifications locally and will try to prepare a PR soon.

Found this thread and was able to resolve simply by updating Git.

Was this page helpful?
0 / 5 - 0 ratings