[macOS] Installing Homebrew (and Git While We're at It)

Tadashi Shigeoka ·  Sun, September 11, 2011

I’ll introduce how to install Homebrew, a package management tool for macOS. (Last updated: April 9, 2020)

・Official: Homebrew — MacPorts driving you to drink? Try Homebrew!

The key point of Homebrew is that it uses the environment that’s already included in the system as-is, allowing for smooth initial environment setup.

Homebrew Installation

Install Homebrew from GitHub using a Ruby script.

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

After installation is complete, run brew doctor.

$ brew doctor

Error: Experimental support for using Xcode without the "Command Line Tools".

You’re told to install Command Line Tools, so:

In Xcode's menu: Xcode->Open Developer tool -> More Developer tool Click this and download Command Line Tool for Xcode from the destination. Download and install it like a normal application.

Run brew doctor again.

$ brew doctor
Your system is ready to brew.

OK!

Since Homebrew itself uses Git, we’ll install Git first.

After installation, immediately update.

$ brew install git

$ brew update
 
$ brew -v
0.9.4

========

If brew install git fails with an error, it might be because the kernel.org site is unavailable. (This time kernel.org was under maintenance and unusable.)

In this case, you need to edit git.rb in the Formula and rewrite the download URL.

$ vim /usr/local/Library/Formula/git.rb

By default, it looks like this:

class GitManuals < Formula
  url 'http://kernel.org/pub/software/scm/git/git-manpages-1.7.6.1.tar.bz2'
  md5 'cae559424a62507cb2c15252d85a158e'
end

class GitHtmldocs < Formula
  url 'http://kernel.org/pub/software/scm/git/git-htmldocs-1.7.6.1.tar.bz2'
  md5 'f698e0abbf1555582e30320930391c59'
end

class Git < Formula
  url 'http://kernel.org/pub/software/scm/git/git-1.7.6.1.tar.bz2'
  md5 'd1e00772cc9dc6c571999feb9e8771ab'

Rewrite it as follows:

class GitManuals < Formula
  url 'http://ftp.uk.freesbie.org/sites/ftp.kernel.org/pub/software/scm/git-core/git-manpages-1.7.6.1.tar.bz2'
  md5 'cae559424a62507cb2c15252d85a158e'
end

class GitHtmldocs < Formula
  url 'http://ftp.ntu.edu.tw/ftp/pub2/software/scm/git/git-htmldocs-1.7.6.1.tar.bz2'
  md5 'f698e0abbf1555582e30320930391c59'
end

class Git < Formula
  url 'https://github.com/git/git/tarball/v1.7.6.1'
  md5 'ab731cf9b99529f3f8d126aa15d9a1cd'

If kernel.org is down like this time, rewrite to mirror site URLs.

Index of /pub/software/scm/git

・Git-related mirror sites: Index of /ftp/pub2/software/scm/git/

・Git mirror sites: Downloads for git’s git - GitHub

Reference Information

First Homebrew Installation. #install #environment #homebrew - Qiita

[homebrew]Homebrew Installation Memo | milligramme 3cc

Memo of What I Did After Buying OS X Lion MacBook Air to Set Up Rails Development Environment | Wild Log is Noro Cure MaxHeart

Installation - GitHub

homebrew - alternative source for installing git. brew install git; kernel.org Down for maintenance - Stack Overflow

That’s all from the Gemba.