0

I go to https://git-scm.com/downloads to find instructions for installing Git on MacOS. That page directs me to first install Homebrew.

I go to https://brew.sh/ and paste this in my terminal as per the instructions

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

That install script ends in the error message

You must install Git before installing Homebrew. See:
https://docs.brew.sh/Installation

So I go to https://docs.brew.sh/Installation to find out more.

There is nothing on there about how to install Git before homebrew.

Catch22 much?

I see that there is some guy named timcharper who made a binary of Git for use with MacOS. Seems like a big workaround to rely on a private persons binary (also, that's an old version of Git) to break this catch22 issue.

What is the recommended solution here? Seems like I'm stuck in an infinite loop =) Is this a new problem with Ventura?

--------------------------- UPDATE ---------------

Managed to remove the xcode-select version I hade (which apparently lacked git) and reinstalled it. Now I have a fully functional git in my terminal. I have pulled several repo:s.

However, the brew installer is still not happy with my git version and denies install.

mattiaswelander@a ~ % /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
==> Checking for `sudo` access (which may request your password)...
Password:
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew

Press RETURN/ENTER to continue or any other key to abort:
==> /usr/bin/sudo /usr/sbin/chown -R mattiaswelander:admin /usr/local/Homebrew
Unexpected Git version: ''!
You must install Git before installing Homebrew. See:
  https://docs.brew.sh/Installation

mattiaswelander@a ~ % git --version
git version 2.39.2 (Apple Git-143)

--------------- Another update ----------------

So I finally gave in to that binary from sourceforge, even though Apple has a clear warning sign that this binary has not been scanned for malicious code, you open it at your own peril.

but even after doing so, the error in the brew install script remains the same, it is unhappy with my git version.

as is obvious from below, terminal now runs my recently downloaded, much older version of git as suggested at https://git-scm.com/downloads

mattiaswelander@a ~ % git --version
git version 2.39.2 (Apple Git-143)
mattiaswelander@a ~ % git --version
git version 2.15.0

The error process seems to move a little further this time, but in the end it all collapses at the same error - the git version:

Press RETURN/ENTER to continue or any other key to abort:
==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
==> /usr/bin/sudo /usr/sbin/chown mattiaswelander /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
==> /usr/bin/sudo /usr/sbin/chown -R mattiaswelander:admin /usr/local/Homebrew
Unexpected Git version: ''!
You must install Git before installing Homebrew. See:
  https://docs.brew.sh/Installation
Matt Welander
  • 8,234
  • 24
  • 88
  • 138
  • There seem to be other ways to install Git without needing homebrew: https://git-scm.com/download/mac. Perhaps macports or binaries might help. – zedfoxus Apr 24 '23 at 19:55
  • I understand that some binary might help, but shouldn't there be a "right" way of going about it, without that workaround? – Matt Welander Apr 28 '23 at 15:46
  • Whether there should be a `right` way depends on individual philosophies. I don't see this as an infinite loop. Brew says it needs Git. Great. Let me get Git from the different options git scm provides. Once done, I can use brew and git provided by brew. Easy! – zedfoxus Apr 28 '23 at 17:43

1 Answers1

2

Part of the link you posted ( https://docs.brew.sh/Installation ) mentions that the requisites for brew are:

- A 64-bit Intel CPU or Apple Silicon CPU 1
- macOS Big Sur (11) (or higher) 2
- Command Line Tools (CLT) for Xcode (from xcode-select --install or https://developer.apple.com/download/all/) or Xcode 3
- The Bourne-again shell for installation (i.e. bash) 4

The kicker is the "Command Line Tools" portion - that will install all of those little things that are needed in the background, like xcode. xcode will also install git.

Give that a shot - first - the instructions are there in the list, but from a command window, you can type xcode-select --install and that should put you on the right track.

Then, of course, after you install brew, you can go back to installing git.

But note, according to the git installation page ( https://git-scm.com/download/mac ) - xcode ships a binary of git! - so you will get git when you do the xcode-select --install portion, above.

I would recommend also installing brew, when you get through all of this and then using brew to update git according to the directions.

Thomas
  • 36
  • 5
  • 1
    mattiaswelander@myhost ~ % xcode-select --install xcode-select: error: command line tools are already installed, use "Software Update" in System Settings to install updates So it seems CLT already installed, but without git? – Matt Welander Apr 28 '23 at 15:43
  • 1
    Found a fix here: https://stackoverflow.com/questions/34617452/how-to-update-xcode-from-command-line for some reason, many of us have the xcode-select CLT installed, but no functioning git component. And the only way to get it in there seems to be 1: Force remove the directory for the xcode-select CLT (sudo rm -rf /Library/Developer/CommandLineTools), 2: run the install command again (xcode-select --install) – Matt Welander May 01 '23 at 06:27
  • 1
    The reason it gives me git version '' is that it has the ARM version af git installed, but it doesn't understand that, therefore doesn't give a sensible error. I removed the git file from /opt/homebrew/bin and THAT error went away. (Yes, apparently Homebrew was moved over from my other machine). But then a new error emerged, since this homebrew install was moved over from an ARM Mac, more things are broken. Will have to find a way to uninstall it and reinstall I think – Matt Welander May 01 '23 at 15:10