Ironruby.1.1 – Vista Begining

I was installing Ironruby on a Vista box, so I thought I will chat down all things I did for someone who might have to do the same thing.

1. Download and install Microsoft Visual C# from http://www.microsoft.com/express/download/#webInstall, It is a very easy to install, simply follow the setup wizard and choose the defaults in all the screen, except in my case I didn’t choose MSDN since it is almost 300MB and it takes a while to download. Also I can get most of all the documents for C# on the net, so to save time and space, I decided not to install. Please be patient while it download and install. It takes some time.

ok, I am back from lunch and guess what I finished installing and asked me to reboot my box. It may be because of the windows update. They always sneek in some updates :)

2. Lets go and insatll ruby. You need ruby . As of now the version is 186.26 can be obtained from http://rubyforge.org/frs/?group_id=167&release_id=17128 download the exe file and execute it on open. Use c:\ruby as the default directory install.

With this now you should be able to start writing ruby code. Well, we are not there yet. I would like to do it with visual studio.

3. Now we need to download and build our Ironruby interpreter. We can download the code from rubyforge and build it visual c# compiler we downloaded in step 1. To download the ironruby source we need to download TortoiseSVN from the following http://tortoisesvn.net/downloads

Follow the wizard and choose all the defaults and at the end, it will ask you to reboot the computer and if you are in the middle close everything and restart the computer.

4. Now create svn folder under c root as c:\svn. Right click on svn folder name and perform svn checkout. When you right click you see the a context screen as follows;

Choose checkout and then it will popup a screen as follows to perform a check out of Ironruby solution from source safe, use the same information as shown in the screen,

press OK and this should bring in the source code from rubyforge for Ironruby solution. All the source code will be placed under c:\svn\trunk. Now that we got all the source code, now we need to build our iron ruby interpreter to use Ironruby.

5. Before we go to build, I would suggest perform a gem update on pathname2, when I tried first time on XP I ran into the problem and I do not want that to be the problem here as well. Open a DOS box and type in “gem install pathname2”. If you started the DOS as a user context, the command will fail and one prompt will show up to allow Ruby to update the gem, allow it, this screen will show up twice. Allow both time and try running the gem update pathname2 again in the dos box and this time, it will fetch the updates properly.

As you can see the first attempt failed and the second attempt after giving Vista the permission for this program to run, it updated successfully.

6. Now lets run the rake to build our ruby interpreter. Todo that, make sure you are in c:\svn\trunk folder in dos box and then type in ‘rake compile’ thats it, it will do the magic and it should show a screen similar to the following

*** It is possible you might get an error that resgen.exe not found in path, if you run into this error, then search for resgen.exe and find the path and add the path to environement variable PATH through control panel. You can find where this file is by doing something like the following on the command line. Once the environment variable is set, make sure close the dos box and open a new dos box otherwise the change to environment variable will not be come into effect when searching for the resgen.exe

Hopefully you got rake compile to work, if not send me a mail or twit me (@ i_am_unni) I will be more than happy to help you. ******

7. Now that our compile worked and out rbx.exe is created, lets try running our “Hello World” program, pretty exciting huh? By default when you run the rake compile, rake will create rbx.exe in debug mode. It is at c:\cvn\trunk\build\debug, I would recommend adding this path to your PATH environment variable that way, you can create your ironruby code in a seperate folder and run the rbx from that folder.

In my case, I create all my Ironruby code in a folder called c:\code\ironruby. Run rbx from that folder, since rbx.exe is already in my PATH environment, I need not worry about Ironruby compile any more. Obviously if you are adding rbx.exe location to PATH environment variable, I would recommend close the dos box and reopen again.

Now lets try our Hello world. Open a new dox box and just type in our favorite compiler rbx as follows

There you you, we got our first ironruby code running.

A word of caution though, if you are going to use ironruby interpreter, make sure all the local variables are marked with $ (as global) so that it can remember the local vriables. It is my understanding local variables are not preserved.

let me show what I am trying to say

Instead of doing I would recommend you type in the code in your favorite editor (may be notepad++) and pass in the ruby code as input to ironruby then you do not have this local variable global variable issue. See for your self

There you go, if you see the lefthand side, you can see the code without making x global. Right side has the output.

What y’ll think, isn’t it fasinating to code in ruby?

Have fun coding…..

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

No Responses so far »

Comment RSS · TrackBack URI

Say your words

You must be logged in to post a comment.