Upgrading Ruby on Webfaction
I run a couple of web apps on Webfaction, one of them is a Rails application. The Webfaction one-click installers and GUI for managing your websites are very easy to use, which is what I love about their service.
Last week I encountered a challenge. My Rails app was using
Ruby v2.1.5 and I needed to upgrade to
v2.2.5. While Webfaction did provide the correct binaries in the
/usr/local/bin folder, I didn't know how to get my app to use the correct binary and also couldn't find any online documentation.
In the end it's not a hard thing, but it took me some time to understand, so I this blogpost is here for my own reference and it might help someone with a similar challenge.
I'm using Mina to deploy my Rails apps, because it's blazing fast and simple to use. With this in mind, my setup looks a bit like this:
$ ls -l /home/<user>/webapps/<appname> bin -> /home/<user>/webapps/<appname>/gems/bin current -> /home/<user>/webapps/<appname>/releases/<release-number> gems nginx releases
current directory is the
hello_world directory that the default Webfaction Rails installer generates.
The binaries that my Rails app use are located in the
gems/bin folder. And the binaries I needed where symlinked to the 2.1 versions in the
/usr/local/bin. So I removed the existing symlinks and made new ones for the 2.2 versions.
I went from:
$ ls -l /home/<user>/webapps/<appname>/gems/bin erb -> /usr/local/bin/erb2.1 gem -> /usr/local/bin/gem2.1 irb -> /usr/local/bin/irb2.1 ruby -> /usr/local/bin/ruby2.1
To the up-to-date:
$ ls -l /home/<user>/webapps/<appname>/gems/bin erb -> /usr/local/bin/erb2.2 gem -> /usr/local/bin/gem2.2 irb -> /usr/local/bin/irb2.2 ruby -> /usr/local/bin/ruby2.2
After this, my deploy script was still failing because it said my Ruby version was still 2.1.5 and my Gemfile requires 2.2.5. Running
gem install bundler from the root of the app solved the problem.
Don't forget to set the various environment variables when installing bundler again 😉