Back to blog

Installing Ruby on Rails on Win7 [DEPRECATED]

September 2, 2010 - Posted in Blogs , Ruby on Rails Posted by:

Tags: , , , , , , ,

[headline h="1"]This method is deprecated[/headline]

In the last two articles, I talked about what is Ruby and what is Ruby on Rails. and what is the meaning of MVC architecture. So we kinda have a general idea of what we will be talking about in the following articles. From this Article we will not only talk but we will start to create our first Ruby on Rails Application. and to do so we have to know what tools we will be using. and what is the best for us.

IN this whole Course I’ll assume that most of you are working on windows 7 machines. Ruby can be used in any operating systems and I’ll talk shortly on how to install the development environment on your system. So let’s get started. What we will do in this Tutorial is:

  • Install Ruby: Ruby recommends to install Ruby 1.8.7 or Ruby 1.9.2.
  • Install Rails: The current Rails version is 3.0.0 which were released August 29th, 2010.
  • Install Database Server: For Database I’ll use MySQL Community Server 5.1.50.
  • Testing your development environment by running your first application.

As we already know by now that Rails is an Open Source Web Application Framework written in Ruby. So to install Rails we first need to install the language and it’s package manager.

Get Listed

Installing Ruby:

As a Windows user the easiest way to get Ruby running on your machine is by using Ruby Installer. This is a self-contained Windows-based installer that includes the Ruby language, an execution environment, important documentation, and more.

1. Simply go to Ruby Installer for Windows Download Page and select the MSI installer files. In this tutorials I assumed that you will select the latest version or Ruby which is Ruby 1.9.2. So you will need to download the Ruby 1.9.2-p0.

2. After downloading the installer file, run it and accept the terms then on the installation destination and optional tasks page, browse to the location you want your installed files to be located “I prefer to make a folder called Ruby on the same partition where Windows folder are”. and don’t forget to check the check boxes as in the figure below.

Ruby 1.9.2 Installer

3. We have to make sure that our Ruby installation was successful. So we go to our Command Prompt “Start > All Programs > Accessories > Command Prompt” and type the following:

ruby --version

then hit enter. If no errors appears and the Ruby version displayed correctly as shown in the next image. Then you have successfully installed the Ruby Language on your Windows 7 System.

Check Ruby Version

Installing Rails:

1. Now it’s time to install the Rails. Simply type in the following command in your command prompt to install Rails and all dependencies

gem install rails --include-dependencies

This will take a while depending on your internet connection. So you can set back and grab yourself a cup of coffee.

Installing Rails

2. If everything went okay you should be able to see something link the previous image. at that point you have done so good. next step is to install our Database server.

3. now we need to install the required gems for rails and that can be made by running the following command in your command prompt:

bundle install

and now you are ready for the next step.

Get Listed

Installing Database Server:

I’d prefer to use MySQL as a database engine for my Rails applications. However you can feel free to use SqlLite3 which is by default the database engine associated with Rails.
1. Download the MySQL Community Server 5.1.50 select the recommended MSI Installer Essentials.

2. After downloading and running the installer make sure to choose complete on the first screen.

MySQL Server Installer

be sure to check on all windows warning before proceed.

3. After completing the installation wizard you will find a check box to start configuring your server

MySQL Server Wizard Complete

click on finish and let’s start customizing your MySQL server.

4. Follow the following screen:
a. Detailed Configurations
Detailed Configuration

b. Developer Machine
Developer Machine

c. Multifunctional Database
Multifunctional Database

d. MySQL Datafiles
InnoDB tablespace settings

e. Decision Support (DSS)/OLAP
Decision Support (DSS)/OLAP

f. TCP/IP Networking Port Settings & Firewall Exception
Port and Firewall Exception

g. UTF-8 Language Support “because we might write down stuff in arabic or in any other language than english and western languages”
UTF-8 Language Support

h. Service Name
Service Name

j. Security Settings
Security Settings

Hit next then execute and wait till all check points are green and voila, your MySQL server is ready… Next step is to test your installation and check if your computer is ready for the rails or not.

Get Listed

Testing your development environment:

1. Open a new Command Prompt window and navigate to the folder you want your projects to be created. I’ve created a new folder named it “Ruby Apps” and placed it in the root of my D: partition.

