Setup a Ruby on Rails ENV on your Windows Machine

Quick poll questions — if “windows” were spelled “WindowS” — wouldn’t that look cooler?

So finally… after days (not really), but quite a few frustrating hours I have set up a smooth running RoR development ENV on my WindowS machine! Super quick and blissfully easy on Linux or Mac, but I could not give up on the struggle to setup the ENV.

So what you need to do — which is actually very simple is assertively march across to RailsInstaller and download the bundle they have setup for us. Such kind peoples. Install the said bundle to your root directory a.k.a. (main drive) and kick back and relax. Majority of the required tools are included.

The ass ache which lead to a cancerous infestation inside my soul was due to a very simple problem with a hard to find solution.

What will happen once you have installed the well packaged RailsInstaller is the following. You will have rails and ruby set up. You will be able to run

:: rails new <whatever you want>

which will set up your Rails Application but once “bundle install” comes around, you will hit a bump. A simple bump :: merely stating the following:

Fetching gem metadata from https://rubygems.org/............
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies…
Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://rubygems.org/gems/rake-10.4.2.gem)
An error occurred while installing rake (10.4.2), and Bundler cannot continue.
Make sure that `gem install rake -v ‘10.4.2’` succeeds before bundling.

Easy, all I need to do is run “gem install rake” — noooope

first errror ::

ERROR: Could not find a valid gem ‘rake’ (>= 0), here is why:
Unable to download data from https://rubygems.org/ — SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/latest_specs.4.8.gz)

second error :: (I tried to be smart)

ERROR: Error installing rake:
“rake” from rake conflicts with C:/RailsInstaller/Ruby2.1.0/bin/rake

I was pulling out my hair with frustration, much like King Star King in most scene of that crazy wildly imaginative cartoon series… watch here

So I searched and searched, and once I found the solution I knew I had to share it with the world, to make setting up a Ruby on Rails Dev. ENV on WindowS simpler for the future and sanity of humanity.

Follow the steps below provided by Luis Lavena (luislavena)

Step 1: Obtain the new trust certificate

We need to download AddTrustExternalCARoot-2048.pem.

Use the above link and place/save this file somewhere you can later find easily (eg. your Desktop).

IMPORTANT: File must have .pem as extension. Browsers like Chrome will try to save it as plain text file. Ensure you change the filename to have .pem in it after you have downloaded it.

I made the mistake of using notepad and saving the file as mentioned above, the system still read it as a .txt file. So I used a simple IDE (atom), can use any, and copy pasted the text in there and save the file with the same new above. It worked.

Step 2: Locate RubyGems certificate directory in your installation

In order for us copy this file, we need to know where to put it.

Depending on where you installed Ruby, the directory will be different.

Take for example the default installation of Ruby 2.1.5, placed in C:\Ruby21

Open a Command Prompt and type in:

C:\>gem which rubygems
C:/Ruby21/lib/ruby/2.1.0/rubygems.rb

Now, let’s locate that directory. From within the same window, enter the path part up to the file extension, but using backslashes instead:

C:\>start C:\Ruby21\lib\ruby\2.1.0\rubygems

This will open a Explorer window inside the directory we indicated.

Step 3: Copy new trust certificate

Now, locate ssl_certs directory and copy the .pem file we obtained from previous step inside.

It will be listed with other files like GeoTrustGlobalCA.pem.

The following step is my own additional one

Step 4: Update and bundle install

navigate back to your newly created Rails Application directory and run

:: gem update — system

once that has completed run

:: bundle install

All bundles including rake will be installed and FINALLY you can run

:: bin/rails server

and travel across to https://localhost:3000

That’s all folks as Batman once said

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.