IntelliJ IDEA 2020.2 Help

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 installed Ruby using a version manager, IntelliJ IDEA should detect interpreters automatically. In this case, you can select the desired version.

  • 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:

  1. Open the Project Structure dialog Ctrl+Alt+Shift+S and select Modules on the left.

  2. In the Ruby SDK and Gems page, click the add button and select New local:

    New local interpreter
  3. 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.

  4. To remove the interpreter from the list, select it, and click the remove 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:

  1. Invoke the Project Structure dialog Ctrl+Alt+Shift+S and select Modules on the left.

  2. Choose the required Ruby interpreter. You can also choose the gemset for the RVM and rbenv version managers.

    Ruby SDK and Gems

  3. 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:

  1. Press Ctrl twice.

  2. In the invoked popup, start typing rvm use or rbenv shell, select the required interpreter and press Enter.

  3. (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:

  1. On the toolbar, click add, and choose New remote...:

    New remote interpreter

  2. In the Configure Remote Ruby Interpreter dialog, select the desired option (SSH, Docker Compose, and so on) and specify the required settings.

    Configure remote ruby interpreter

    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 Synchronize gems button in the Ruby SDK and Gems page.

  3. (Optional) Specify mappings between files of a local and remote project. To do this, click the Edit Path Mappings button. In the Edit Project Path Mappings dialog, specify the local and remote project root paths.

    Edit Project Path Mappings

    Note that IntelliJ IDEA detects Vagrant synced folders, WSL mappings, and so on. These mappings are listed in this dialog and cannot be changed.

Last modified: 28 August 2020