Specify gem version in ruby script

Amazon has recently launched AWS SDK for Ruby version 2. This was a good move, but unfortunately version 2 is not compatibe with version 1. Due to this my ruby scripts which were using old gem failed to work when I updated 'aws-sdk' gem.

This is how I tackled it. Now, that I have both the old and new version of them gems, I altered my old scripts to work with the v1 gem and the new ones to work with v2 gem.

# gem list --local | grep aws
aws-sdk (2.0.23, 1.60.1)
aws-sdk-core (2.0.23)
aws-sdk-resources (2.0.23)
aws-sdk-v1 (1.60.1)
#

I used below paramaters to point my old ruby scripts to old gem i.e. v1.

gem 'aws-sdk', '=1.60.1'
require 'aws-sdk'

The new scripts which will utilize v2 just needs to have 'require' as below.

require 'aws-sdk'

Hope this saves your time.

comments powered by Disqus