I recently finished rebuilding an Ubuntu virtual machine specifically for poking around with Ruby on Rails and it turned out to be quite a learning experience for a guy who has spent the majority of his developer lifetime in windows based systems.
I decided to go with an Ubuntu virtual machine due to some of the stories I’ve heard from others who’ve tried to do Rails development on windows. Initially, I built an Ubuntu 8.10 VM using VMWare Workstation 6.0.x on Vista…but ran into some odd issues with VMWare Tools. After reading the support documentation on VMWare’s website, I found that Ubuntu 8.10 is only supported on VMWare Fusion (yes, the simple solution here would be to join the cool kids and go MBP). The next most recent release, Ubuntu 8.04, is however supported by VMWare Workstation 6.5, so I upgraded Workstation and installed 8.0.4…this time with VMWare Tools playing nicely.
After having to start from scratch a couple of times, I decided to document my installation steps. Hopefully this will help some of you get started…or, more likely, serve as a reminder for myself the next time I need to rebuild.
Step 1: Let’s make sure our system is up to date and have the build software installed.
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install build-essential
Step 2: Install Ruby (I’m using v1.8) and the supporting libraries (rdoc, mysql, etc.).
sudo apt-get install ruby ri rdoc mysql-server libmysql-ruby ruby1.8-dev irb1.8 libdbd-mysql-perl libdbi-perl libmysql-ruby1.8 libmysqlclient15off libnet-daemon-perl libplrpc-perl libreadline-ruby1.8 libruby1.8 mysql-client-5.0 mysql-common mysql-server-5.0 rdoc1.8 ri1.8 ruby1.8 irb libopenssl-ruby libopenssl-ruby1.8 psmisc
Step 3: Install Ruby Gems (I’m on 1.3.1, you may want to check Ruby Forge for the latest version).
wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
tar xzvf rubygems-1.3.1.tgz
cd rubygems-1.3.1
sudo ruby setup.rb
Step 4: Sanity check – let’s make sure gems are up to date.
sudo gem update –system
Step 5: Just in case a symlink didn’t get automatically created, let’s manually create them.
sudo ln -s /usr/bin/gem1.8 /usr/local/bin/gem
sudo ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
sudo ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
sudo ln -s /usr/bin/ri1.8 /usr/local/bin/ri
sudo ln -s /usr/bin/irb1.8 /usr/local/bin/irb
Step 6: And now it’s time for rails!
sudo gem install rails
Step 7: For testing, you’ll probably want RSpec. (Note that RSpec will be automatically installed as well because it is a dependency of RSpec-Rails).
sudo gem install rspec-rails
Step 8: Git seems to be the preferred choice for source control among rails developers.
sudo apt-get install git-core curl gitweb
After installing, you’ll probably want to set your username/email that other developers will see when you make your commits.
git config –global user.name “your name”
git config –global user.email “youremail@yourdomain.com”
Verify the changes
git config –global –list
And if you’re using github for hosting, you’ll need to provide an SSH key. This page has a great overview of how to do that.
Step 9: Sqlite is a great alternative to MySql for local development.
sudo apt-get install sqlite3 swig libsqlite3-ruby libsqlite3-dev
sudo gem install sqlite3-ruby
Step 10: I decided to give JetBrain’s RubyMine a shot. So far, it’s been making the transition from Visual Studio+Resharper a little easier thanks to the common keyboard mappings.
First, you’ll need the Java JDK if you don’t already have it installed.
sudo apt-get install sun-java6-jdk
Next, download RubyMine. After you download it, unpack it to your installation folder of choice.
tar xzvf rubymine749.tar.gz /usr/bin/rubymine749
Update: I believe the above line should have been two steps:
tar xzvf rubymine749.tar.gz
sudo mv rubymine749 /usr/bin/
To run ruby mine, you need to set the JDK_HOME environment variable. I added the line “export JDK_HOME=”/usr/lib/jvm/java-6-sun/” to the top of the file “/usr/bin/rubymine749/bin/rubymine.sh” so I wouldn’t have to remember to set it every time I start the IDE.
To start, run this command from within the /usr/bin/rubymine749/bin folder:
sudo ./rubymine.sh
Step 11: Once I get the hang of the language, I’m going to give Vim another shot as a text editor. Baby steps though, just moving from the my Visual Studio+Resharper sweet spot is enough of shock for now.
sudo apt-get install vim-full vim-gnome vim-ruby vim-rails
And for some awesome Vim extensions, check out what Joe Fiorini has out on github.
Good luck!!
Thanks for the great guide!! I have been looking for the latest and greatest way of installing all of the tools but this is the first complete guide that I have found so far that is easy to follow.
Ubuntu, sudo, and git? Sniff sniff. I’m so proud. 🙂
Great post! I actually run Ubuntu 8.10 just fine through VirtualBox on my Windows 7 machines. So I may try to follow this as best as I can so that I can add Ruby to my Ubuntu development VM.
And great choice of editor there! I really enjoy using vim!
Every time I try learning vim or emacs, I start bleeding from the ears. 🙂