Configure a Ruby interpreter
To work with a Ruby project in IntelliJ IDEA, you need to configure the required Ruby interpreter. You can set the interpreter for the currently opened project or when creating a new project.
Configuring the Ruby interpreter depends on the way you installed it:
If you installed Ruby using a package manager (apt for Ubuntu, Homebrew for macOS, and so on) or Ruby installer (for example, RubyInstaller for Windows), you need to add it manually.
If you are using Ruby installed in an isolated environment (Docker, Vagrant, WSL, and so on), IntelliJ IDEA allows you to configure it as a remote interpreter.
Add a local interpreter
To add a local interpreter manually, perform the following steps:
Open the Project Structure dialog Ctrl+Alt+Shift+S and select Modules on the left.
In the Ruby SDK and Gems page, click the button and select New local:
Provide a path to the Ruby executable, for example:
/usr/local/bin/ruby for Ruby installed on macOS using Homebrew.
/usr/bin/ruby for Ruby installed on Linux using apt.
C:\Ruby26-x64\bin\ruby.exe for Ruby installed on Windows using RubyInstaller.
IntelliJ IDEA will display the added interpreter along with automatically detected interpreters.
To remove the interpreter from the list, select it, and click the button.
Select an auto-detected interpreter
Select an interpreter on the Ruby SDK and Gems page
To select the auto-detected Ruby interpreter maintained by the version manager, follow the steps below:
Invoke the Project Structure dialog Ctrl+Alt+Shift+S and select Modules on the left.
Choose the required Ruby interpreter. You can also choose the gemset for the RVM and rbenv version managers.
For the selected Ruby interpreter/gemset, you can see the installed gems on the right. Learn more about Ruby gems support at Bundler.
Switch an interpreter using Run Anything
If you use RVM or rbenv to manage local Ruby SDKs, you can quickly set the required interpreter using Run Anything:
Press Ctrl twice.
In the invoked popup, start typing
rbenv shell, select the required interpreter and press Enter.
(Optional) If necessary, click the Rollback button in the popup that informs about the changed SDK.
Add a remote interpreter
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 IntelliJ IDEA and run, debug, and test your application in an isolated environment right from the IDE.
To configure a remote Ruby interpreter, follow these steps:
On the toolbar, click , and choose New remote...:
In the Configure Remote Ruby Interpreter dialog, select the desired option (SSH, Docker Compose, and so on) and specify the required settings.
Note that when you are using a remote interpreter, IntelliJ IDEA downloads gems from a remote machine to a local cache to be able to use code insight features. In this case, you may encounter a situation when new gems were installed on a remote machine outside the IDE. To update a set of gems stored in a local cache, click the Synchronize gems button in the Ruby SDK and Gems page.
(Optional) Specify mappings between files of a local and remote project. To do this, click the button. In the Edit Project Path Mappings dialog, specify the local and remote project root paths.
Note that IntelliJ IDEA detects Vagrant synced folders, WSL mappings, and so on. These mappings are listed in this dialog and cannot be changed.