How To Install Ruby

How To Install Ruby

Emmanuel Ighosewe
Author
Emmanuel Ighosewe

Ruby is a well-known and highly respected programming language. There was a time when installing Ruby on Windows causes many issues; however, things have changed. Currently, no one has an excuse for not writing Ruby code on any platform.

Ruby was first released in the mid-1990s, and the popularity increased when Ruby on Rails was released in 2005. Ruby is an object-oriented programming language, but it also provides powerful features for programming functional. Unlike many other languages, it is less verbose and has a precise and concise syntax. Because of this simplicity, it is a good language. Ruby is designed to make the use easy and fun, yet powerful enough to build complex systems. This is a good choice for both beginners and experienced developers. The popular Ruby on Rails web framework supports many major websites, which means Ruby will be around for a long time.

This language has its basis in many languages, like Perl, Lisp, Smalltalk, Eiffel, and Ada. It is an interpreted scripting language, which means that most implementations can directly and freely execute instructions without compiling programs into machine-language instructions.

Downloading And Installing Ruby

You can download all the versions of Ruby from rubyinstaller.org. Download the newest version and follow the rest of the installation instructions.

Using RubyInstaller

If you are using the RubyInstaller, you must first download it from the website’s download page. Please note that the options list has two sections, "with devkit" and "without devkit." The Devkit version will install the MSYS2 system. If you need to install RubyGems that need to be compiled, you need to install this version. Using the old Ruby may allow you to delete the non-devkit version. If you want to use the Ruby on Rails app, you definitely need gems compilation, so the Devkit is required.

Also, note that different versions of Ruby are provided, and there are x86 and x64 packages. However, it would be best if you stuck with the x64 version. Download and run to get started.

  • You must first accept the license agreement.
  • Make sure to check the "MSYS2 Development Toolchain" option on the next screen.
  • Then click on "Next" and cool off. The installation process takes a few minutes.

Installing The MSYS2 Toolchain

After that, another essential checkbox will appear on the final installation screen: "Run" "ridk install" to configure MSYS2. The GUI installer will not do this part for you. Use this checkbox to start the next one.

Installing the development toolchain is a command-line process. Therefore, a terminal window will open to complete this section.

This "ridk install" command asks you the component you are installing. There is no issue if you just press “Enter” to accept the default settings. This will install the basic MSYS2 system, check for updates, and then install the development toolchain.

After scrolling, you will see many output streams. It takes the time that installing Ruby would take. Then the message “Installation of MSYS2 and MinGW development tool chain successful” should be displayed. Strangely enough, it will give you the same installation prompt. Press Enter to exit. The terminal window is closed.

Getting Ready To Use Ruby On Windows

To check your new Ruby installation, you'll need to reopen a terminal window. You can do this by opening the Windows menu and typing "cmd" in the search box. At the command prompt, type "ruby -v" and press Enter.

If you run the "gem list" command, you'll see the RubyGems that came with your new installation.

How To Install Ruby On Mac

The Ruby installation process for Windows has different instructions from Mac. However, if your platform is MacOS, then you can follow the instructions below to install Ruby.

Open Up The Terminal

The terminal application on macOS is a command-line interface (CLI) installed on new Macs. You can quickly open the terminal following these instructions:

  • Enter ⌘+space bar. This will display MacOS Spotlight Search, a search utility used to open applications on your Mac.
  • Input “Terminal” in the spotlight search.
  • Press Enter.

If you open a terminal (assuming the configuration is null), start from the home directory. Did you know that the Ruby version is installed by default on your Mac computer? You can find that by entering some commands in the terminal. Using the which command, we can see the location of the executable file on the computer.

which ruby

Ruby will be passed as an argument so that this command will find the location of the Ruby executable. This command will notify us that Ruby cannot be found if Ruby is not installed or unavailable.

Now, check the installed version of Ruby by entering the following command.

ruby -v

Here we process Ruby CLI and use the -v option for this. The -v option tells Ruby CLI to return our Ruby installation version. If you don't need the latest version of Ruby, then you should not proceed. But as good software developers and system administrators, we like to keep track of things and install updated versions when possible. To do this, we will install a package manager.

Install a package manager

Package Manager is an application whose task is to manage the software on your computer. In this situation, managing means installing, updating, and removing the software as required. The package manager installs software constantly and keeps your computer clean.

In addition, macOS has an excellent package manager called Homebrew. And homebrew software is written in Ruby. You can use the command line below to install Homebrew.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install Ruby using the package Manager

Okay, now that Homebrew is installed, we can install the latest version of Ruby. The command is straightforward:

brew install ruby

With this command, Homebrew will fetch Ruby and all the dependencies required for Ruby to run.




Hire the top 1% tech freelance talent through Upstack.