c: Users Hashem>D:
D:>md "Ruby Apps"
D:>cd "Ruby Apps"
D:Ruby Apps>

2. Now we will create a test application with the name of “my_app” and to do so we type the following command in the command prompt window

rails new my_app

Now a folder will be created including the complete folder and file structure for your new application.

3. Now it’s time to run the server and test the application we just created. Ruby installation comes with a build in web server called WEBrick. To run the server navigate to the newly created application and run the following command:

D:Ruby Apps>cd my_app
D:Ruby Appsmy_app>rails server

The WEBrick will communicate to your localhost via port 3000. so now head up to your browser and open

http://localhost:3000

If everything went ok you should be now looking at the Ruby on Rails: Welcome aboard default page.

You’re riding Ruby on Rails!

Notes:

  • The server will be closed if you terminate the command prompt window at any time. so be sure to leave that window open during the whole process when developing an application.
  • To terminate the server manually press “Ctrl + C” or just hit the close button.

You are done

Congratulations, Now you have created and tested your development environment. If you faced any problems please do not hesitate and post them in the comments and I’ll get back to you with the answer at once.

Next time we will get more into creating our first simple Rails application. so stay tuned and you might wanna subscribe to our weekly Rails newsletter. Till we meet again, Have fun & Happy riding…

Get Listed

37 Comments

Luis Lavena 4 years ago

Hello, nice tutorial.

I would avoid recommend run things ad ministrator unless you installed RubyInstaller as administrator.

So if you didn’t install Ruby as administrator, no need to run the command prompt as one.

Even if your account belongs to administrators group, the installer do not require elevation of privileges.

Reply

Hashem E.Zahran. 4 years ago

Hello Luis, Thanks for stepping by.. You are right i was just working on a remote PC with and Administrator account that’s why most of the CMD screens are with the Admin level…

Reply

Luis Lavena 4 years ago

Cool.

Another missing point is that using MySQL 5.1 will not work with binary mysql 2.8.1 gem. Either you will need to compile it (using the DevKit) or copy the 5.0 libmysql.dll

I know, a huge bummer, but at least you can compile it!

Details for that in our tutorials page:

http://github.com/oneclick/rubyinstaller/wiki/tutorials

Reply

Hashem E.Zahran. 4 years ago

Thanks Luis, I’m aware of this issue but that appeared only when installing older version of Ruby & Ruby Gems. Actually that was fixed in the new version of Ruby Installer & the new Rails… I faced that when installing 1.8.7 & 1.9.1 but not anymore with this new version. I had to make sure that everything is working fine on a new fresh installation of windows on my development machine and it was all about the bundle gem installer in this version…

The good thing in this new version, when you create a new project using the “rails new” command, it tells you what is missing before it continue to create your app. also when you run “rails new -d mysql” it checks if it will work or something is missing as well. Which is pretty cool feature. as I spent days trying to figure out why it’s not connection to MySQL server…

Reply

Luis Lavena 4 years ago

Hmn, maybe you’re not following me. I’m talking about mysql 2.8.1 gem, which binary has been compiled for MySQL 5.0, not 5.1

Most of the time it will fail to work since libmysql.dll differs, ending on a segmentation fault and crash.

vignesh 2 years ago

file lib is missing like tat i’m gettig error any one can help me in this

Hashem E.Zahran. 4 years ago

Aha, Thanks for correcting me Luis, I think I miss understood your point. I’ve been with ruby from only 8 months now. Didn’t face much problems till now but Um sure your help in correcting and following my tutorials will be a great help for me… Thanks again having the RubyInstaller Developer following my humble blog is a great pleasure :)

Reply

Tim Santeford 4 years ago

Hey thanks for the post. You have a typo in step 1, “-include–dependencies” should be “–include-dependencies”. Could you do a post on installing curl and curb on windows? Thanks!

Reply

Tim Santeford 4 years ago

Yikes your blog post filter stripped out the dashes. I ment to post “{dast}{dash}include{dash}dependencies”

Reply

Sarah 4 years ago

Thanks for a great tutorial, it helped me alot

SArah

Reply

mithun 4 years ago

Hi
i am getting trouble in creating database i am using postgresql

Reply

mithun 4 years ago

Hi
how to create database and table in ruby on rails and how to use

Reply

Gwen 3 years ago

