Set up a Ruby development environment
Install prerequisite dependencies
RubyMine supports the reference implementation of Ruby (Ruby MRI) and alternative implementations, such as JRuby or TruffleRuby. Before installing the Ruby interpreter, you need to install the dependencies required to compile Ruby on your machine. For example, depending on your operating system, these dependencies can include the following tools and libraries:
Ubuntu: build-essential, libssl-dev, etc.
macOS: xcode-select, openssl, etc.
Depending on the way you've chosen to install Ruby, these libraries can be installed manually or automatically. For example, the Ruby Version Manager (RVM) installs the required libraries automatically while the ruby-build utility requires installing them manually.
After installing prerequisite dependencies, you are ready to install the Ruby interpreter to your local machine. There are plenty of options that are described in the Installing Ruby topic. The main ways to install Ruby are:
- Version managers
Platforms: macOS, Linux
The most popular way to install Ruby on Linux or macOS is using a version manager, such as RVM, rbenv, chruby, or asdf. Version managers allow you to install several Ruby versions on your machine and quickly switch between them. RubyMine automatically detects interpreters installed on a local machine and maintained by version managers. You can learn more from the Ruby version managers topic.
- Package managers
Platforms: macOS, Linux
You can install Ruby on Linux or macOS by using the system's package manager. For example, this can be apt or snap for Ubuntu and Homebrew for macOS. Learn how to configure a project interpreter installed in this way from Add a local interpreter.
- Ruby installers
Platforms: macOS, Linux, Windows
You can install Ruby on Linux or macOS by using third-party installers, such as ruby-build or ruby-install. These installers can be used along with version managers to switch between different Ruby versions.
On Windows, you can use RubyInstaller to set up the Ruby environment quickly. If you are planning to develop Rails applications on Windows 10, the Ruby interpreter installed to Windows Subsystem for Linux (WSL) might be a better choice. In RubyMine, you can configure the Ruby interpreter installed to WSL.
The installed Ruby interpreter is supplied with a set of third-party libraries. Most of these libraries are distributed as a gem— a packaged library or application that can be installed with a tool called RubyGems. This tool is bundled with Ruby MRI starting with version 1.9, so most likely, you don't need to install it separately. You can learn more about this tool from the official Ruby documentation.
The next important library you need to install to your Ruby interpreter is Bundler. This tool allows you to manage your project dependencies and install exact gems and versions that are needed. These dependencies are specified in a Gemfile, which is placed in a project root directory.
As a rule, the installed Ruby interpreter comes with Bundler installed, but its version can differ from one required for your project. In such cases, RubyMine suggests you installing the required version. Learn how RubyMine integrates with Bundler from the Bundler topic.
To work with Rails projects in the IDE, you need to install the 'rails' gem to the Ruby interpreter. There are several ways to do this 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.
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 includes the Active Record framework for Object-Relational Mapping (ORM) - a technique that connects application objects to tables in a relational database management system. The most common database management systems used in Rails are Sqlite, Mysql, and Postgres. To use the desired database system in your project, install a corresponding package to your operating system. For example, to install Postgres on macOS using Homebrew, execute the following command in a terminal:
Various remote development tools, such as Docker, Vagrant, or Windows Subsystem for Linux (WSL), allow you to use an isolated environment for developing your applications. This can be useful in multiple cases, for example, if you want to:
Develop in an isolated environment to avoid impacting your local machine configuration.
Run, debug, and test your application on the same operating system you deploy.
Develop Linux-deployed applications using the Windows Subsystem for Linux.
You can prepare the desired Ruby/Rails setup in a remote environment using Docker Compose, Vagrant box, or WSL. Then, you can add the remote Ruby interpreter in RubyMine and run, debug, and test your application in an isolated environment right from the IDE.