How to set up a Ruby development environment

Although setting up a Ruby development environment can be simple, it’s crucial to follow the correct steps to guarantee a hassle-free workflow. We’ll give a thorough walkthrough of how to set up a Ruby development environment on the PC. Let’s presume we’re running a Unix-based operating system like Linux or macOS, although we’ll occasionally include instructions particular to Windows.

Step 1: Install a terminal (Linux/macOS)

We already have a terminal if we’re running Linux or macOS. Throughout the setup procedure, we will run commands from this terminal. For Windows, consider installing Git Bash or utilizing Windows Subsystem for Linux (WSL).

Step 2: Install a version manager (optional)

The use of a Ruby version manager, such as Ruby Version Manager (RVM), is advised but not required. With the aid of these tools, we can isolate our projects and manage various Ruby versions on our system. Here, we are using RVM to demonstrate this.

Installing RVM

# Install RVM
\curl -sSL https://get.rvm.io | bash -s stable
# Load RVM into your shell session
source ~/.rvm/scripts/rvm
# Install a Ruby version (e.g., Ruby 2.7)
rvm install 2.7
# Set the default Ruby version
rvm use 2.7 --default

Step 3: Install Ruby Gems

Packages and libraries called Ruby Gems are used to increase Ruby’s functionality. We don’t need to install them separately because they are already included with Ruby.

Step 4: Install a text editor/IDE

To write Ruby code, we’ll need a text editor or an Integrated Development Environment (IDE). Some popular options include Atom, RubyMine (a Ruby-specific IDE), Sublime Text, Visual Studio Code, and others.

Step 5: Create a directory for our Ruby projects

Putting our Ruby projects into a designated directory is a smart idea. We can now begin coding after creating a folder for our projects and navigating to it in the terminal.

Step 6: Write our first Ruby program and run it

We create a file with the .rb extension, such as hello.rb, then launch our text editor to view it. We write a basic Ruby program that looks like this:

puts "Hello, Ruby!"

Once we have written the program, we’ll save our file. In the terminal below, type the following commands:

  • nano hello.rb (this will open the hello.rb for you to edit and create it if it does not exist already).

  • Write a basic ruby program such as puts "Hello, Ruby!".

  • Save the file using the command "CTRL+X" and Press "Y".

  • To check whether the ruby environment is functional, use ruby hello.rb command, and the output should be the content of your hello.rb file.

Terminal 1
Terminal
Loading...

Step 8: Installing Gems

We can install external libraries with the gem command if our project needs them. For instance, here’s how to set up the well-liked pry gem for debugging:

gem install pry

Step 9: Set up a version control system (Optional)

We can think about collaborating with people and tracking changes in our code using a version control system like Git. For this, we’ll create a repository for our project using Git and install it:

# Install Git (if not already installed)
# Follow the instructions at https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
# Initialize a Git repository
git init

Step 10: Start developing!

Setting up our Ruby development environment was successful. We can now start creating applications, developing Ruby code, and learning about the Ruby environment.

Although the project’s specific requirements might vary, following these steps should provide a strong foundation for Ruby development.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved