We had a visitor on #ironruby today asking for help getting IR running on his mac. I gave him the following directions, and they seemed to work aside from one glitch. I tested them on my wife’s mac, and it worked for me, too.
You can grab the Mono .dmg from go-mono.com. This will install the framework and put the required programs (mono, xbuild) in your PATH.
Fetch the IronRuby source
Since Jim Deville likes macs, I’m sure more recent versions will work, but this is the one we’ve recently packaged up for Debian and tested on Ubuntu. If you want to be certain that the IronRuby code you write on Debian works on OS X, then you should probably build from the same version of the source. You should probably also install version 2.4.3 of Mono, but that may be more effort than it’s worth ;)
Unpack the tarball
Open up a terminal and unpack the thing you just downloaded:
$ mkdir ~/src/ $ cd ~/src/ $ tar xfz ~/Desktop/mletterle-ironruby-e6b28d2.tar.gz $ cd mletterle-ironruby-e6b28d2/
At this point, you should be able to build the IronRuby assemblies using xbuild. I don’t recommend using rake, as it has some dependencies, and I’m not a fan of dependencies.
$ xbuild /p:TreatWarningsAsErrors=false Merlin/Main/Languages/Ruby/Ruby.sln <snip/> Build succeeded. 2817 Warning(s) 0 Error(s) Time Elapsed 00:00:28.8378230
Run the IronRuby interactive interpreter
Our guest mentioned that he was using a terminal with a white background. Do note that the font color of the interactive interpreter (aka Read-Eval-Print Loop or REPL) is white, so if you’re using a white background, you might want to change it. IIRC, there is a way to change the font color using a configuration setting. Figuring it out is left as an exercise for the reader.
$ mono Merlin/Main/Bin/Debug/ir.exe IronRuby 0.9.0.0 on 2.6.3 (tarball Wed Mar 10 18:18:12 MST 2010) Copyright (c) Microsoft Corporation. All rights reserved. >>> 1+2 => 3 >>> exit()
Extra credit: IronPython
The tarball you downloaded also included the source to IronPython. The procedure to build/run IronPython is pretty similar to IronRuby.
Unlike IronRuby’s .sln, this version of IronPython’s .sln does not have a default configuration parameter, so we need to specify it with the /p:Configuration=Debug argument.
$ xbuild /p:TreatWarningsAsErrors=false /p:Configuration=Debug Merlin/Main/Languages/IronPython/IronPython.sln <snip/> 69 Warning(s) 0 Error(s) Time Elapsed 00:00:38.8057450
Run the IronPython interactive interpreter
IronPython has a REPL interface like IronRuby’s. Or is it the other way around? Anyway, here’s an example.
$ mono .//Merlin/Main/Bin/Debug/ipy.exe IronPython 2.6 Beta 2 DEBUG (220.127.116.11) on .NET 2.0.50727.1433 Type "help", "copyright", "credits" or "license" for more information. >>> 1+2 3 >>> ^D