by Jay Fajardo
It turns out that Mongoid dependencies starting from 3.x require you to use Ruby 1.9.3 while Webbynode only has 1.9.2 when creating a standard RAPP instance.
The solution isn’t as hard as it seems. Most of the stress I experienced was tracing the problem and finding out that there wasn’t anything on the web to directly point you to a solution.
So instead of searching for “Ruby 1.9.3 on Webbynode”, I tried researching for “RVM on Webbynode” and found this article by Andre Honsberg, which pointed me in the right direction.
To make things simpler for the common Webbynode deployer, here are are the steps one needs to take to make Ruby 1.9.3 (and future rubies) work on your webby.
RVM is the key.
The Ruby Version Manager (RVM) is clearly the best way to manage multiple rubies in development and can make your deployments more flexible when you deal with many ruby projects using varying ruby versions.
Note My web server preference is Nginx + Passenger and the following steps are for that stack.
First, get on your webby’s shell using the CLI and install RVM.
This will download and run the RVM installation and create the .rvm folder and sources within your home directory (/var/rapp).
Next, add a reference in your .bashrc to the RVM working directory
Now re-initialize your bash terminal session
To test if the everything is all fine, type the following command and check if you get rvm is a function.
Installing Ruby with RVM.
All good? Awesome. Now we can install our ruby.
This installs 1.9.3 in your .rvm directory. You may want to download other rubies which will all be found in .rvm for you to manage and use as you want.
Now let’s make 1.9.3 our default ruby.
Let’s check our default ruby now by running it with the -v directive.
Note Anytime you want to see a list of rubies installed, you can issue the rvm list command where you’ll also see the current and default ruby version. Incidentally, anytime you want to revert to the system ruby version you can issue the rvm use system command.
Making Nginx use your new ruby version.
So now that we’ve got Ruby 1.9.3 on the web by, we’ll want to make Nginx use it for our app.
Let’s start by editing nginx.conf.
Look for the passenger_ruby directive which will likely be defined to point to the system ruby wrapper.
replace this line with
This will direct Nginx to start using your new ruby when Nginx next starts.
Note I used patch 327 of Ruby which was the latest one at the time I tried this.
Just to make sure my wrappers are properly formed, I issue the below command to update RVM and ask it to re-generate the wrappers.
Restart Nginx and resume fighting the good fight.
Verifying the version
To confirm that we’re using the new ruby version, from the webbynode CLI: