Upgrading to Ruby 2.1.4, from 1.9.3

January 2, 2015


Now that Rails 4.2.0 is out and several things have aligned, we took the plunge to upgrade to Ruby 2.1.4 from 1.9.3.

We had already upgraded to Rails 4.2.0.

Upgrading ruby was fairly straightforward, and we improved the AWS deployment in the process: faster updates & DB no longer tied to EB.

Here are the steps we took:

The plan was to create a whole new AWS EB environment using the latest 2014.09 AMI - 64bit Amazon Linux 2014.09 v1.0.9 running Ruby 2.1 (Passenger Standalone) And to install the matching ruby version in the windows development environment.

Part 1: Upgrade ruby in development environment:

cannot load such file – 2.1/pg_ext (LoadError)

fix => update gemfile to gem ‘pg’, ‘~> 0.18.0.pre20141117110243’ Note: pg 0.18.1 is now available All tests are now passing, in less time.

Part 2: Deploy to new Amazon AMI:

Step 1: To manage the Amazon RDS database from the Amazon RDS console instead of AWS Elastic Beanstalk, we first created the new RDS VPC Security Group, then created a new t2 Postgres DB instance linked to this Security Group.

Step 2: add Inbound access to the Security Group for my IP; take a backup of the existing DB and restore to the new DB.

Step 3: run “eb init” to update the settings for the new environment, then create EB with “eb start”

Got this error:

“Yum does not have postgresql-devel available for installation.” Fix => this AMI requires postgresql packages named postgresql92-devel / postgresql93-devel. so update and commit .ebextensions\packages.config file.

Step 4: test the environment URL

Got this error:

Nothing displays. On fetching logs: Passenger log indicates problem with “ENV[“DATABASE_HOSTNAME”]”.

Fix => requires the full DATABASE_URL specified in the environment variables ( omitted as a test )

Re-test the environment URL again

Got this error:

Site working but css is missing. On checking the eb-activity.log: “No assets:precompile task in Rakefile, skipping asset compilation” Fix => now compiling assets locally and checking into git - per advice http://guides.rubyonrails.org/asset_pipeline.html

So going forward, if deployment includes an assets change, run this locally:  bundle exec rake assets:precompile RAILS_ENV=production  ;  and commit new public/asset files to git.

Step 5: perform URL swap, verify product URL is now switched and working; terminate old environment.

Outcome:

Success! Early comparisons indicate Rails on ruby 2.1.4 is consuming less CPU and running faster than on 1.9.3 - great!

© 2020 Keith P | Follow on Twitter | Git