IntelliJ IDEA 2017.1 Help

Configuring SDK Gemsets

This feature is supported in the Ultimate edition only.

In this section:

Introduction

Gemsets are a convenient way to deal with the different gem environments for your applications. IntelliJ IDEA supports both RVM and rbenv gemsets.

Gemsets are supported for the following types of projects:

List of Ruby SDKs

To view the list of Ruby SDKs, available to the computer, follow these steps

  1. Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S).
  2. Click Modules and choose the desired module with Ruby support.
  3. Next, click the Gems tab, and observe the list:
    /help/img/idea/2017.1/ij_list_of_ruby_sdk.png

To select an SDK for a project, click the radio button to the left of the desired Ruby SDK, or press Space.

Note the following:

  • IntelliJ IDEA automatically detects Ruby versions installed.
  • Add or remove any local or remote SDKs with the buttons /help/img/idea/2017.1/new.png and /help/img/idea/2017.1/delete.png.
  • Expand/collapse buttons /help/img/idea/2017.1/expandAll.png//help/img/idea/2017.1/collapse_all.png are only available for macOS and *NIX platforms, as the ones having gemsets. For Windows platform, these buttons are disabled.
  • Speed search works for the list SDKs.

List of gemsets

For each SDK, open the list of available gemsets.

To view the list of gemsets for the selected SDK, follow these steps

  1. In the list of available SDKs, select the one marked with the icon /help/img/idea/2017.1/arrow_right_1.png to the left:
    /help/img/idea/2017.1/ij_gemset.png
  2. Do one of the following:
    • Press Enter.
    • Double-click the SDK node.
    • Click the button /help/img/idea/2017.1/arrow_right_1.png.
    • Press right arrow key.

Note that the previous selection of a gemset is preserved. You can quickly return to it by merely selecting the SDK in question.

RVM gemset

If you haven’t specified any RVM gemset to use with the project yet, then the default and global gemsets are selected.

However, one can select any desired gemset by hitting Space or clicking the radio button to the left of the gemset name.

/help/img/idea/2017.1/rm_rvm_gemsets.png

It's also possible to decide whether to use the global gemset (hit Space, or select/clear the check box). Global gemset (if selected) is used to share gems to all the gemsets within an SDK.

The default gemset, marked with a radio button, is used for any specific interpreter.

Creating RVM gemsets

For configuring RVM gemsets, one should use the files .ruby-gemset and .ruby-version. Refer to the rvm documentation.

Creating a dedicated RVM gemset on project creation

To create a gemset for the new Ruby/Rails project, follow these steps:

  1. Create a new project, as described in the section Creating Projects from Scratch in IntelliJ IDEA.
    As you type the new project name, IntelliJ IDEA suggests a gemset with the same name:
    /help/img/idea/2017.1/rm_new_rails_app_with_gemset.png

    Click the link Create to create the gemset (empty directory under the selected SDK).

    Next, select the check box Use gemset <name> to use the newly created gemset for your project:

    /help/img/idea/2017.1/rm_new_rails_app_with_gemset_1.png

    If you need to install Rails, note that Rails will be installed in this gemset.

  2. Now you are ready to create a new project with the gemset. Click the button Create for that.

Creating RVM gemset in the Setting/Preferences dialog

IntelliJ IDEA allows you to create an RVM gemset in the Setting/Preferences dialog. This is how it's done.

To create an RVM gemset

  1. Open the Setting/Preferences dialog.
  2. In the Ruby SDK and Gems page, click /help/img/idea/2017.1/add.png, and then choose New RVM gemset:
    /help/img/idea/2017.1/rm_new_rvm_gemset.png

    The dialog box opens:

    /help/img/idea/2017.1/rm_new_rvm_gemset_dialog.png
  3. In this dialog, do the following:
    • Choose Ruby SDK. If an RVM SDK has been selected for your project, then it is used. If an SDK has not been selected or a non-RVM SDK has been selected (for example, system, chef or remote), then the default SDK is used.
    • Specify the desired gemset name.

The gemset with the specified name appears under the selected SDK.

Rbenv gemset

For rbenv, the default gemset means the set of gems installed to the SDK folder, so you cannot unselect it (the check box to the left is disabled).

global gemset has no special behavior.

rbenvenables you to select as many gemsets as required (hit Space, or select/clear the check box to the left of the desired gemset).

Creating rbenv gemsets

Prerequisite

Before you start working with rbenv, make sure that rbenv-gemsets plugin is installed and enabled. The plugin is not bundled with IntelliJ IDEA.

There are the following ways of creating gemsets: using the commands of the rbenv-gemsets plugin, or using the .rbenv-gemset file.

To create a gemset commands of the rbenv-gemsets plugin, follow these steps:

  1. Open the Terminal tool window.
  2. Enter command in the format
    rbenv gemset create <rbenv version number> <gemset name>

    For example:

    /help/img/idea/2017.1/rm_create_rbenv_gemset.png

To create a rbenv gemset in the editor, follow these steps:

  1. Open for editing the file .rbenv-gemset (if the file does not exist, create it).
  2. Type the new gemset name. The following steps depend on the existence of a gemset:
    • If the gemset with the entered name exists, the completion is suggested:
      /help/img/idea/2017.1/rm_rbenv_gemset_completion.png
    • If the gemset with the entered name does not exist, then press Alt+Enter and choose the intention action Create gemset <gemset name>:
      /help/img/idea/2017.1/rm_create_gemset_intention.png

    Refer to the rbenv documentation.

As a result, the created gemset appears in the Project Structure Dialog dialog. Note that this gemset is already selected.

List of gems

In the Gems tab to the right of the selected Ruby module in the Project Structure Dialog dialog, there is the list of gems, available for an SDK or a gemset.

If you select an SDK, you'll see see all the gems available for the current project with that version. So doing, the gems of all gemsets are selected for the SDK in question.

Note the following:

  • If an SDK has no gemsets (as on Windows platform), then all the gems installed with the selected SDK are shown in the right-hand pane.
  • If an SDK has gemsets (as on macOS or *NIX platforms), then, when one selects a gemset, the gems for the selected gemset are shown in the right-hand pane. This is valid for both rvm and rbenv.
  • If an SDK has gemsets, and this SDK is selected, then the contents of the right-hand pane depends on the version manager used:
    • rbenv: the gems list shows all the gems from all the gemsets. So doing, the gems in the gems list have the note from which gemset they are taken. Same is valid for the External Libraries node in the Project tool window.
    • rvm: the gems list shows both the global gemset and one gemset selected (by default, this is the default gemset). So doing, the gems list bears no marking, as well as the External Libraries node in the Project tool window.

Speed search also work for the gems: just type a string, and speed search shows the matching entries only:

/help/img/idea/2017.1/ij_quick_search_gems.png

It's also possible to see the gem path, using the button /help/img/idea/2017.1/folder.png, and the web page with the gem description, using the button /help/img/idea/2017.1/web_icon.png.

See Also

Last modified: 18 July 2017