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.
29 May 2010
- Get Linux working alongside Windows
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)
- Install Ruby
Go to the terminal and run
sudo apt-get install ruby.
- Install IRB
I was disappointed when I tried getting IRB working. Turns out you have to install that separately:
sudo apt-get install irb
- Install RubyGems
sudo apt-get install rubygems . . . but it's not so simple. Installing gems will not yet work properly.
- Add gem to the PATH
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.
/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:
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.
Now add the following line to the end of
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.