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
- Install Cmder to use as cmd or install windows subsystem for Linux
- Have a code editor of your liking
- Install Ruby language
- Install Sqlite
- 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:
- Create a folder where your Rails project will live
- Navigate to your folder using command line and run the command
gem install rails
- Run the command
rails new your project name
- Navigate into the project you just created
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 thegem "tzinfo-data"
not reading the system details of windows operating system.Solving errors
This can be solved in the following steps
Open your project in a code editor
- Navigate to the gem files
- Locate the
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
- Delete the platforms and remain with
gem "tzinfo-data"
Save the file and start the server again and voila