Wednesday, June 16, 2010

Using Homebrew with a SOCKS5 proxy server

So, one of my coworkers, David Howell recommended that I use Homebrew instead of MacPorts on my new Mac at Wolfram. Homebrew is basically a package management system for keeping open source software up-to-date.

I very quickly ran into a proxy problem. All internet requests must first pass through the Wolfram proxy server. I was able to configure the http and ftp proxy locations, but for some reason, curl, which Homebrew uses to download files, was having a hard time with the proxy configuration.

Prior to configuring the ftp_proxy environment variable, I would get a 500 -- unauthorized error for any ftp request. After setting the ftp_proxy environment variable, I would get a request timed out error. This problem only seemed to be with curl. It worked fine with wget.

After a lot of crazy things -- including a hack to the Homebrew source code to use wget, I discovered a much easier way to get curl to work with a SOCKS5 proxy server instead. All I had to do was add the following line to ~/.curlrc

socks5 = "socks.wolfram.com:1080"


So, I reverted my changes to the Homebrew source code. Everything works great now.

It is interesting that there are no environment variables for SOCKS5 proxy servers in unix. I'd imagine that it is a very useful thing to have. For the moment, I guess you just have to check the man pages for existing tools to see if they have a configuration option for a SOCKS5 proxy and whether they have a configuration file that the configuration can be added to.