Homebrew, the Mac package manager

I want to throw my hat in the ring with those who have already endorsed Home­brew for the Mac. Home­brew is a fan­tas­tic way to install lots of the pro­grams that you’ll very likely want to use as you get more and more into LaTeX.

For exam­ple, the other day I watched this great screen­cast on para­graph for­mat­ting in Vim, and I was con­vinced that I really wanted to try out the pro­gram dis­cussed there, Par. There are two options for get­ting Par. One is to go over to the main web site, choose one of the seven down­load pack­ages to down­load, and then install it. Here are the instal­la­tion instructions:

On most UNIX–like sys­tems, “make –f pro­toMake­file” will work, but you might want to read the com­ments in pro­toMake­file, or use the auto­conf add-on for Par 1.52 con­tributed by Nel­son H. F. Beebe, or take a look at some hints for build­ing par on var­i­ous platforms.

I’m actu­ally fairly com­fort­able fol­low­ing these instruc­tions, but there was a point in time where I wasn’t. There was a point in time (not so long ago, really), where I wouldn’t have known what this meant at all. Even now, if there were a more straight­for­ward way to do this, I’d take it.

There is! Home­brew makes installing pack­ages like Par a breeze. Instead of doing the above, all you need to do is open up Terminal.app and type brew install par, then hit Enter. If you’ve installed Home­brew, it will down­load the appli­ca­tion and install it for you. And if you hap­pen to need another pro­gram to make the one you want run, Home­brew will install that, too (e.g., I needed Tokyo-Cabinet to make the mail pro­gram mutt run; Home­brew knew this and installed it for me).

Home­brew is the (new) pack­age man­ager for the Mac. It makes installing cer­tain sorts of pro­grams very easy (mostly these are command-line pro­grams; all of them are free to down­load). And it makes updat­ing these pro­grams easy, too. How would you go about updat­ing Par, given the above instruc­tions? I am not entirely sure. But if you installed it via Home­brew, you would type brew update and update all the pro­grams that you’ve installed via Home­brew (I haven’t done this yet, but the doc­u­men­ta­tion sug­gests that this is how this works).

Installing Home­brew is actu­ally quite easy. The main github page for Home­brew explains the instal­la­tion instruc­tions clearly. Lit­er­ally, this is all you need to do:

  1. Copy and paste the fol­low­ing into Terminal.app:
    ruby -e "$(curl -fsS http://gist.github.com/raw/323731/install_homebrew.rb)"
  2. Install Apple’s Xcode either directly from Apple or via your OS X instal­la­tion disk (you’ll have to reg­is­ter as a devel­oper to do this, but it is free, so there is no rea­son not to). I think installing the devel­oper tools via Xcode installs some of the higher-powered command-line tools you need to run things like git; what­ever the rea­son, you need to install it.

Once you’ve installed Home­brew, you can search for a pro­gram by typ­ing brew search /search_term/, with the slashes included. Then just type brew install program_name to install a pro­gram, brew uninstall program_name to unin­stall a pro­gram, and brew help for help.

MacVim

You can even use Home­brew to install MacVim, if you like. Just brew install macvim and you are good to go. In the ter­mi­nal, type mvim and hit Enter. MacVim will open and the icon will appear in your Dock. Right click on it (or Command+Click) and then under ‘Options’ you can choose ‘Leave in Dock’ to make it stick around after you close it. In the future I’ll talk about git in detail, I hope. You can install git with a brew install git (no real sur­prise there, huh?).

I highly rec­om­mend Home­brew. And if, for some rea­son, you need to unin­stall Home­brew, just fol­low the direc­tions toward the bot­tom of this page. (I know this because some­thing messed up with my instal­la­tion the other day. I sim­ply did a brew list to see all the pro­grams I had installed, fol­lowed these direc­tions to eas­ily unin­stall Home­brew, then rein­stalled using the direc­tions above (though I obvi­ously didn’t have to install Xcode again), and used the list I just gen­er­ated to quickly rein­stall the pro­grams I needed. Very quick and very easy.)

Posted Monday, July 12th, 2010 under git, Mac, text editors.

9 comments

  1. You need to install Xcode because oth­er­wise you won’t have a com­piler (usu­ally GCC) avail­able to build and install Homebrew’s packages.

  2. Since Mac options are on the table, I’ll add that I’ve been using TeXshop for years and have been very happy with it. Admit­tedly, it doesn’t allow for intri­cate grep­ping of the file; for that, I load the source in some­thing else.

  3. Hi Bene­dict, That makes sense. Thanks for fill­ing me in on the details!

    Hi P.D., I agree that TeXShop is a very nice edi­tor. It is every­thing that a Mac LaTeX edi­tor should be–it is clean and intu­itive and ‘just works’. I think some of the fea­tures (like its use of Sync­TeX) are par­tic­u­larly nice. I also think it has more options and fea­tures than I real­ized when I switched over to another edi­tor. Do you have any favorite TeXShop features?

  4. Does Home­brew really install pack­ages by com­pil­ing source rather than just installing bina­ries? If so, I won­der why. Of course, nearly all Linux dis­tri­b­u­tions come with a pack­age man­ager like this and they’re great (apt-get for Debian/Ubuntu, yum for Fedora, pac­man for Arch, etc.). They usu­ally just install bina­ries, though, unless it’s some­thing unusual or you specif­i­cally request to install from source (e.g., if you want to change some­thing). Only Gentoo’s portage sys­tem always installs from source. I guess com­pil­ing from source, although slower and less fail­safe, can result in bina­ries more opti­mized to your hard­ware, but since hard­ware for macs all comes from Apple, I wouldn’t have thought that was much of an issue. The biggest prob­lem with com­pil­ing from source is that for com­pli­cated stuff it can take for­ever, which is pretty annoy­ing if you’re not actu­ally chang­ing any­thing about it.

    P.D., what sort of things do you have in mind by “intri­cate grep­ping of the file”? I’ve never used TeXshop, but from what I’ve heard, it’s a lot like TeX­works. TeX­works sup­ports reg­u­lar expres­sion find/replaces, so I would have guessed that TeXshop does too. But maybe you meant some­thing more elab­o­rate. I’m curi­ous about what, if any­thing, TeXshop offers that TeX­works doesn’t, but I guess that’s for another post.

    • Hey Kevin,

      I just looked at the Home­brew wiki FAQ. In response to “Why are you com­pil­ing every­thing?” they say:

      We opti­mise for your Mac. But we try not com­pile stuff that takes ages but the avail­abil­ity of binary pack­ages dic­tates that. We don’t host our own bina­ries to keep costs zero. If you want to donate host­ing to the project, please let mxcl know.

      So there you have it. Free host­ing on github is a nice thing for projects like this, but I guess it has its costs.

  5. Thanks for col­lec­tion all i need in one place :)

  6. I came across this page look­ing for instruc­tions on how to unin­stall Home­brew: my old setup was a lit­tle borked even before the Migra­tion Assis­tant didn’t quite get the group per­mis­sions right.

    Any­way, you can find the steps I took at this old revi­sion of the Instal­la­tion wiki page; I’m not sure when or why they removed it:

    https://​github​.com/​m​x​c​l​/​h​o​m​e​b​r​e​w​/​w​i​k​i​/​I​n​s​t​a​l​l​a​t​i​o​n​/​1​b​f​5​0​8​3​6​7​d​c​c​1​8​6​a​e​0​f​4​1​c​e​5​d​6​4​d​4​7​7​5​0​1​4​2​7​2d8

Leave a Reply