I am getting errors while installing. Error while generating documentation for activerecord-3.0.9 Message: Invalid argument -./</cdesc-<.ri and then while installing documentation for rails I get the error file 'lib' not found. Can you help?

Reply

foxrafi 3 years ago

I have the same problem, please help?

Reply

Hashem 3 years ago

Hello Kindly be informed that those are now an outdated installation instructions for older versions of Ruby & Rails.. Kindly visit http://railsinstaller.org/ or http://rubyinstaller.org/

Reply

Miserable 2 years ago

Can you update the page to say this method is deprecated? I had a beast of a time until i finally found your comment that says “don’t do this” …may save someone else some time

Reply

Toan Nguyen 3 years ago

Please help with ‘lib’ not found. I did try reinstall dozen time. T.T

Reply

Web Design Atlanta 3 years ago

Thanks for give this information, but i am getting erroe with installation…

Reply

Amit 3 years ago

Can i use sqllite database instead of Mysql, will it be compatible with ruby 1.9.2 version.

Reply

Sultana 3 years ago

I can’t install bundle please tell me the instruction for that. I have window 7.

Reply

prasanna 2 years ago

I have got different message like “file ‘lib’ not found ” and unable to use bundle

Reply

Bharath Kumar 3 years ago

Excellent… Thank you so much…

But I got some error while installing about “json”. I installed DevKit to fix it.

Anyway Very nice Thank you so much.

Reply

Agus @ Ruby on Rails 2 years ago

A very good example of a complex explanation being explained in a way that encourages people to take on the task of adventuring into Ruby. If anyone had issues with mysql gem wanting to be installed all the time. Even though it has been. Go to the bin directory under the mysql main directory and copy libmysql.dll to your ruby bin directory. This will solve the quirky problem

Reply

rajesh 2 years ago

is there any one to help me. Im having problem in installing bundle install. It is showing that
case 1:when installing directly as above stated.
c:windowssystem32>bundle install
could not locate Gemfile

case2: when im running it after creating small my_app application.
D:Ruby Appsmy_app>bundle install
Fetching source index for https://rubygems.org/
Could not reach rubygems repository https://rubygems.org/
Could not find gem ‘jquery-rails (>= 0) x86-mingw32′ in any of the gem sources l
isted in your Gemfile.

Reply

Allerin - Ruby on Rails 2 years ago

Really great Job explaining the Ruby on Rails Installation on Windows 7.
Snap Shots of each step and explanation resembles great professionalism in author.
Keep it up
Thanks for Sharing

Reply

Snave 2 years ago

Hi, been installing ruby on rails got to as far as installing
RDoc documentation for rails-3.2.6… and got an error afterwards file ‘lib’ not found
does that mean that all the other successful installations were a waste of time or should I just ignore it.
please do advise thanks.

Reply

Rahman 2 years ago

So do I, lib not found. what is the problem. Give me solution, please

Reply

Dpli 2 years ago

Can anyone help me for this? I have problem while installing rails on my sytem….

ERROR: Error installing rails:
ERROR: Failed to build gem native extension.

C:/Ruby192/bin/ruby.exe extconf.rb
creating Makefile

make
‘make’ is not recognized as an internal or external command,
operable program or batch file.

Reply

ram 2 years ago

me too strucked at same point

Reply

reza pahlevi 2 years ago

would you explain how do you ignore the warnings and errors?

Could not locate Gemfile
and
lib not found

This installation guide simply won’t work as described.

Reply

reza pahlevi 2 years ago

dear Hashem,
why don’t you tell them to try the following?
1. install DevKit
2. create file “gemrc” with following content
:ssl_verify_mode: 0
this would help a lot! and imho it is better than censorship.
best regards,
reza

Reply

pixeldesign 2 years ago

not install rails how to do that?plz help

Reply

anil 1 year ago

I am getting this error

C:UsersRUBY>gem install rails –include-dependencies
INFO: `gem install -y` is now default and will be removed
INFO: use –ignore-dependencies to install only the gems you list
ERROR: Error installing rails:
actionpack requires rack (~> 1.4.0, runtime)

Reply

Prasanna 1 year ago

Hey I am getting trouble in installing the bundle ‘bundle install’.It is giving error that gem file not found.

Reply

Leave a Reply

%d bloggers like this: