RubyGems61
| The information on this page pertains to NetBeans IDE 6.1. If you are looking for information about Ruby Gems in 6.5, where a lot of features and enhancements have been done, look here. If you are looking for information about Ruby Gems in 6.0, look here. |
|---|
Contents |
Installing Gems
You can install gems from the command line or you can use the NetBeans Gems Manager.
Installing Gems From the Command Line
- To learn how to install gems in JRuby, see this "Getting Started" how-to on the JRuby wiki.
- For native Ruby platforms, the command line instructions can be found in the RubyGems Command Reference at rubygems.org.
Installing Gems From the IDE
To install gems from the IDE, choose Tools > Ruby Gems from the main menu, and select the Ruby Platform to which you want to install the gem.
If this is the first time you are using the Ruby Gems manager, you might want to click the Manage button to open the Ruby Platform Manager. Make sure that the Gem Home, Gem Path, and Gem Tool settings are correct. (If you are not sure of the difference between Gem Home and Gem Path, click Help to see the definitions).
Note: If the Gem Home and Gem Path directories require root access, see the Troubleshooting section for important information about permission problems.
Troubleshooting
This section provides solutions for some of the common problems you might encounter when you use the Ruby Gems manager.
RubyGems needs to be installed
In order to use the _gem_ command, you must install RubyGems into your Ruby installation. If you are using the bundled JRuby installation, this is already the case. See the Installing RubyGems chapter in the RubyGems User Guide at rubygems.org for information on how to install RubyGems.
Permission problems
The IDE also needs to have write permissions on the gems repository in order to install, upgrade, and uninstall gems.
If you have switched to /usr/bin/ruby on your Linux box, for example, the gem installation
directory is probably not writable without root privileges. The IDE will inform you of
this problem, linking to this wiki page, with the following dialog:

There are several ways to solve this:
- Install your own private copy of Ruby somewhere else, and use that instead. Remember not to run the make installation step as root. See below section "Installing your own private copy of Ruby on Ubuntu".
- Make the repository writeable. Change the directory's write permissions to enable the IDE to write files there.
Here's an example how joe changes the permission of repository in /var/lib/gems/ (the default on Ubuntu), which had root-owned files, to allow him to to run gem without root access:
joe@rubycomp:~$ cd /var/lib/gems/ joe@rubycomp:/var/lib/gems$ sudo chown -fR joe . [Sudo] password for joe:
- Run NetBeans as root. I don't recommend this approach.
- Create a private repository for your gems. This will save you the trouble of installing your private copy of Ruby, while keeping your system's security intact. To do this, choose Tools > Ruby Platforms to open the Ruby Platform Manager (If you are in the Ruby Gems manager, you can click the Manage button to open the Ruby Platform Manager). Click the Browse button. Navigate to where you want to put the gems repository and click the New Folder button in the file browser. Name the new folder, select it, and click Open. Answer OK to the question about setting up a new repository in the new folder.
Problem with installing Gems that use native extensions
Some RubyGems use native extension. That is they are (partially) written in C and thus need to be compiled during installation. If you encounter kind of failed to build native extensions problems during Gem installation, be sure:
- You are not using JRuby interpreter at the moment, which cannot build native C extensions (there are often counterpart extensions written in Java, you might try to find them).
- You have GCC installed on your Unix-like system (Linux, Mac OS X, ...) so the native compilation is possible.
- on Mac OS X be sure you have installed Developer Tools. They're not installed by default but they're on the install CD's you get with Leopard.
- on Ubuntu (7.10 in the time of writing this) following packages need to be installed for compilation. Run:
sudo apt-get install build-essential autoconf
In the case you are using Ruby package from Ubuntu repository, be sure you also install ruby<version>-dev package, like ruby1.8-dev or ruby1.9-dev. Otherwise you can't compile any native extensions. E.g.
sudo apt-get install ruby1.8-dev
Please update this Wiki page section for your OS if it is not mentioned here yet.
Installing your own private copy of Ruby
Take a look at this page to see how to install Ruby on some systems.
Installing FastDebugger on Debian (testing).
Not sure it's the best solution, but you can setup fast debugger in a few simple steps without creating your own gems repository.
Install ruby-debug-ide:
spectator:/$ sudo gem install ruby-debug-ide
Make symbolic link:
spectator:/$ sudo ln -s /var/lib/gems /usr/lib/ruby/gems
That's all! Your IDE will detect the installed fast debugger and will use it by default.



