I still get a bit of traffic for my post on how to compile mtr under Snow Leopard, so I thought I’d write a update for anyone looking to install it on Lion.
First of all, according to commenters, that process still works.
However, I decided to try a different approach with Lion, by first installing the much-buzzed-about Homebrew.
Homebrew is a new package manager for OS X. I’ve always avoided OS X package managers because of all of the nightmare experiences I’ve read from folks using fink or MacPorts, but Homebrew immediately appealed to me for two reasons:
- It uses the conventional /usr/local directory
- It works without, and recommends against, using the
sudocommand to install software
Now, like any good system administrator, I don’t run my computer as an admin, so that last benefit particularly appealed to me.
So, once you have Homebrew installed, installing the latest mtr is as easy as entering:
brew install mtr
Done!
However, there are a few common issues:
Issue 1: ‘unable to get raw sockets’
mtr needs to run as root. Previously, when compiling from mtr source and using sudo, it would install itself with suid, meaning that it ran as root regardless of which user ran it. Obviously, this has the potential to be dangerous. If you really want to set the suid flag, that’s up to you, but beyond the scope of this post. I, and the folks at Homebrew, recommend that you run mtr using sudo as needed, and keep the suid flag off.
Issue 2: mtr runs in X11
Once you get past the above issue, you might notice that mtr launches and runs in X11. This was not appealing to me at all. After doing some digging around, I found out that you could add the -t flag to have mtr output in the terminal:
mtr -t www.apple.com
For a few days, I used it like this, but after Nelson Minar linked to the Homebrew Formula in a comment on my last mtr post, I noticed that you could pass --no-gtk to brew and it would install mtr without the GUI. So I removed and reinstalled correctly:
brew uninstall mtr
brew install mtr --no-gtk
That’s it! mtr now correctly runs in my terminal without any additional arguments.