Thrift 0.9.3 on Mac OS

The Problem

At some point Homebrew was updated to provide Thrift 0.10.0 and it would appear that the ability to install older versions was removed. At the time I couldn't find a easy way to install the old version.

Searching Homebrew shows:

-> % brew search thrift
homebrew/versions/thrift090                                         thrift ✔
homebrew/php/php53-thrift         homebrew/php/php54-thrift         homebrew/php/php55-thrift         homebrew/php/php56-thrift

Inspecting thrift090 shows it uses 0.9.0 (as the name suggests):

-> % brew edit thrift090 | head
# The 0.9.0 tag in homebrew repository isn't working in OSX Mavericks
# this version fixes Cpp11 problems about syntax and tr1 headers
# All patches and this file can be found in this public gist:
# https://gist.githubusercontent.com/rafaelverger/58b6eeafaae7d28b06cc
class Thrift090 < Formula
  desc "Framework for scalable cross-language services development"
  homepage "https://thrift.apache.org"
  url "https://archive.apache.org/dist/thrift/0.9.0/thrift-0.9.0.tar.gz"
  sha256 "71d129c49a2616069d9e7a93268cdba59518f77b3c41e763e09537cb3f3f0aac"

So between StackOverflow and other bits I managed to compose the following process.

Installing

First its probably best to ensure Homebrew is up to date:

brew update

Now we're going to replace the current Thrift Formula with the one for 0.9.3. This can be found by going back in time on GitHub.

The current version is here: https://github.com/Homebrew/homebrew-core/blob/master/Formula/thrift.rb

Looking at the history we can find the 0.9.3 version: https://github.com/Homebrew/homebrew-core/blob/9d524e4850651cfedd64bc0740f1379b533f607d/Formula/thrift.rb

You may need to clone this repository to look at the history as its large and GitHub may refuse to generate it.

First navigate to the Homebrew repository:

cd $(brew --repo)

And then to the Formula folder:

cd Library/Taps/homebrew/homebrew-core/Formula/

Looking at the current Thrift Formula file thrift.rb it's currently using 0.10.0 as expected:

class Thrift < Formula
  desc "Framework for scalable cross-language services development"
  homepage "https://thrift.apache.org/"
  url "https://www.apache.org/dyn/closer.cgi?path=/thrift/0.10.0/thrift-0.10.0.tar.gz"
  sha256 "2289d02de6e8db04cbbabb921aeb62bfe3098c4c83f36eec6c31194301efa10b"
...

Remove the existing Formula:

rm thrift.rb

Note: You can always restore the Formula folder back to its unmodified state by doing running git reset HEAD --hard

Then download the 0.9.3 version:

wget https://raw.githubusercontent.com/Homebrew/homebrew-core/9d524e4850651cfedd64bc0740f1379b533f607d/Formula/thrift.rb

Checking thrift.rb again - it now uses 0.9.3:

class Thrift < Formula
  desc "Framework for scalable cross-language services development"
  homepage "https://thrift.apache.org/"

  stable do
    url "https://www.apache.org/dyn/closer.cgi?path=/thrift/0.9.3/thrift-0.9.3.tar.gz"
    sha256 "b0740a070ac09adde04d43e852ce4c320564a292f26521c46b78e0641564969e"
...

After that it should be easy to install Thrift.

brew install thrift

At any point the Formula can be reverted using the git reset or git checkout commands.