One of the great features of the new NetBeans 6.0 is the possibility of developing Ruby code with it. Unfortunately if you run Linux you will find out that you cannot directly use the RubyGems you have installed with your distribution unless you set some very generous file permissions or run NetBeans as root. None of these solutions is appealing. A much better solution is to install your own version of RubyGems. The NetBeans wiki explains how this can be achieved, but unfortunately it does not work in my case (I am currently running Ubuntu 7.10). I suspect that this is due to some changes in the way RubyGems have to be installed. The rest of this post explains the steps I took in order to install RubyGems on my computer and use them in NetBeans 6.0.
- Find out which version of RubyGems is installed on your computer and download the same version from RubyForge (Given that NetBeans will be the one who will manage the Gems I suspect that this is not so important. However, it is likely that it will save lots of headache if you do not always want to run your Ruby programs from NetBeans). In my case I have rubygems version 0.9.4-1ubuntu1, and therefore I downloaded the 0.9.4 version
- unpack the rubygem-0.9.4.tgz with
tar -xzvf rubygem-0.9.4.tgz
- create the directory where you will store your rubygems:
mkdir ~/.localrubygems
- create the directory where the lib files are stored.
mkdir ~/.localrubygems/lib
This step is not compulsory, but unless you set this option a lib directory is created in your home directory (which I did not like)
- change to the directory with the rubygem source
cd rubygem-0.9.4
- install rubygems:
GEM_HOME=/home/dinel/.localrubygems/ \ ruby setup.rb all --installdirs=home \ --prefix=/home/dinel/.localrubygems/ \ --libdir=/home/dinel/.localrubygems/lib/
the –installdirs=home indicates that the installation is done in the user’s directory and the –prefix and –libdir indicated where the files which go in the lib dir are stored
- that’s it. The installation is complete now.
In order to use NetBeans with Ruby you need to set the GEM_HOME and GEM_PATH environment variable and start NetBeans:
export GEM_HOME=/home/dinel/.localrubygems/ export GEM_PATH=$GEM_PATH:/home/dinel/.localrubygems/ netbeans
If everything went fine you should be able to go to Tools/RubyGems and see:

Select the New Gems tab, click Reload Gems button and you will see all the Gems available for installation:

Now is time to try some real Ruby programming to find out whether this solution poses some problems.



February 18th, 2008 7:40 am
Hi. In dev builds there is a new Ruby Platform Manager with Gem Path and Gem Home autodetection and customization. So you might set Gem Home and/or Gem Path from within the IDE differently for every interpreter. You can also set different interpreter for particular projects. So above complication should gone.
In next few days it will be very easy to set up new gem repository from withing the IDE as well.
I would encourage you to switch to dev builds, or even continuous builds:
http://deadlock.netbeans.org/hudson/job/trunk/
which are getting quite stable these days.
If you find any bug or have any ideas please let us know:
http://wiki.netbeans.org/RubyFeedback
February 21st, 2008 10:18 am
Hi,
My name is James Branam and I’m the NetBeans Community Docs Manager. Your blog entry would make a fantastic tutorial for our Community Docs wiki (http://wiki.netbeans.org/wiki/view/CommunityDocs). Would you be willing to contribute it? If you need any help or have any questions, please contact me at james.branam@sun.com. I look forward to hearing from you.