IntelliJ IDEA 2019.2 Help

Using the Bundler

IntelliJ IDEA supports integration with Bundler and enables you to handle gem dependencies for your application right inside the IDE. Before using Bundler, make sure that the following prerequisites are met:

  • Your project has the Gemfile. If not, you can create it by choosing the Tools | Bundler | Init command.

  • The Bundler gem is installed to the project SDK. If not, select Tools | Bundler | Install Bundler to do this. You can also install the Bundler gem along with other gems from the Gemfile

Install gems to local interpreter

You can install gems defined in the Gemfile to the local project interpreter as follows:

  1. Do one of the following:

    • Press Ctrl twice. In the invoked popup, start typing bundler, select bundle install and press Enter.

    • Click Tools | Bundler | Install. Within this menu, you can also use other Bundler commands such as Update, Clean, and so on.

    • Install missing gems using the Missing gem inspection provided by the IDE. For example, open the Gemfile, place a caret to any highlighted gem missing in the project SDK and press Alt+Enter:

      Gemfile inspection
    • When you open a project or change the project SDK, the following message displays:

      Gem manager

      Click Install to install missing gems.

  2. In the Bundle Install dialog, click Install to run the bundle install command without any arguments:

    Bundle Install dialog

    If necessary, pass the required arguments when running this command:

    Bundle Install dialog
  3. Wait until gems will be installed. The Run tool window will display this process:

    Bundler output

You can see the installed gems in both the Project Settings | Modules | Ruby SDK and Gems Ctrl+Shift+Alt+S page...

Ruby SDK and Gems page

… and the External Libraries node of the project tree:

External libraries

Install gems to project

IntelliJ IDEA allows you to work with gems installed not only to the SDK but to a project itself. To do this, pass the following argument when running the bundle install command: --path vendor/bundle

Bundle Install dialog

In this case, Bundler installs gems into the vendor/bundle directory and adds the .bundle/config file to a project’s root. IntelliJ IDEA processes this configuration file to detect that gems are installed into vendor/bundle.

Local gems will be displayed in the External Libraries node of the project tree:

External libraries

Install gems to remote interpreter

If you are using a remote Ruby interpreter, IntelliJ IDEA uses the Gemfile placed on a remote machine to install the gems. This requires configuring mappings between files of a local and remote project. To do this, click the Edit Path Mappings Edit Path Mappings button in the Ruby SDK and Gems page:

Ruby SDK and Gems page

In the Edit Project Path Mappings dialog, specify the local and remote project root paths:

Edit project path mappings

After you configured mappings, install gems using the Install Gems to Local Interpreter instruction.

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.

Last modified: 28 August 2019

See Also

Web Resources: