Install Ruby on Rails on Windows & Linux
First we will start with installing Ruby on Rails on a windows system, we would be requiring couple of software that needs to be downloaded from the internet.
- Rails Installer ( download )
- Node Js ( download for 32 bit | 64 bit )
- Sublime text for code editor ( download for 32 bit | 64 bit )
- Sqlite3 DB Browser ( download for 32 bit | 64 bit )
Rails Installer consists of the following : ruby 2 , rails 4 , bundler , git , sqlite database & devkit.
Incase your computer has an admin user, then login as admin and install, else install the software as a regular user. Restart the computer once all 3 software are installed.
After restart follow the following steps :
STEP 1 – Open command prompt and goto c:/Sites
STEP 2 – rails new my_ap
NOTE – While working with windows majority of people might get a SSL Error, you will need to follow the instructions mentioned below to have it fixed.
Solution for Windows SSL Error (FIXED)
After following these steps, it will take a few minutes for all the libraries to be downloaded and installed on your computer. These steps (1-5) needs to be followed every time you start a new project.
Installing Ruby on Rails on Ubuntu 16x
The first step is to install some dependencies for Ruby.
STEP 1 - sudo apt-get update
STEP 2 - sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
rbenv is a simple two step process. First you install
rbenv, and then
STEP 3 - git clone https://github.com/rbenv/rbenv.git ~/.rbenv
STEP 4 - echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
STEP 5 - echo 'eval "$(rbenv init -)"' >> ~/.bashrc
STEP 6 - exec $SHELL
STEP 7 - git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
STEP 8 - echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
STEP 9 - exec $SHELL rbenv install 2.3.1 rbenv global 2.3.1 ruby -v
STEP 9 - gem install bundler (note - run
rbenv rehashafter installing bundler)
STEP 1 - git config --global color.ui true
STEP 2 - git config --global user.name "YOUR NAME"
STEP 3 - git config --global user.email "YOUR@EMAIL.com"
STEP 4 - ssh-keygen -t rsa -b 4096 -C "YOUR@EMAIL.com"
To install NodeJS, we’re going to add it using the official repository:
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - sudo apt-get install -y nodejs
And now, without further adieu:
gem install rails -v 4.2.6
If you’re using rbenv, you’ll need to run the following command to make the rails executable available:
Now that you’ve installed Rails, you can run the
rails -v command to make sure you have everything installed correctly:
rails -v # Rails 4.2.6
If you get a different result for some reason, it means your environment may not be setup properly.
Linux installation steps have been taken from Go Rails Website, if you are using other versions of Linux, you will find more information in this link. Check it out 🙂
Install Sublime-Text-3 via package manager:
sudo add-apt-repository ppa:webupd8team/sublime-text-3 sudo apt-get update sudo apt-get install sublime-text-installer
ERROR (FIXED) :
When you try to check the rails version in Command Prompt, you might get this following error ,
The system cannot find the path specified.
- Open the
rails.batfile (By default in :
- Find the line of code showing a path like this,
- Replace the line with
- After changing, your file will look like this,
@ECHO OFF IF NOT "%~f0" == "~f0" GOTO :WinNT @"%~dp0ruby.exe" "C:/Users/emachnic/GitRepos/railsinstaller-windows/stage/Ruby2.2.0/bin/rails" %1 %2 %3 %4 %5 %6 %7 %8 %9 GOTO :EOF :WinNT @"%~dp0ruby.exe" "%~dpn0" %*
- Repeat Steps 2 to 4 for
bundle.batfile in the same folder.
rails -vto check the version of Rails installed.
- And, that’s it.. Happy coding!