Getting Ruby 2.1 working with Windows 8.1, data_mapper and sqlite3

I have been playing with Ruby 1.9.3 for a year or two and I recently mentally made the decision to upgrade to Ruby 2.1. I knew it would take some work, but my decision was based on the following reasons:

* Heroku, where I want to deploy my web apps, runs Ruby 2.0+ and I wanted to minimise any potential conflicts when deploying.
* I wanted to take advantage of any extra sugar offered by 2.1.
* I figured 1.9.3 would be deprecated sooner or later, so may as well upgrade now while most of my code is (relatively) young and (relatively) malleable than when it is more mature and potentially vulnerable to more breaking changes.

There are a few gotchas in the process and I couldn’t find a single guide (that wasn’t rails-centric) that brought them all together so I hope this helps.

1. Download the ruby installer

http://rubyinstaller.org/downloads/

This step was pretty easy. Pretty much a double click of the installer and it pretty much installed itself. To check your version post-install, do a

ruby --version

2. Get the ruby devkit

At the same location you got the ruby installer, get the ruby devkit. To install it, follow the instructions here

https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

3. Workaround the SSL issue for rubygems goodness

Due to an SSL issue, rubygems will not be able to pull down your favourite gems. To workaround the issue, follow the steps here

Luis Lavena’s Helpful SSL Issue Page Aliased So It Doesn’t Uglify My Blog

4. Install sqlite3 by following these instructions somewhat blindly

Being a hack, I actually don’t know what’s going on with sqlite3 and data_mapper and Ruby 2.1, but follow the instructions here and you will be fine

https://groups.google.com/forum/?fromgroups=#!topic/rubyinstaller/gedIaMryCFQ

I used good old 7-zip to unpack that .tar file. I tried the bsdtar program but couldn’t get it to unpack the .tar file.

Not sure if necessary

Before I read the instructions on the page in step 4, I had also taken steps to download sqlite3 by following the steps on this page to no avail https://teamtreehouse.com/forum/gem-install-sqlite3-not-working. My conclusion is that manually downloading sqlite3 might not be necessary as long as you follow the instructions in the source in step 4.

And now, back to the installation:

Once you have unpacked knapsack locally, you should be able to use this to finally download sqlite3

gem install sqlite3 --platform=ruby -- --with-opt-dir=C:/Knapsack/x64-windows (or wherever you unzipped the knapsack files to)

Verily, after “–platform=ruby” there is a “–” before the “–with-opt…etc” which is important.

5. Install data_mapper

The following command should execute without issues:

gem install data_mapper

6. And, finally, install dm_sqlite_adapter

gem install dm_sqlite_adapter --platform=ruby -- --with-opt-dir=C:/Knapsack/x64-windows.

That’s it. You should be able to use your sqlite3 / data_mapper app in Ruby2.1 and Windows 8.1. Thanks to all of the authors of the instructions mentioned here.