Experimenting with a little Homebrew
Well, today it finally happened. I got sick and tired of MacPorts behavior of replacing every binary already included in the Mac OS with its own version. I don’t need two versions of perl or python installed on my Macs and I am getting tired that every time I try to install a port, it insists on installing a complete perl/python installation or its own set of libraries the MacOS already has built in, in order to install a small utility. I know that MacPorts has some justification for this, but it seems messy to me.
As such, I started looking for alternatives and came back to homebrew, which I had discovered a few months ago. It is a package management system in which everything relies on already installed Mac binaries/libraries as much as possible. By default, homebrew packages are installed into their own isolated directory (/usr/local/Library/Cellar/
) and then symlinked into /usr/local/bin
, /usr/local/sbin
, or /usr/local/lib
directories as needed. But it is flexible enough that you can install it where ever you want and it will still run. Another nice feature, it doesn’t require you install it as root, it can run completely as the user permission level!
The negatives of homebrew:
- There are no where near as many packages (they call them “Formula”) are available for Homebrew as for MacPorts or Fink.
- For an astronomer, another big problem, there is no TeX under Homebrew.
It turned out the first negative was a bit of annoyance, but I was willing to live with it because the installation was so much cleaner and most of the important packages I needed MacPorts for were already there. The second negative turned into a postive because I discovered here is a very easy to install MacTeX package available now that installs a complete TeXlive installation, including AASTeX, by default! It even has some nice GUI controls included for keeping it up to date.
What follows is a description of what I did to transition from MacPorts to HomeBrew+MacTeX.
- Backing up MacPorts: No need to not have a way to change my mind if this blows up in my face. I backed up my entire MacPorts installation by using the command
tar czvf /opt_backup.tgz /opt
and then when that was done, I had a 1.6 Gig tarball at the root level of my drive called
opt_backup.tgz
. - Disable MacPorts: At this point, I deleted the
/opt
directory and commented out the commands in my~/.tcshrc
that added those directories to the PATH environmental variable. If you use the default bash shell, you will need to edit~/.bashrc
to disable MacPorts. - Install Homebrew: Following the directions on the Homebrew site. I originally wanted to place homebrew in its own custom install directory (/usr/local/homebrew).But after reviewing the Homebrew installation documentation, I came to realize that using the default
/usr/local
location for the install makes the most sense.I did this in the recommended manner, using the install script, which does some nice permission checking to make sure things will run nicely before installing. Since my default shell isn’t
bash
, I had to switch to it, then just run the install script from the command line:bash ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"
The first time I ran it, it failed because my permissions for /usr/local had been tweaked. So I had to run the command
sudo chown -R root:staff /usr/local
to get the permissions so the script could run.
- Activate Homebrew: Since I am not using a custom directory for the installation, there is not configuration needed in terms of setting up the environment.
/usr/local/bin/
is in the defaultPATH
, so as soon as I start up a new terminal window, homebrew is available! Otherwise, I would have to edit my default~/.tcshrc
or~/.bashrc
to add the homebrew binaries directories (bin
andsbin
) to thePATH
environmental variable. - Install my favorite packages using homebrew: Installing packages in homebrew is just a matter of making sure the Formula for the package exists (all the publicaly available Formula are here) and then typing
brew install (formula name)
So for example, installing CFITSIO was just a matter of typing:
brew install cfitsio
Actually, this was for the most part simple for my attempts to install git. It kept crashing with an error that said:
The current directory must be set to the ITT directory.
Well, ITT is the vendor of IDL (a package commonly used by astronomers for data reduction) and I discovered that I had accidentally set the IDL binary directory to be in the
PATH
ahead of the default system directories. This meant the IDL version of a binary calledinstall
was replacing the system default version of this. Just the kind of problem I was trying to get away from in MacPorts. I changed to my~/.tcshrc
to make sure the IDL binaries directory was later in the PATH than the system directories fixed things. The only package this affected the install of was git, all the other packages installed without a hitch thus far. The other brew formulae I installed were installed with the following commands:brew install subversion imagemagick ghostscript macvim lynx coreutils findutils plotutils
I can get a list of all the packages I have installed using the command:
brew list
- Installing MacTeX: This was extremely easy, I downloaded the MacTeX 2010 package (The version I got was dated 10 Sept 2010 and was 1.6 Gig) and then uncompressed it and double clicked it. It installs using the Mac Installer. I did make sure to customize the install to remove some of the stuff I didn’t feel I needed, but I kept the GUI tools. Turns out there is a nice TeX Live Utility installed in
/Applications/TeX
that lets you customize which TeX packages are installed and can automatically update things. Review of this tool also showed a very astronomer friendly decision to include AASTeX by default! The TeX installation is in the/usr/local/texlive/
directory and it installs a symlink at/usr/texbin/
to all the LaTeX binaries. I added the following lines to my ~/.tcshrc file to get the tex binaries in my PATH:# Set up MacTeX 2010 by including path to that installation of LaTeX setenv PATH ${PATH}:/usr/texbin
So there you have it, how I went from using MacPorts and the literally hundreds of packages to support the few I wanted to trimming things down to a few packages in homebrew and one double-clickable TeX installer.
[Edited on Mar. 2, 2011 11:04 am to update the instructions to the default homebrew instructions, which are cleaned and easier to implement.]