Note: See also Dinel's blog on Installing Ruby Gems in NetBeans IDE 6.0 (Ubuntu 7.10).
Here are the excellent resources I used to install my private copy of ruby:
I've summarized the steps here:
[~/] mkdir tmp [~/] cd tmp
[~/tmp] wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.5.tar.gz
[~/tmp] tar xvfz ruby-1.8.5.tar.gz
[~/tmp] sudo apt-get install build-essential
[~/tmp] sudo apt-get install zlibc zlib1g zlib1g-dev
Let's say we want to install our own private copy of ruby in ~/ruby-1.8.5, i.e. /home/you/ruby-1.8.5
[~/tmp] cd ruby-1.8.5 [~/tmp] ./configure --prefix=/home/you/ruby-1.8.5
[~/tmp/ruby-1.8.5] make
[~/tmp/ruby-1.8.5] make install
[~/tmp/ruby-1.8.5] make install-doc
[~/tmp/ruby-1.8.5] cd ext/zlib [~/tmp/ruby-1.8.5/ext/zlib] ~/ruby-1.8.5/bin/ruby extconf.rb [~/tmp/ruby-1.8.5/ext/zlib] make [~/tmp/ruby-1.8.5/ext/zlib] make install [~/tmp/ruby-1.8.5/ext/zlib] cd ~/tmp
[~/tmp] wget http://rubyforge.org/frs/download.php/20989/rubygems-0.9.4.tgz [~/tmp] tar xvfz rubygems-0.9.4.tgz
[~/tmp] cd rubygems-0.9.4 [~/tmp/rubygems-0.9.4] ~/ruby-1.8.5/bin/ruby setup.rb
That should do it. Now you can fire up netbeans and point to your new Ruby installation in Tools/Options/Miscellaneous/Ruby Installation
Use the Ruby Gems manager (Tools/Ruby Gems) to install gems for your private ruby:
Adding MySQL Support
[~/tmp] sudo apt-get install mysql-server libmysql-ruby libmysqlclient15-dev
[~/] cd ~/tmp [~/tmp] wget http://tmtm.org/downloads/mysql/ruby/mysql-ruby-2.7.4.tar.gz [~/tmp] tar xvfc mysql-ruby-2.7.4.tar.gz [~/tmp] cd mysql-ruby-2.7.4/
[~/tmp/mysql-ruby-2.7.4] ~/ruby-1.8.5/bin/ruby extconf.rb
[~/tmp/mysql-ruby-2.7.4] make [~/tmp/mysql-ruby-2.7.4] make install
Adding Rails support
To install rails just use the Gems Manager in the IDE and add rails gems and optionally the mongrel gem. Getting MySQL support up and running is slightly harder (but no harder than the previous steps you have already done).
[~/tmp] sudo apt-get install libreadline5-dev
[~/] cd ~/tmp/ruby-1.8.5/ext/readline [~/tmp/ruby-1.8.5/ext/readline] ~/ruby-1.8.5/bin/ruby extconf.rb [~/tmp/ruby-1.8.5/ext/readline] make [~/tmp/ruby-1.8.5/ext/readline] make install
Note: See also Dinel's blog on Installing Ruby Gems in NetBeans IDE 6.0 (Ubuntu 7.10).
(This is a summary of http://wiki.rubyonrails.org/rails/pages/HowToUseMultipleGemRepositories, with minor adaptations for Netbeans.)
This assumes that you already have the stock Ubuntu ruby and rubygems packages installed. If you do, your Gem repository is at /var/lib/gems/1.8. Make a note of this because it will be important later.
First you need to decide where you'll put your private repository. I'll use /home/david/.rubygems. Whenever you see this path, substitute your own for it.
tasmania:~$ mkdir .rubygems
Next download rubygems. I believe it's best to download the same version that you have installed on your system (currently 0.90.0 on Feisty) to prevent compatibility problems.
You can download the distribution here: http://rubyforge.org/frs/?group_id=126
After you download the file, unpack them somewhere. I'll assume you downloaded it to /tmp.
tasmania:/tmp$ tar xvf rubygems-0.90.0.tgz tasmania:/tmp$ cd rubygems-0.90.0 tasmania:/tmp$ GEM_HOME=/home/david/.rubygems ruby setup.rb all --prefix=/tmp/gems
I used GEM_HOME to tell setup.rb where it should initialize the repository. If you now look inside the repository location, you should see something like this:
tasmania:~/.rubygems$ ls cache doc gems specifications
Congratulations! You now have your own private, working, Gem repository.
(I'll let you in on a secret. I won't be using this repository. It's there only to keep Netbeans happy so it will stop bugging me about not finding my rails installation. Of course, this means I won't be using Netbeans to manage my gems.)
Now we have a problem. Since Netbeans looks for Gem executables (e.g., the rails executable) inside $GEM_HOME/bin, you need to symlink the entire /var/lib/gems/1.8/bin dir to $GEM_HOME/bin like so:
tasmania:~/.rubygems$ ln -s /var/lib/gems/1.8/bin .
Or, if you plan to let Netbeans manage your private repository, you need to create a bin/ directory and manualy symlink all the global Gem executables:
tasmania:~/.rubygems$ mkdir bin tasmania:~/.rubygems$ cd bin tasmania:~/.rubygems/bin$ for f in $(find /var/lib/gems/1.8/bin -type f); do ln -s $f .; done
Now we just have to let Netbeans know where to find the writable repository, and where to find all other gems. We do this using (again) GEM_HOME and a new environment variable: GEM_PATH.
tasmania:/opt/nbrubyide/bin$ export GEM_HOME=/home/david/.rubygems tasmania:/opt/nbrubyide/bin$ export GEM_PATH=/var/lib/gems/1.8:/home/david/.rubygems tasmania:/opt/nbrubyide/bin$ ./nbrubyide &
Presto! Put those exports in a wrapper script, and start hacking. You shouldn't put this in your .bashrc (or your shell's equivalent) as that will confuse you global gem command.