How to Setup Ruby on Rails in Windows 7

Here’s what worked:

I opened my web browser and searched for “how to install ruby on rails on windows 7” and found a new site called Railsintaller, which has the DevKit and SQLite3 included in the installation file! I downloaded the installation kit and went to the installation directions page which had step-by-step instructions on how to install Ruby on Rails in Windows.

HINT: The “$” signs in front of the commands used in their instruction page are not meant to be typed in. They are used to signify the beginning of a line of code, but not meant to be typed into the console.

After downloading and running the executable from Railsintaller you are prompted for your name and email address, then the prompt sits waiting for a hand-typed response. This is where you create a new Ruby on Rails (RoR) application by typing: rails new [application name] (where application name is the name of the application you want to create).

Next, browse to the application folder by using the “CD” (change directory) command like this: cd [application name]. For simplicity, Railsinstaller has created a new directory on the root of your computer called C:Sites. This is where your application folder is stored. From this directory you can now start the RoR application by typing: rails s (or “rails server”).

Windows Firewall may initially block the server attempt, but simply click “Allow” and then browse to http://localhost:3000 on your computer. “Welcome aboard. You’re riding Ruby on Rails!” Further instructions walk you through obtaining a text editor and setting up a GitHub account, but I’ll leave that up to you to read through.

HINT: The console window has to stay open to use the web app. As soon as you close the console window, the browser window no longer responds.

Here’s what didn’t work:

1. Download the Windows RubyInstaller and install.
2. Download RubyGems and extract it.

Did you install the app from step 1 and extract the folder from step 2? If yes to both, continue.

3. Open “Start Command Prompt with Ruby” from the Start Menu under Programs > Ruby.
4. Use DOS “CD” commands to browse to where you extracted the RubyGems folder.

I extracted mine to C:Users[Username]Downloadsrubygems-2.0.0rubygems-2.0.0, which means at the command prompt I had to change directories (CD) by typing: cd C:Users[Username]Downloadsrubygems-2.0.0rubygems-2.0.0 to navigate to that directory (replace [username] with your Windows username and CD to wherever you extracted the folder).

5. Once at the correct directory in the “Start Command Prompt with Ruby” interface, type: ruby setup.rb
6. If successful, it should say, “Ruby Interactive (ri) documentation was installed…”

How to Install Ruby on Rails

With RubyGems loaded, you can now install all of Rails and its dependencies through the “Start Command Prompt with Ruby” interface.

7. At the “Start Command Prompt with Ruby” command line, type: gem install rails
8. Wait. Nothing will happen for a second. This takes a while, depending on your computer speed. Follow the prompts if you get a yN question.

After it’s complete, it will say something like “..gems isntalled” and you will be back at the command prompt. Nothing will happen next until you create an application.

9. At the “Start Command Prompt with Ruby” command line, type: rails new C:Users[Username]Rails[ApplicatonName] (where [username] is your Windows username and [application is your new application’s name – don’t worry, it will create the directory if it doesn’t exist).
10. After that’s complete, at the command line type: cd C:Users[Username]Rails[ApplicatonName] to change directories and then type: rails server.

You should now be able to browse to http://localhost:3000 on your PC and begin using the web interface there, but for me it didn’t work right away. When I initially attempted to run “rails server” I got the error message, “Could not find gem ‘jquery-rails (>= 0) x86-mingw32’ in the gems available on this machine. Run `bundle install` to install missing gems.” However, running “bundle install” would do several things, but the end result would be the same. I’d get the same error. After doing some research I found help on Stack Overflow that mentioned installing the gems one by one. I started by typing “gem install jquery-rails”, which installed successfully, but when I typed “rails server” to start the server, I got a “coffee-rails” error so I typed “gem install coffee-rails” and waited for that to install before typing “rails server” again. Every time it couldn’t find a gem, I just kept typing in the gem name with the install command until they were all installed. For some reason “bundle install” wasn’t working for me, but individual installs would.

When I got to the “sqlite3” error, the message was different. It said, “Error installing sqlite3 The ‘sqlite3’ native gem requires installed build tools. Please update your PATH to include build tools or download the DevKit.” I didn’t see that anywhere in the instructions so again I had to research it and found out the DevKit is a separate install from a different download page (it’s at the bottom – get the “tdm” one, not the “mingw” one)). You’ll want to put these files wherever you originally installed the other Ruby files. For me it was C:Ruby200 and I copied the extracted files into C:Ruby200Devkit. Using the “Start Command Prompt with Ruby” command line, type: “ruby dk.rb init” then “ruby dk.rb review” and finally “ruby dk.rb install”. The DevKit is now installed, which meant I could then install sqlite3 by typing: gem install sqlite3, but this time the error message was different. It said, “sqlite3.h is missing. Install SQLite3 from http://www.sqlite.org/ first.” Wow. This is like a wild goose chase. After searching around I couldn’t find anything particularly useful, but one site mentioned a possible borked installation of rails so I reran the “gem install rails” command, not knowing what effect that would have. It came back with “1 gem installed”. Again I attempted to start the server by typing: rails server, which didn’t work, so I uninstalled it.

Ruby Installer for Windows

I downloaded the Ruby Installer and re-installed Ruby in a different directory with the same result. I found forums that talked about copying the sqlite3 DLL and EXE files into the Windows System and System32 folders, which I did, but it didn’t seem to make a difference. I couldn’t seem to get past the sqlite3 header issue so I closed all of the programs I had open and uninstalled Ruby again.

Posted

in

by