Environment Setup in Ruby
Ruby is an interpreted, high-level, general-purpose programming language. Ruby is dynamically typed and uses garbage collection. It supports multiple programming paradigms, object-oriented, including procedural and functional programming. Ruby is based on many other languages like Perl, Lisp, Smalltalk, Eiffel and Ada. This language has an elegant syntax that is natural to read and easy to write.
Below are the environment settings for both Linux and Windows.
Steps for Setting up Ruby Environment for Windows
- We can download Ruby from RubyInstaller.com
Click on any link as your preferred version depending on our Windows for say we can go with WITHOUT DEVKIT versions like Ruby 2.6.4-1 (x64) for Windows(64 bit) and the 2nd link which says Ruby 2.6.4-1 (x86) is for Windows(32 bit) as highlighted below, which is the latest version.
- After downloading the file, run the .exe file and follow the instructions to install Ruby on your Windows. Once you installed Ruby with default settings on your Windows, you have to setup environment variable.
- Go to Control Panel -> System and Security -> System.
Then click on Advanced System Setting option then under Advanced tab click on Environment Variables.
- Now, we have to Edit the “Path” variable under System variables so that it also contains the path to the Ruby environment. Under the System Variable select the “Path” variable and click on Edit button.
- We will see list of different paths, click on New button and then add path where Ruby is installed. By default, Ruby is installed in “C:\Ruby26-x64\bin” (in our case) folder OR “C:\Ruby26-x86\bin”. In case, you have installed Ruby at any other location, then add that in path, for example: if you have installed Ruby on other drive then go to that driver and locate the Ruby folder then inside the ruby folder a folder called bin will be there so copy the path and include it to System Variable’s Path like SomeDrive:\SomeFolder\RubyXX-xYY\bin
- Click on OK, Save the settings and we are done. Now to check whether installation is done correctly, open command prompt and type ruby -v and hit Enter. You will see some output like ruby 2.6.4p104 (2019-08-28 revision 67798) [x64-mingw32](in our case) on the console. It means we have successfully installed Ruby and we are good to go.
Steps for Linux
In linux(ubuntu), there are several ways to install Ruby like using third party tools. But we will refer to simplest and easy way to install Ruby using terminal.
- Go to Application -> Terminal
- Type command as below.
sudo apt install ruby-full
and press enter and enter your password. Wait for it to complete the download and then it will install Ruby on your machine.
- We are done installing Ruby on Linux. Now to check whether installation is done correctly, type ruby -v in the Terminal.If you see some text like ruby 2.6… it means u have successfully installed Ruby on your Linux.
Popular Ruby Editors/IDE :
- Notepad/gedit : They are simple text-editor for writing ruby programs. Notepad is available on Windows and gedit is available on Linux.
- NetBeans : It is a well known free IDE(Integrated Development Environment) for developing softwares in ruby. You can download NetBeans from here.