Webriti Themes Blog

Stay updated with our latest news

Step By Step Guide to install Ruby On Rails in Windows

priyanshu | Mar 1,2012 |   8 comments

Hi there, in this blog i will tell you how to install Ruby on Rails (RoR).Frankly speaking it takes me couple of days to get the things work’s properly, seriously , surfed a lot and finally came across one stop solution. When i was surfing, found number of forums regarding the issues of Ruby on Rails with the mysql gem, thats encouraged me to write this blog.
For the installation of ruby on rails i have preferred railsinstaller.
RailsInstaller has everything you need to hit the ground running. In one easy-to-use installer, you get all the common packages needed for a full Rails stack. Follow the steps carefully

Step 1: Download the railsinstaller package from here.

Step 2:After installing this package u will find  a directory by the name RailsInstaller according to the path selected by you during the installation and the menu in the start->All Programs->RailsInstaller…..

Step 3: Click the gitbash submenu in the RailsInstaller menu.A cmd type screen will gets open.

Step 4:check the ruby version by the command “ruby -v” and also the gem version by command “gem -v”. and this installs your ruby successfully along with the gems package.

Step 5:Check the rails version now:”rails -v” but this time you will find an unknown command because you had’nt install rails till now, so you got to do it by running a command “gem install rails” in the gitbash,this takes some time to install the rails. After the installation, again check the rails version and this time you will find the latest rails version.This finishes the installation of ruby on rails.

Step6: Now install the MySql installer verision 5.5.21 from here.You need to made couple of requirements inorder to run this msi package sucessfully one is .NET 4 framework and second Microsoft C++ runtime 2010 32 bit package.

Step 7:After successful installation edit the environmental variables path by appending value “<selected drive>\Program Files\MySQL\MySQL Server 5.5 “.

Step 8:Now moving on to the most difficult part: MySql gem installation:Download the gem package of mysql2 from github (just google it).Copy all the files from the root of the extracted folder.

Step 9:Next move to the path(as per you ruby and gems version’s) “RailsInstaller\Ruby1.9.2\lib\ruby\gems\1.9.1\gems” and create a folder by the name mysql2-<your gems version >, in my case named the folder as mysql2-0.3.11 and place all the copied files here.

Step 10:Now change your directory path to the mysql2 gems folder created above and Build Gem by the command:” gem build mysql2.gemspec “, ignore the warnings for now.

Step 11: Run the command subst x:”<selected drive>\Program Files\MySQL\MySQL Server 5.5 ”

Step 12: Run This Command gem install mysql2-0.3.11.gem --platform=ruby -- --with-mysql-dir=X: --with-mysql-lib=X:\lib.In the command specify this file mysql2-0.3.11.gem as per mysql2 gems version(refer step 9) .

Step 13 : Finally, the only thing  you need to make sure is the version of libmysql.dll i.e. mysql client library version, if you find any version related issues than get the latest dll file from the zip package of MySql Connector/c which can be downloaded from here and overwrite the libmysql.dll file in your RailsInstaller i.e in RailsInstaller\ruby version\bin.Now you are ready to create first RoR application with the mysql database.

For further assistance  leave me a comment.

 

8 Comments


Warning: Trying to access array offset on value of type null in /www/webriticom_319/public/wp-content/themes/webriti-theme-shop/inc/comment-function.php on line 11

Lili

March 18, 2012 at 2:03 pm

C:\Documents and Settings\zKF46724>gem install C:\mysql-2.8.1-x86-mswin32.gemERROR: While cineutxeg gem (RuntimeError) Error instaling C:\mysql-2.8.1-x86-mswin32.gem: invalid gem format for C:\mysql-2.8.1-x86-mswin32.gem前辈,我在安装mysql-2.8.1-x86-mswin32.gem的时候,老是报上面这个错,google上搜了一下,还是没有解决到问题。请问您知道是什么情况造成的吗?

    admin

    March 18, 2012 at 6:04 pm

    please post ur comment in english..may be i can help you in this

Josh

April 22, 2012 at 5:44 pm

How do you verify that steps 9-13 are working properly?

    admin

    May 8, 2012 at 5:35 pm

    i dont know about the verification part… but all these steps worked for me

shekhar chandra

March 14, 2013 at 8:06 pm

on executing step 12 it says file ‘lib’ not found.

jake

November 27, 2013 at 11:39 am

thank you.

It’s ironic that the railsinstaller site calls itself one click, but someone else has to make an actual step by step guide that isn’t 400 pages long.

jake

November 27, 2013 at 11:45 am

step 4 doesnt work.

Rajesh

April 27, 2018 at 8:27 am

Hi,
I have download and installed the ruby from rubyinstaller.org site. Version : 2.4.4.1(32-bit), also i have installed DEV kit in my machine. After ruby installation complete when i check the version in command prompt, it shows me a correct version and some of the gem list also able to view.
Then when i try to install the rails using the command “gem install rails”, i am getting an error “could not find a valid gem ‘rails’ (>= 0), here is why: unable to download data from https://rubygems.org/ – timed out (https: //api.rubygems.org/specs.4.8.gz)”
I am new to ruby on rails. I am not sure what is the mistake i am doing in installation. Can you please assist to resolve this rails installation issue.

Leave a Reply