# Ruby Programming/Installing Ruby

← Overview | Ruby editors →
The first step to get started in Ruby development is setting up your local environment. Due to differences between various operating systems we will cover multiple of them. If you are already able to use a terminal emulator and know how to install Ruby yourself, you can skip this chapter (after you installed Ruby). Otherwise we will guide you through the process of installing Ruby on your computer.

## Terminal emulators

Knowing how to use a terminal emulator is very useful if you are programming. Usually it will provide the most straightforward access to commands and applications instead of hiding it behind graphical interfaces. On the other hand they are often daunting to beginners since they are often perceived to require a deep understanding of a computer when in fact often only knowing the very basics is already enough to get started.

### Unix-like operating systems

One of the most commonly used shells in the Unix-like operating systems (i.e. macOS, GNU/Linux, BSD) is the Bash shell, in fact it is very often the default shell. To start a session you will often use a terminal emulator, which allow you to use a terminal session at the same time as other graphical applications. It doesn't really matter, which terminal emulator you use, generally you want one that has color and Unicode support. In macOS you can use Terminal.app which you can find under Applications > Utilities. A popular alternative is iTerm. On most Linux distributions you will usually be provided with at least one terminal emulator by default, otherwise you might want to try Terminator, Konsole, rxvt-unicode or something different.
When you open a new window or tab in your terminal emulator of choice you will be shown your prompt. What it looks like exactly depends a lot on configuration, which can vary greatly from OS to OS (you can configure everything to your likings, however this exceeds the scope of this short introduction). Generally it will indicate your current working directory, username and hostname. When working in the shell your session always has current working directory. Commands that accept relative filenames will use that directory as the base directory to look for files. By default you are in your user's home folder, which is often abbreviated with a tilde (~).
To execute a command you just type it into the shell and press enter.
At first we want to look at the command ls. If you type it in just like that it will print the files and directories in your current working directory. You can also provide a relative path to a directory you want to list, e.g. ls DIR. If you want more detailed information about the files you can use ls -l DIR, if you instead want to also include invisible entries (i.e. names starting with a dot) use ls -a. Of course it is possible to combine them both by running ls -l -a DIR or the short form ls -la DIR. Note that this kind of concatenating multiple arguments into one is only possible with single character parameters. Parameters can also come in long form, for example the equivalent of ls -a is ls --all DIR. Which forms are available depends on the individual command.
Now you might be thinking how to remember all parameters for every command you will ever use. Thankfully you only want to remember the most important ones, which are the ones you use most frequently, otherwise there is a nice way to look them up. You can either use the man command. For example run man ls to find more information about the ls command. Oftentimes you can find a more concise summary by trying to run the command in question followed by the parameter --help, however this is not something you can expect to work well with every command, whereas manual pages should be always available.
Back to the topic of current working directories. If you want to change your directory you can use cd followed by the directory you want to change to. There are two special virtual directories '.' and '..'. The single dot refers to the current directory while the double dot refers to a dir's parent directory. So executing cd .. changes into the parent directory of the current working directory.
A very brief summary of other useful commands:
cat FILE: display the contents of a file.
mkdir DIR: create a directory.

## System-wide installation

A common and easy way to install Ruby is to perform a system-wide installation. Depending on the operating system installation procedures will be different (if required at all).

### Windows

Windows Operating System did not have Ruby programing language pre-installed (unlike other platforms listed here) . To install Ruby programming language, it is highly recommended to install it from here: https://rubyinstaller.org/ .
Refer to right side bar: WHICH VERSION TO DOWNLOAD? for guide to download which version to download. Usually it will recommend the latest stable version to be downloaded.
You might see the options of Ruby+Devkit installer version as a selectable component. This option is important as to build native C/C++ extensions for Ruby and is necessary for Ruby on Rails. Moreover it allows the download and usage of hundreds of Open Source libraries which Ruby gems (packages) often depend on.
Download it and double click the file to be installed on the local PC.
Once install it, double click of Ruby Installer to start installing it on Windows
Step 1: Select "I accept the license" and click "Next" button
Step 2: Select the directory that you wanted to install to and below , select the "Add Ruby executables to your PATH" and "Associate .rb and .rbw files with the Ruby installation". Click "Next" buttons"
Step 3: Select all the checkboxes inside the setup files. Click "Next"
Step 4: Click "ridk install" and click "Next" button to proceed
Once finished installing, type cmd into Window search bar and type ruby -v sto see which version of ruby that are installed. If it is showing, congrats, you successfully installed Ruby language in the system.

### macOS

Ruby comes preinstalled on macOS. To check which version is installed on your system, execute ruby -v inside a shell session.
If you want to install a more recent version of Ruby, you can:
* Update to a newer version of macOS, which may have a more recent version of Ruby.
* Use RVM or RBEnv tools specifically for managing multiple ruby versions (This is the most popular way because you can manage many Ruby versions and associate them with projects)
* Use Fink, MacPorts, Homebrew general purpose packaging systems for mac.

### Linux

On many Linux distributions Ruby is installed by default. To check if Ruby is installed on your system, run ruby -v in a shell session.
Where this is not the case, or you want to update the installed version, you should use your distribution's package manager. Here we will provide information for some popular Linux distributions here, however it is recommended to users of all distributions to familiarize themselves with their distribution's package manager, since this will allow for the most efficient software management. Whether this is a command-line or graphical application depends on the offerings of the distribution and personal preference of the user.

#### Debian / Ubuntu

The package manager Synaptic provides graphical package management. It is installed by default under Ubuntu and has to be installed manually on Debian (by running sudo apt-get install synaptic from the command line).
Instead of using Synaptic you can also use apt directly from the command-line (you can find further information in the Debian Wiki's article on Package Management). Execute sudo apt-get install ruby from the command line to install Ruby.

#### Fedora

From the command-line you can install Ruby with DNF by executing sudo dnf install ruby.

#### Arch Linux

Use pacman to install Ruby by executing pacman -S ruby as root.

#### Mandriva Linux

On Mandriva Linux, install Ruby using the command-line tool urpmi.

#### PCLinuxOS

On PCLinuxOS, install Ruby using either the graphical tool Synaptic or the command-line tool apt.

#### Red Hat Linux

On Red Hat Linux, install Ruby using the command-line tool RPM.

## Per-user Installation

Per-user installations allow each user of the system to utilize their own particular version of Ruby without impact to other users.

### Guix

To install the latest available version of Ruby, run: guix install ruby.

## Setup Ruby in Windows

Ruby does not come preinstalled with any version of Microsoft Windows. However, there are several ways to install Ruby on Windows.
* Download and install one of the compiled Ruby binaries from the Ruby web site.
* Download and run the one click RubyInstaller.
* Install Cygwin, a collection of free software tools available for Windows. During the install, make sure that you select the "ruby" package, located in the "Devel, Interpreters" category.

### Setup Ruby in Windows with Notepad++

In latest version of Ruby and Window 10 , it is much more easier to setup Ruby now more than ever.
We will be using to start setup Ruby in Windows.
Once install Notepad++ in Windows, open up the programs and click on Plugins > Plugins Admin
At Plugins Admin , select Plugins , NppExec to install
Once installed, you can run NppExec by pressing F6

## Building from Source

If your distro doesn't come with a ruby package or you want to build a specific version of ruby from scratch, please install it by following the directions here. Download from here.

## Compile options
### Building with debug symbols

If you want to install it with debug symbols built in (and are using gcc--so either Linux, cygwin, or mingw).

### Optimizations

Note that with 1.9 you can pass it --disable-install-doc to have it build faster.
To set the GC to not run as frequently (which tends to provide a faster experience for larger programs, like rdoc and rails), precede your build with
though you might be able to alternately put those in as opt or debug flags, as well.

## Testing Installation

The installation can be tested easily by executing:
This should produce an output similar to:
If this shows up, then you have successfully installed Ruby. However if you get an error similar to:
then you did not successfully install Ruby.