Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Working version of Homebrew for OS X 10.10

Working version of Homebrew for OS X 10.10

The only way to get working Homebrew on OS X 10.10 for now (10.10 beta was just released a couple of hours ago) is by using an special fork by @jacknagel available at

To install this working version of Homebrew just execute:

ruby -e "$(curl -fsSL"

# This script installs to /usr/local only. To install elsewhere you can just
# untar anywhere you like or
# change the value of HOMEBREW_PREFIX.
HOMEBREW_PREFIX = '/usr/local'
HOMEBREW_CACHE = '/Library/Caches/Homebrew'
module Tty extend self
def blue; bold 34; end
def white; bold 39; end
def red; underline 31; end
def reset; escape 0; end
def bold n; escape "1;#{n}" end
def underline n; escape "4;#{n}" end
def escape n; "\033[#{n}m" if STDOUT.tty? end
class Array
def shell_s
cp = dup
first = cp.shift{ |arg| arg.gsub " ", "\\ " }.unshift(first) * " "
def ohai *args
puts "#{}==>#{Tty.white} #{args.shell_s}#{Tty.reset}"
def warn warning
puts "#{}Warning#{Tty.reset}: #{warning.chomp}"
def system *args
abort "Failed during: #{args.shell_s}" unless Kernel.system(*args)
def sudo *args
ohai "/usr/bin/sudo", *args
system "/usr/bin/sudo", *args
def getc # NOTE only tested on OS X
system "/bin/stty raw -echo"
if STDIN.respond_to?(:getbyte)
system "/bin/stty -raw echo"
def wait_for_user
puts "Press RETURN to continue or any other key to abort"
c = getc
# we test for \r and \n because some stuff does \r instead
abort unless c == 13 or c == 10
module Version
def <=>(other)
split(".").map { |i| i.to_i } <=> other.split(".").map { |i| i.to_i }
def macos_version
@macos_version ||= `/usr/bin/sw_vers -productVersion`.chomp[/10\.\d+/].extend(Version)
def git
@git ||= if ENV['GIT'] and File.executable? ENV['GIT']
elsif Kernel.system '/usr/bin/which -s git'
exe = `xcrun -find git 2>/dev/null`.chomp
exe if $? && $?.success? && !exe.empty? && File.executable?(exe)
return unless @git
# Github only supports HTTPS fetches on 1.7.10 or later:
`#{@git} --version` =~ /git version (\d\.\d+\.\d+)/
return if $1.nil? or $1.extend(Version) < "1.7.10"
# Invalidate sudo timestamp before exiting
at_exit { Kernel.system "/usr/bin/sudo", "-k" }
# The block form of Dir.chdir fails later if Dir.CWD doesn't exist which I
# guess is fair enough. Also sudo prints a warning message for no good reason
Dir.chdir "/usr"
####################################################################### script
abort "MacOS too old, see:" if macos_version < "10.5"
abort "Don't run this as root!" if Process.uid == 0
abort <<-EOABORT unless `groups`.split.include? "admin"
This script requires the user #{ENV['USER']} to be an Administrator. If this
sucks for you then you can install Homebrew in your home directory or however
you please; please refer to our homepage. If you still want to use this script
set your user to be an Administrator in System Preferences or `su' to a
non-root user with Administrator privileges.
abort <<-EOABORT unless Dir["#{HOMEBREW_PREFIX}/.git/*"].empty?
It appears Homebrew is already installed. If your intent is to reinstall you
should do the following before running this installer again:
rm -rf #{HOMEBREW_PREFIX}/Cellar #{HOMEBREW_PREFIX}/.git && brew cleanup
# Tests will fail if the prefix exists, but we don't have execution
# permissions. Abort in this case.
abort <<-EOABORT if HOMEBREW_PREFIX and not File.executable? HOMEBREW_PREFIX
The Homebrew prefix, #{HOMEBREW_PREFIX}, exists but is not searchable. If this is
not intentional, please restore the default permissions and try running the
installer again:
sudo chmod 775 #{HOMEBREW_PREFIX}
ohai "This script will install:"
puts "#{HOMEBREW_PREFIX}/bin/brew"
puts "#{HOMEBREW_PREFIX}/Library/..."
puts "#{HOMEBREW_PREFIX}/share/man/man1/brew.1"
chmods = %w( . bin etc include lib lib/pkgconfig Library sbin share var var/log share/locale share/man
share/man/man1 share/man/man2 share/man/man3 share/man/man4
share/man/man5 share/man/man6 share/man/man7 share/man/man8
share/info share/doc share/aclocal ).
map{ |d| "#{HOMEBREW_PREFIX}/#{d}" }.
select{ |d| d and (not File.readable? d or not File.writable? d or not File.executable? d) }
chgrps = chmods.reject{ |d| File.stat(d).grpowned? }
unless chmods.empty?
ohai "The following directories will be made group writable:"
unless chgrps.empty?
ohai "The following directories will have their group set to #{Tty.underline 39}admin#{Tty.reset}:"
wait_for_user if STDIN.tty?
sudo "/bin/chmod", "g+rwx", *chmods unless chmods.empty?
sudo "/usr/bin/chgrp", "admin", *chgrps unless chgrps.empty?
sudo "/bin/mkdir", HOMEBREW_PREFIX
sudo "/bin/chmod", "g+rwx", HOMEBREW_PREFIX
# the group is set to wheel by default for some reason
sudo "/usr/bin/chgrp", "admin", HOMEBREW_PREFIX
sudo "/bin/mkdir", HOMEBREW_CACHE unless HOMEBREW_CACHE
sudo "/bin/chmod", "g+rwx", HOMEBREW_CACHE
if macos_version >= "10.9"
developer_dir = `/usr/bin/xcode-select -print-path 2>/dev/null`.chomp
if developer_dir.empty? || !File.exist?("#{developer_dir}/usr/bin/git")
ohai "Installing the Command Line Tools (expect a GUI popup):"
sudo "/usr/bin/xcode-select", "--install"
puts "Press any key when the installation has completed."
ohai "Downloading and installing Homebrew..."
if git
# we do it in four steps to avoid merge errors when reinstalling
system git, "init", "-q"
system git, "remote", "add", "origin", ""
args = git, "fetch", "origin", "rb2:refs/remotes/origin/rb2", "-n"
args << "--depth=1" if ARGV.include? "--fast"
system git, "reset", "--hard", "origin/rb2"
# -m to stop tar erroring out if it can't modify the mtime for root owned directories
# pipefail to cause the exit status from curl to propogate if it fails
# we use -k for curl because Leopard has a bunch of bad SSL certificates
curl_flags = "fsSL"
curl_flags << "k" if macos_version <= "10.5"
system "/bin/bash -o pipefail -c '/usr/bin/curl -#{curl_flags} | /usr/bin/tar xz -m --strip 1'"
warn "#{HOMEBREW_PREFIX}/bin is not in your PATH." unless ENV['PATH'].split(':').include? "#{HOMEBREW_PREFIX}/bin"
ohai "Installation successful!"
ohai "Next steps"
if macos_version < "10.9" and macos_version > "10.6"
`/usr/bin/cc --version 2> /dev/null` =~ %r[clang-(\d{2,})]
version = $1.to_i
puts "Install the #{Tty.white}Command Line Tools for Xcode#{Tty.reset}:" if version < 425
puts "Install #{Tty.white}Xcode#{Tty.reset}:" unless File.exist? "/usr/bin/cc"
puts "Run `brew doctor` #{Tty.white}before#{Tty.reset} you install anything"
puts "Run `brew help` to get started"

tcarlsen commented Jun 3, 2014

will this work then doing a brew update ?? I tried adding the remote myself but a brew update would chance to master and I had to remerge to the rb2 branch..

Another thing then using the rb2 branch I cant get brew cask to work.. any idea?

$ brew cask
Error: Unknown command: cask

jpincheira commented Jun 3, 2014

@tcarlsen, sorry, I didn't try with a brew update. I removed brew completely and then just executed this and it works fine.

koenpunt commented Jun 3, 2014

It's not the only way, I extracted the 1.8 Ruby version from the Mavericks installer and that worked fine as well.

kwent commented Jun 3, 2014

This is working fine. Thank you.

zaur commented Jun 3, 2014

brew doctor
Error: No such file or directory - /Library/Developer/CommandLineTools/usr/bin/clang

danscan commented Jun 3, 2014

@zaur I'm also getting the Error: No such file or directory - /Library/Developer/CommandLineTools/usr/bin/clang error when running brew doctor.

That branch appears to have been removed. Is there another solution?

It worked for me. Anyway, there is already official fix Homebrew/homebrew#29795

ahmetb commented Jun 4, 2014

The command in the gist is not working for me:

==> Downloading and installing Homebrew...
fatal: Couldn't find remote ref rb2
Unexpected end of command stream
Failed during: git fetch origin rb2:refs/remotes/origin/rb2 -n

Is rb2 branch still there?

indrayam commented Jun 4, 2014

Same here.

indrayam commented Jun 4, 2014

Never mind. It seems the core install works on 10.10. Although brew doctor command keeps failing. Does not seem to be a show stopper so far

koenpunt commented Jun 5, 2014

Homebrew has been updated to use the Current Ruby version, so a simple git pull will probably suffice:

cd /usr/local && git pull origin master

iesta commented Jun 5, 2014

I get :
error: Untracked working tree file '.gitignore' would be overwritten by merge.

I'm getting this error when doing the pull.. Any ideas?
➜ local git:(master) git pull origin master /Applications/ line 11: git-sh-setup: No such file or directory ➜ local git:(master)

@iesta Maybe try doing git checkout -- .gitignore first?

ryangurn commented Jun 6, 2014

I get the same error

fatal: Couldn't find remote ref rb2
Unexpected end of command stream
Failed during: git fetch origin rb2:refs/remotes/origin/rb2 -n

How should I go about fixing this?

Same error here

==> This script will install:
==> The following directories will be made group writable:
==> The following directories will have their group set to admin:

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/etc
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/etc
==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
==> Downloading and installing Homebrew...
fatal: Couldn't find remote ref rb2
Unexpected end of command stream
Failed during: git fetch origin rb2:refs/remotes/origin/rb2 -n


jpincheira commented Jun 27, 2014

Thanks for posting an update @Spharian 👍

I worked around this issue by updating brew with git instead of my broken brew command:

cd /usr/local/Library/
git branch --set-upstream-to=origin/master master
# on branch master
git pull

katrotz commented Nov 28, 2014

Thanks, that worked:

cd /usr/local && git pull origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment