Thursday, November 11, 2010

Success with rvm and ruby 1.9.2

Previous: Ruby 1.9.2, rvm, and Sinatra follies

So, I've spent a couple of evenings playing with Sinatra and MongoDB under ruby 1.8.7. I've learned a bit and made progress in getting Sinatra apps to run on localhost. When I reached the point that I needed an object mapper, I read the descriptions of the ones listed on the MongoDB site. MongoMapper looks really good; very well thought-out, very competently designed, very clean code. But another one, Candy, stood out for me because instead of mimicking the approach of ActiveRecord, it explicitly and unapologetically takes advantage of the unique, very non-relational characteristics of MongoDB.

Candy is relatively new code, and it requires ruby 1.9 as a baseline. That meant I had reached an appropriate point to re-try rvm and ruby 1.9.2.

Having installed rvm three times previously, making plenty of educational mistakes each time, I found the installation procedure easy and quick this time around. I left the system install of 1.8.7 in place, used rvm to install 1.9.2, and set 1.9.2 as the rvm default.

Next step was to ensure existing ruby apps would work under 1.9.2. I started my local Instiki instance and got this message:
Bundler couldn't find some gems.Did you run 'bundle install'?
I tried running 'bundle install' and got
'report-activate-error': Could not find RubyGem bundler
So, I tried 'rvm gem install bundler' and it worked. The 'bundle install' command then worked, too.

At that point Instiki started up normally. So far, so good! (I use Instiki for general notes and record-keeping, so it's in the nature of a "production" system for me. Getting it up and running is always the first order of business when I upgrade ruby.)

I changed to the directory where I've been playing with Sinatra and tried to start my test app. I have a Gemfile there, and when I ran 'bundle install' it appeared to download and install all the necessary gems under rvm.

When running cukes, specs, and the app itself I got a number of errors pertaining to files not found on 'require'. All these errors were due to require 'foo' instead of require './foo'. I expected this, since ruby 1.9.2 does not include the current directory in the ruby load path by default. Once I fixed that on a single line in a single file, everything that had been working before was working again under ruby 1.9.2. Nice!

I have some old side projects in rails that probably will not start. I'll get around to fixing them later. For now, I'm pleased to be up and running at last with rvm and ruby 1.9.2.

Next: Candy OM for MongoDB and ruby - FAIL

No comments:

Post a Comment