Tags

No tags :(

Share it

I’m currently using a Mac with Mountain Lion and I wanted to use Kerl to install the latest Erlang R15B03-1. Kerl is a great way to manage multuple Erlang installations on a system. You can compare it somewhat to Virtualenv for Python. The problem with a 64-bits Erlang installation is that some of the tools (debugger, observer) depend on wxWidgets 2.8. Unfortunately, wxWidgets 2.8 doesn’t work on Mountain Lion. So if you want to develop with Erlang on OS X 10.8 then an alternative solution has to be found.

Full credit to Joan Valduvieco who was able to replace wxWidgets with WxGTK as it has the same API as WxWidgets 2.8 and uses X11 instead of Carbon. Rather than waiting for his patched formulas to make it into the official Brew tree, I just went ahead and updated my formulas locally.

I really didn’t want to use Brew initially, since I’m already using MacPorts, but the objective here was compelling enough to go ahead with it anyway. Here follows the complete sequence to get a fully working 64-bits Erlang environment on Mountain Lion:

Install Brew:

ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"

Brew needs write access to /usr/local. In order to prevent build failures, we must “chown” the following directories:

$sudo chown -R $(whois) /usr/local/share/locale
$sudo chown -R $(whois) /usr/local/share/man
$sudo chown -R $(whois) /usr/local/include/freetype2/ 
     # might have to do this last one later and retry Erlang installation,
     # or install this dependency first and chown it.

Update Brew:

$ brew doctor
$ brew update

Update the Erlang and WxGTK formulas. Download the following and save them to /usr/local/Library/Formula/

Save as /usr/local/Library/Formula/erlang.rb:

https://gist.github.com/raw/4376548/fa633c5120a7b67ed21c51e2c40a930685ab92d9/erlang.rb

Save as /usr/local/Library/Formula/wxgtk.rb:

https://raw.github.com/jvalduvieco/homebrew/erlang-wxgtk/Library/Formula/wxgtk.rb

Install Erlang:

$ brew install erlang --with-wxgtk
		
[wait, get some coffee]
		
$ /usr/local/Cellar/erlang/R15B03-1: 7584 files, 285M, built in 13.9 minutes

Since I have multiple Erlangs on my system (via Kerl), let’s make sure that the right one is active:

$ which erl
$ /usr/local/bin/erl 
$ ls -n /usr/local/bin/erl
$ lrwxr-xr-x  1 501  80  33 Jan 16 13:12 /usr/local/bin/erl -> ../Cellar/erlang/R15B03-1/bin/erl

Cellar is from Brew, so we’re good to go! Let’s test wxGTK:

$ erl
Erlang R15B03 (erts-5.9.3.1) 1 [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false] [dtrace]
		
Eshell V5.9.3.1  (abort with ^G)
1> 

Start the wxWidgets demo:

1> wx:demo().

Tada! Finally after much searching I have Erlang debugger and observer working on Mac OS x64:

Erlang debugger on Mountain Lion