Switching Between Ruby Versions on Windows

I had the need to handle multiple Ruby versions on my Windows PC.  I was creating a new Rails app and wanted to use the latest Ruby version, but I also needed to manage apps that used older versions.  Many developers use RVM, but it doesn’t work on Windows – so I needed a different solution.

I found URU and it works great for managing multiple Ruby versions.

I tried installing it by downloading the compressed file and running the executable included, but it didn’t work correctly.  For some reason, it created a new directory, but the directory was empty.

So instead, I used the Scoop method – downloading Scoop and then using it to install URU.

(1) After I installed URU, I added the directory to my PATH (environmental variable) on my PC.

(2) Next, I opened a CMD window, and then specified the bin directories for each Ruby version you want o use.  For example entering this on the cmd line (for each Ruby install):

uru admin add C:\ruby200\bin

(3) Then to switch between Ruby versions you enter the command, including the Ruby version (without periods):

uru 200

This will switch to Ruby 2.0.0.

To view the Ruby versions you can switch to, use:

uru ls

You can check that you were switched by entering this command to check what version you are using:

ruby -v

The first time that I did this, I just installed the new Ruby version and I received an error telling me that my gemfile specified version 2.4.4, but I was running 2.2.1.  That was weird because when I ran ‘ruby -v’, it told me I was on 2.4.4.

It turns out, I just needed to run ‘bundle install’ to install the gems that were in the app I was trying to run, but not installed for the new Ruby version yet.

For more details on URU commands, you can read this page from the wiki.

Creating a CSR on Windows

In order to create a SSL Certificate, you need to generate a CSR, or Certificate Signing Request.  I ran into some issues when generating one from Windows, so I wanted to document the steps that I took.

  1. went to http://slproweb.com/products/Win32OpenSSL.html to download Win32 OpenSSL v1.0.0k
  2. installed OpenSSL
  3. I received an error regarding C++ during the install, so I installed Visual C++ 2008 Redistributables from the same page I downloaded OpenSSL
  4. Run a command prompt (cmd.exe from the search box in the Windows start menu)
  5. When I tried to run an OpenSSL command, I received an error that a file could not be found (WARNING: CAN’T OPEN CONFIG FILE: /USR/LOCAL/SSL/OPENSSL.CNF)
  6. As noted here, you have to set the environmental variable by typing this into the cmd: set OPENSSL_CONF=c:\[PATH TO YOUR OPENSSL DIRECTORY]\bin\openssl.cfg
  7. navigate to the bin directory
  8. enter your openssl command to generate your csr.  For me, it was:
    openssl req -nodes -newkey rsa:2048 -keyout myserver.key -out myserver.csr
  9. this created key and csr files I could use for creating my SSL certificate

Running Memcached on Windows

I needed to run memcached locally on my Windows PC.  These are the steps to making it work on Windows.

(1) Download the Memcached program (32 bit)

(2) Extract the exe to C:\memcached

(3) Open your start menu

(4) In the Search box at the bottom, enter “cmd” – don’t hit enter!

(5) Instead of enter, press Ctrl+Shift + Enter.  This should allow you to run the command prompt as the administrator, as long as your Windows user ID is set-up as an admin

(6) use the `cd` command to navigate to get to: C:\memcached

(7) once there, enter: memcached.exe -d install

(8) next enter: memcached.exe -d start

You should now be running a memcached server.  To check, open the Windows Task manager and on the Services tab, you should see “memcached”.

Editing Hosts File as Administrator on Windows

I was having an issue editing the hosts file on Windows.  I was receiving an error saying that only the Administrator could edit the file since the etc directory was protected.  My user has Administrator access so I couldn’t understand what was going on.  I tried to change the settings on the etc directory and could not do that either.

So I ended up opening Wordpad (which I use to edit the hosts file), by right-clicking and selecting Run as Administrator.  Once I did that and opened my hosts file in Wordpad, I was able to save the file.

Creating a Manifest.json file for the Google Chrome Store in Windows

I ran into an issue with my manifest.json file when trying to submit my app to the Google Chrome Store.  I followed the directions, but apparently there was a detail that was so simple, it wasn’t documented.  The documentation says to create a text file to put the manifest code, and then to save it as manifest.json.  However, when I loaded my zip file, I kept receiving error messages saying that the manifest.json was not at the root level and couldn’t be found.  The only thing was the file was of course there, and there were no subdirectories in my zip file.

It turned out to be a stupid, basic mistake.

When I looked at the properties of the file, the file was a .txt file, and the full name was actually manifest.json.text even though I couldn’t see the .txt part in Windows Explorer.  I found the solution was that when the file was created, I should have named it manifest.json, but also when I saved it in Notepad, I should have selected “Save as type” as “All Files”.  When you look at the properties, the file type will now be “json” instead of “txt”.

Error: C:/Dev/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require’: 193: %1 is not a valid Win32 application

I was receiving this error which was preventing me fom running my Rails server or any other commands locally:

C:/Dev/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require’: 193: %1 is not a valid Win32 application.   – C:/Dev/Ruby193/lib/ruby/1.9.1/i386-mingw32/digest/sha1.so (LoadError)

It started after I implemented a web hook, which conflicted with a local application.  I found out by after finding this post:


In the case of the poster, an app called FRAPS was causing the issue.  I don’t have that program, but after closing a bunch of apps from Windows’ Task Manager, it was working again.

Getting Thin Gem to Work on Heroku When you Develop in Windows

Upgrading to Heroku’s Cedar stack, I had to install the Thin gem to prevent my app from running on Web Brick.  On the Bamboo stack this is injected so I need not worry, but with Cedar you need to install all the gems you need.

The problem is that I work on Windows in development and that one of the dependencies for the Thin gem is the Eventmachine gem.  However, Eventmachine isn’t really geared towards Windows environments (except gem install eventmachine –pre), so everytime went to run bundle install the install would fail because the dependency, eventmachine 0.12.10 could not install.

However, Heroku helped me find a solution.

Add this to the gemfile

group :production do
gem ‘thin’

and instead of ‘bundle install’, run ‘bundle install –without production’


It has not been a picnic using RSpecs.  One of the steeper learning curves I’ve found in Rails.  Here are some random tidbits I’ve found:

(1)  the rspec command doesn’t get recognized in Windows for me.  So I have to do: rake spec:controllers (or whichever folder)

(2) to run a single test, from the root directory, do:

bundle exec rspec spec/(path to file).rb


bundle exec rspec spec/controllers/user_controller_spec.rb