Installing Ruby On Rails On Windows

Step by step guide

Introduction

Installing Ruby On Rails on windows can be time consuming. This is due to several errors that are encountered during the process by windows users.

Cause of errors

  • Lack of powerful command line in windows
  • Lack of Sqlite 3 database
  • Gems configuration.

Prerequisites

To overcome these errors, install the prerequisites in the following order

  1. Install Cmder to use as cmd or install windows subsystem for Linux
  2. Have a code editor of your liking
  3. Install Ruby language
  4. Install Sqlite
  5. Install Rails

Procedure

To start with you have to install ruby on your computer. The installation can be accessed from the ruby installer website. After installing ruby, install Sqlite by downloading the precompiled binaries for windows from the website. You will need to download both the dll and the tools zips. After extracting the zips copy paste the contents into bin folder of the ruby path. If you installed ruby on the C drive. You will see a ruby folder which has a bin folder inside it. You can now check if ruby was installed successfully by open in the Cmd line and running theruby --version command. Similarly, check if Sqlite3 was installed by running the command sqlite3 --version

After installing the two its now time to install Rails. As shown in the documentation, the following are the steps:

  1. Create a folder where your Rails project will live
  2. Navigate to your folder using command line and run the command gem install rails
  3. Run the command rails new your project name
  4. Navigate into the project you just created
  5. Run the command bin/rails server

    Errors expected

    This should start up the server on local host 3000 on your browser or throw some errors. The most common error is None of the paths included in TZInfo::DataSources::ZoneinfoDataSource.search_path are valid zoneinfo directories. (TZInfo::DataSources::ZoneinfoDirectoryNotFound) It is caused by the gem "tzinfo-data" not reading the system details of windows operating system.

    Solving errors

    This can be solved in the following steps

  6. Open your project in a code editor

  7. Navigate to the gem files
  8. Locate the gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
  9. Delete the platforms and remain with gem "tzinfo-data"

Save the file and start the server again and voila