Installing Ruby gems in NetBeans 6.0 on Ubuntu

by Dinel

[[{TableOfContentsTitle=DocStartup} | {TableOfContents title='Doc Startup'}]]


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 (for me this was true for both Ubuntu 7.10 and the alpha versions of Ubuntu 8.04). I suspect that this is due to some changes in the way RubyGems have to be installed. The rest of this tutorial explains the steps which need to be taken in order to install RubyGems on my computer and use them in NetBeans 6.0.

The solution

In order to solve this problem you first need to create your own copy of RubyGems and then tell NetBeans to use it.

Install your own copy of RubyGems

  1. 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
  2. unpack the rubygem-0.9.4.tgz with
    tar -xzvf rubygem-0.9.4.tgz
  3. create the directory where you will store your rubygems:
    mkdir ~/.localrubygems
  4. 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)
  5. change to the directory with the rubygem source
    cd rubygem-0.9.4
  6. install rubygems using
      GEM_HOME=/home/dinel/.localrubygems/ \ 
      ruby setup.rb all --installdirs=home \ 
      --prefix=/home/dinel/.localrubygems/ \ 

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 now complete.

Use your copy of RubyGems

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/ 

In order to make your life easier, you can put all these in a script.

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:


This is tutorial was first published in Dinel's blog.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo