I thought I should mention the very easy Homebrew package installer for Mac OS X. I’ve found it quite simple to use and have not turned back since I blew away my MacPorts.
You can find Homebrew on gitub and you can find the recommended installation instructions there which are as follows.
ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"
This will download the install_homebrew.rb ruby script and execute it in one go. If you are unsure or just curious and can read ruby code you can see this script here
In brief, this script changes permissions on various directories, downloads the Homebrew install files and installs them under /usr/local
Before I ran this install, I blew away my MacPorts installation using these instructions, which suggests the following…
sudo port -f uninstall installed
sudo rm -rf \
/opt/local \
/Applications/DarwinPorts \
/Applications/MacPorts \
/Library/LaunchDaemons/org.macports.* \
/Library/Receipts/DarwinPorts*.pkg \
/Library/Receipts/MacPorts*.pkg \
/Library/StartupItems/DarwinPortsStartup \
/Library/Tcl/darwinports1.0 \
/Library/Tcl/macports1.0 \
~/.macports
Since Apple does not touch /usr/local I cleaned that out too, since anything in there on my Mac would have been installed by MacPorts. Homebrew installs under /usr/local and I wanted it to be nice and clean. Doing this will depend on what you’ve been up to with your Mac.
Some key files that will be installed by the installer are
/usr/local/bin/brew
This script does all the magic of installing, uninstalling, listing installed packages, showing package information and other tasks.
/usr/local/Cellar/
This directory is where the files are installed for the packages you install. You can see some of the package directories I have installed on this machine.
$ ls -dF1 /usr/local/Cellar/* /usr/local/Cellar/bash-completion/ /usr/local/Cellar/geos/ /usr/local/Cellar/git/ /usr/local/Cellar/mongodb/ /usr/local/Cellar/ossp-uuid/ /usr/local/Cellar/pidof/ /usr/local/Cellar/postgis/ /usr/local/Cellar/postgresql/ /usr/local/Cellar/proj/ /usr/local/Cellar/readline/ /usr/local/Cellar/wget/
Once, you’re installed you should be able to run brew install to install packages.
Packages are first downloaded to /Library/Caches/Homebrew/, so if you do uninstall and re-install, you will not have to re-download them a second time.
Here’s a dump of the files my cache directory.
ls -1 /Library/Caches/Homebrew/* /Library/Caches/Homebrew/bash-completion-1.2.tar.bz2 /Library/Caches/Homebrew/geos-3.2.2.tar.bz2 /Library/Caches/Homebrew/git-1.7.3.2.tar.bz2 /Library/Caches/Homebrew/git-htmldocs-1.7.3.2.tar.bz2 /Library/Caches/Homebrew/git-manpages-1.7.3.2.tar.bz2 /Library/Caches/Homebrew/mongodb-1.6.3-x86_64.tgz /Library/Caches/Homebrew/mysql-5.1.51.tar.gz /Library/Caches/Homebrew/ossp-uuid-1.6.2.tar.gz /Library/Caches/Homebrew/pidof-0.1.4.tar.gz /Library/Caches/Homebrew/postgis-1.5.2.tar.gz /Library/Caches/Homebrew/postgresql-9.0.1.tar.bz2 /Library/Caches/Homebrew/proj-4.7.0.tar.gz /Library/Caches/Homebrew/proj-datumgrid-1.5.zip /Library/Caches/Homebrew/readline-6.1.tar.gz /Library/Caches/Homebrew/solr-1.4.1.tgz /Library/Caches/Homebrew/wget-1.12.tar.bz2
I will demonstrate installing Mongodb, which is a “scalable, high-performance, open source, document-oriented database”. Think “NoSQL”.
brew install mongodb
Here’s the output
==> Downloading http://fastdl.mongodb.org/osx/mongodb-osx-x86_64-1.6.3.tgz
######################################################################## 100.0%
==> Caveats
If this is your first install, automatically load on login with:
cp /usr/local/Cellar/mongodb/1.6.3-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
If this is an upgrade and you already have the org.mongodb.mongod.plist loaded:
launchctl unload -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
cp /usr/local/Cellar/mongodb/1.6.3-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
Or start it manually:
mongod run --config /usr/local/Cellar/mongodb/1.6.3-x86_64/mongod.conf
==> Summary
/usr/local/Cellar/mongodb/1.6.3-x86_64: 16 files, 83M, built in 2 seconds
A command I really like is the info command.
brew info mongodb
It will give you all the information you need for a particular package for starting, stopping, restarting or other actions pertinent the service you installed. If will be similar to the information output when you first install a package. It’s good to know about this command so that you can always find the maintenance commands.
Here is an example of the info command for the postgresql package.
brew info postgresql
postgresql 9.0.1
http://www.postgresql.org/
Depends on: readline, ossp-uuid
/usr/local/Cellar/postgresql/9.0.1 (1229 files, 25M)
If builds of Postgresl 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
http://github.com/mxcl/homebrew/issues/issue/2510
To build plpython against a specific Python, set PYTHON prior to brewing:
PYTHON=/usr/local/bin/python brew install postgresql
See:
http://www.postgresql.org/docs/9.0/static/install-procedure.html
If this is your first install, create a database with:
initdb /usr/local/var/postgres
If this is your first install, automatically load on login with:
cp /usr/local/Cellar/postgresql/9.0.1/org.postgresql.postgres.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
If this is an upgrade and you already have the org.postgresql.postgres.plist loaded:
launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
cp /usr/local/Cellar/postgresql/9.0.1/org.postgresql.postgres.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
Or start manually with:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
And stop with:
pg_ctl -D /usr/local/var/postgres stop -s -m fast
If you want to install the postgres gem, including ARCHFLAGS is recommended:
env ARCHFLAGS="-arch x86_64" gem install pg
To install gems without sudo, see the Homebrew wiki.
http://github.com/mxcl/homebrew/commits/master/Library/Formula/postgresql.rb
brew list will tell you which packages are installed.
brew help will give you the following
Usage: brew [-v|--version] [--prefix [formula]] [--cache [formula]]
[--cellar [formula]] [--config] [--env] [--repository]
[-h|--help] COMMAND [formula] ...
Principle Commands:
install formula ... [--ignore-dependencies] [--HEAD]
list [--unbrewed|--versions] [formula] ...
search [/regex/] [substring]
uninstall formula ...
update
Other Commands:
info formula [--github]
options formula
deps formula
uses formula [--installed]
home formula ...
cleanup [formula]
link formula ...
unlink formula ...
outdated
missing
prune
doctor
Informational:
--version
--config
--prefix [formula]
--cache [formula]
Commands useful when contributing:
create URL
edit [formula]
audit [formula]
log formula
install formula [-vd|-i]
For more information:
man brew
To visit the Homebrew homepage type:
brew home
I hope you find this quick intro to Homebrew helpful. Please leave a comment to question.



Out of curiosity why do you use sudo for all your commands. The docs specifically explain why that is a bad idea. A simple one time `sudo chown -R $USER /usr/local` fixes that issue. This makes life so much easier. sudo opens up a lot of opportunities to really blow things up. Your putting complete trust that there isn’t a bug or mistake in the hundreds of formula scripts. And entering in a password every time you use the brew command is a hassle.
Thanks Sukima. You are absolutely right. Force of habit. I’ve edited the text to remove “sudo” for the brew commands.
[...] Wie bei allen Dingen, die stark ins System eingreifen, funktionierte bei mir der empfohlene Weg der Installation von ‘homebrew’ mal wieder nicht. Google sei Dank fand ich (kurz bevor ich alle Haare verlor) diesen wertvollen Link zur einfachen Installation des neuen ‘macports’ oder ‘fink’. Ein Befehl in der console und es wuppt! 2 thumbs up to heaven!!! Und hier ist der wertvolle Link. [...]
Stumbled across your post and because of that I read about homebrew… Just wanted to say thanks a lot! I was struggling like hell to get postgis working… and it works flawlessly now
Upon doing the ruby command, I’m getting
curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Though you have -k in the keys already. Any idea of what I could try? I’ve Mac OS 10.5.8.
Exactly the same issue. Also using 10.5.8
I’m on 10.6.7, so hard to debug your exact issue. The latest documentation on the homebrew Github site https://github.com/mxcl/homebrew#readme is
/usr/bin/ruby -e “$(curl -fsSL https://raw.github.com/gist/323731)”
If that does not work, then please submit a report here https://github.com/mxcl/homebrew/issues
Btw, they recommend reading this before filing a report http://allanmcrae.com/2011/05/how-to-file-a-bug-report/
Hope that helps.
Thanks. This didn’t work, but the issue was eventually resolved by downloading the homebrew elsewhere: http://blog.boxcryptor.com/how-to-use-boxcryptor-with-encfs-on-mac-os-x#comment
Hi,
I have configured the brew in linux, How to make package for using brew ?
Ramesh
Hi,
I have installed brew in my linux (slackware13.1 linux)
While run the command given below
brew create http://ftp.acc.umu.se/pub/gnome/sources/libsoup/2.33/libsoup-2.33.90.tar.gz
and typed the formula
require ‘formula’
class Libsoup Downloading http://ftp.acc.umu.se/pub/gnome/sources/libsoup/2.33/libsoup-2.33.90.tar.gz
######################################################################## 100.0%
Warning: Cannot verify package integrity
The formula did not provide a download checksum
For your reference the MD5 is: f905e685f4e2fa6b414522e06d8db3c8
/usr/bin/mktemp: cannot make temp dir /tmp/homebrew-libsoup-2.33.90-XXXX: Invalid argument
Error: Couldn’t create build sandbox
root@slack64:/tmp/brew/homebrew#
I am getting above error. Please help me how to fix this error
Ramesh
Hello,
I’ve just started using Homebrew and I love it. The only issue I am having is that it doesnt seem to be installing the man pages for any packages I install. I there something I need to alter somewhere or a flag I need to set?
Thanks,
Kyle
Hi Kyle,
Thanks for your reply,
Please let me know, how can you configure in your system in details…
Ramesh
What are the implications of changing all those permissions on system directories? This strikes me as an unwise decision, particularly changing the group id’s
Looks handy, but unfortunately the gist url for the installer script is now a 404
I found out that gist site has been restructured a little
The ruby installer script can now be installed using…
ruby -e “$(curl -fsSLk https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)“