Set up a Ruby development environment
Process overview
This topic explains the process of setting up a Ruby development environment on your local machine. Note that there is no one process that is equally good for all platforms and purposes. We only recommend some of the best practices, which you will pick from based on your own needs and local machine operating system.
Install Ruby
In this topic, we focus on the reference implementation of Ruby (Ruby MRI), although RubyMine also supports alternative implementations, such as JRuby or TruffleRuby.
There are plenty of options, which are described in the Installing Ruby topic. The key factors to consider are:
Your operating system (Linux, macOS, Windows)
Preferred tools: system package managers (Homebrew, atp, etc.), Ruby version managers (rbenv, RVM), and Ruby installers (ruby-build, ruby-install), RubyInstaller
(For Windows) Whether you are planning to use Rails
If you have difficulty choosing your solution, we suggest that you use one of the few procedures below. They utilize the methods we consider most popular and straightforward among users today.
Expand the procedure for your platform to read the details.
Install Ruby on Linux
This procedure explains how to install Ruby on your Linux system using the rbenv tool considered one of the most popular Ruby version managers. It allows installing different versions of Ruby and easily switching between them.
(Prerequisites) Do the following before installing Ruby:
Update your Linux distribution by running the following commands in your terminal:
sudo apt update sudo apt upgradeYou will be asked for your login and password. After you enter both, press Enter. Then, when prompted, press Enter one more time.
Install the required packages and libraries by running the command below:
sudo apt install gcc make libssl-dev libreadline-dev zlib1g-dev libsqlite3-dev libyaml-devWhen prompted, press Enter. You may be required to re-enter your login and password (press Enter then).
Install rbenv:
Clone the rbenv repository:
git clone https://github.com/rbenv/rbenv.git ~/.rbenvSet up rbenv on your system:
~/.rbenv/bin/rbenv initWhen completed, close the terminal window and open a new one to make sure the changes take effect.
Install the ruby-build plug-in by running the following command:
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-buildInstall Ruby:
(Optional) To view the latest stable version of Ruby, run the following command in the terminal:
rbenv install -lTo install a specific version of Ruby, run this command:
rbenv install {your_ruby_version}Verify your installation by running the command below:
ruby -vYou should get the Ruby version you selected to install.
Related links
Alternative method
Other popular methods of installing Ruby on Linux are by using Ruby Version Manager (RVM) or Ubuntu's APT package manager. Find more details here.
Install Ruby on macOS
Ruby is included by default in macOS since El Capitan (10.11). However, this is an outdated version not designed for customer use. We recommend installing Ruby through version managers to ensure the compatibility of all dependencies required for your projects and avoid any permission issues.
This procedure explains how to install Ruby on your macOS system using the rbenv tool considered one of the most popular Ruby version managers. It allows installing different versions of Ruby and easily switching between them.
(Prerequisites) You will need the Xcode IDE and the Homebrew package manager. Unless they're already on your system, do the following:
Run the following command in your terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"This will install Homebrew, which should automatically download and install Xcode.
Run the
brew configcommand to check the installation of Homebrew. Specifically verify the line for Xcode.If Xcode is still not installed, run the
xcode-select --installcommand.
Now you're system is ready for Ruby installation.
Install rbenv:
Run the following command:
brew install rbenvAfter the installation is complete, run the following command:
rbenv initClose your terminal tab and open a new one to make sure the changes take effect.
Verify that the installation was successful by running the command below:
rbenv -vYou should get the rbenv version installed on your system.
Install Ruby:
To view the latest stable version of Ruby, run the following command in the terminal:
rbenv install -lTo install a specific version of Ruby, run this:
rbenv install {your_ruby_version}
Verify your Ruby installation:
ruby -vYou should get the Ruby version you selected to install.
Related links
Alternative method
Another popular method of installing Ruby on macOS is by using Ruby Version Manager (RVM). Find more details here.
Install Ruby on Windows
There are two popular methods of installing Ruby on Windows:
RubyInstaller: self-contained Windows-based installer
Windows Subsystem for Linux (WSL): recommended if you plan to work with Ruby on Rails
There are two popular methods of installing Ruby on Windows:
RubyInstaller: self-contained Windows-based installer
Windows Subsystem for Linux (WSL): recommended if you plan to work with Ruby on Rails
Select the tab for your preferred method and follow the instruction.
Use the RubyInstaller tool
Go to this page and download the desired version of the Ruby installer.
Run the downloaded executable file. This will open the Ruby installer wizard.
On the first page of the wizard, check the I accept the License checkbox and click the Next button.
On the next page of the wizard, do the following:
Specify where to install Ruby: leave the default option or specify a new location.
Click the Next button.
On the next page of the wizard, make sure the MSYS2 development toolchain checkbox is selected and click the Next button. This will launch the process of extracting files.
Once all files are extracted, you will see the final page of the wizard. Leave the Run ‘ridk install’ to set up MSYS2 and development toolchain checkbox selected and click the Finish button.
A terminal window will pop up with MSYS2 installation settings. Leave everything at default and press Enter. This will install the selected components, followed by a window with a success message. Press Enter again.
Verify your Ruby installation by running the following terminal command:
ruby -vThis should return the Ruby version installed to your system.
Configure WSL
Download and install a WSL distribution (for instance, Ubuntu) from Microsoft Store.
For this step, be sure to use at least Windows 10 or later with the latest “Fall Creators Update” (minimum version 1709, build 16299.15). See the official guide Install the Windows Subsystem for Linux for instructions.
To work with WSL 2, your Windows version should be 10 build 18917 or later. Follow these instructions to switch the distributive.
Run the Linux distribution.
Upon the first launch, the system may prompt you to enable the Windows optional feature. In this case, you need to do the following:
Open Windows PowerShell as Administrator and run
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-LinuxRestart your computer.
(Optional) If your Linux distribution doesn't come with
rsync, you need to install it, for example:apt-get install rsyncyum install rsync
Now that you can use Linux commands, follow the procedure above to install Ruby.
After you install a Ruby interpreter on your system, make sure to configure it in RubyMine.
Set up Ruby gems
The installed Ruby interpreter is supplied with a set of third-party libraries. Most of these libraries are distributed as gems, packaged libraries or applications that can be installed with a tool called RubyGems. This tool is bundled with Ruby MRI, so most likely, you don't need to install it separately. You can learn more about this tool from the official Ruby documentation.
Set up Bundler
To manage dependencies specifically required for each of your projects, you will use a tool called Bundler. This tool lists each project's dependencies in Gemfiles, which are placed in respective project root directories.
Normally, the installed Ruby interpreter comes with Bundler installed, but its version can differ from the one required for your project. In such cases, RubyMine suggests installing the required version. Learn how RubyMine integrates with Bundler from the Bundler topic.
Set up a Rails development environment
To work with Rails projects in the IDE, you need to install the rails gem and its dependencies to the Ruby interpreter.
Install Rails gem
There are several options to do it in RubyMine:
When creating a new Rails application, you can install the 'rails' gem right from the New Project wizard.
For existing projects, add the 'rails' gem to your Gemfile and install it using Bundler.
Open the embedded RubyMine terminal emulator and execute the
gem install railscommand.
The next step in this process is installing dependencies required for Rails projects.
Install Git
When you create a new Rails project, make sure to install Git beforehand. This step is necessary since RubyMine automatically creates a local Git repository for all new Rails projects.
Install database tools
Rails development heavily relies on using relational databases. The most common database management systems (DBMS) used in Rails are SQLite, MySQL, and Postgres. To work with a desired DBMS , we recommend that you install the respective package using your system package manager. For example, to install Postgres, use one of the commands below:
macOS
brew install postgresqlLinux (including WSL for Windows)
sudo apt install postgresql postgresql-contrib
Install JavaScript tools
Rails applications can contain JavaScript modules managed in the following ways:
Webpacker: a wrapper gem on Webpack – the popular tool used for managing and bundling JavaScript code.
Asset Pipeline: a legacy framework for working with JavaScript and CSS assets in Rails.
Note that the Webpacker is a default JavaScript compiler starting with Rails 6. To use Webpacker in your applications, you need to install the following tools:
After that, you can install JavaScript dependencies right from RubyMine and work with your JavaScript code.