Setting up Ruby on Linux

Up until now, I've done nearly all of my Rails programming on Windows Vista (64 bit). The environment has been pretty good, but it's time for a change. This was probably due a while ago, but I've decided to explore Linux with a dual boot of Ubuntu 10.x. Thanks to StackOverflow and some Googling, I got mostly up and running in about a day. Here's a summary of some the steps I took to hopefully help others in the same position as me: decent at programming, but terrible at Linux.
  1. Get Linux working alongside Windows
  2. There are two ways to do this (that I know of): Dual boot and Virtual machine. With a dual boot, you get to choose at startup which OS you want to run. With a Virtual Machine (VM), one OS is like a program running in the other. For example, I could easily alt+tab between Linux and Windows. I went the dual boot route by using a program called Wubi. For VMs, Virtual Box is highly recommented (I almost got it working). I went with Ubuntu 10.something for no real reasons other than it's the newest version of Ubuntu and that I've read that Ubuntu is easy to use. Follow the Virtual Box wizard and you should be in good shape. (StackOverflow)
  3. Install Ruby
  4. Go to the terminal and run sudo apt-get install ruby.
  5. Install IRB
  6. I was disappointed when I tried getting IRB working. Turns out you have to install that separately: sudo apt-get install irb
  7. Install RubyGems
  8. sudo apt-get install rubygems . . . but it's not so simple. Installing gems will not yet work properly.
  9. Add gem to the PATH
  10. I know just enough about PATH in Windows to get by, so this was a little interesting in Linux. You need to edit a file called bash.bashrc which is located in the /etc folder. To be able to edit, you need to have permission. cd into /etc and write sudo chown username:username bash.bash.rc (StackOverflow). Now, open bash.bashrc with a text editor (Ubuntu comes with gEdit), and add the following lines to the bottom of the file: export PATH="$PATH:$HOME/ruby/gems/bin" export GEM_HOME="$HOME/ruby/gems" export GEM_PATH="$GEM_HOME:/usr/lib/ruby/gems/1.8" export GEM_CACHE="$GEM_HOME/cache" (Bluehost forum) Save the file, leave the text editor open. We'll be back there in a minute. RubyGems work! Well, kind of. You need to require 'rubygems' before you can access gems. In addition to being "wrong," it's a pain to make sure every Ruby script has that line. Luckily, there's an easy way out.
  11. Add RUBYOPT to bash.bashrc
  12. Now add the following line to the end of bash.bashrc: export RUBYOPT=rubygems (rubygems.org) Save the file and you're good to go! Now it's time figure out Rails, MySQL, and Git. I'll save that for another post.
Alan 29 May 2010
blog comments powered by Disqus