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 thecommand.
Install gems to local interpreter
You can install gems defined in the Gemfile to the local project interpreter as follows:
Do one of the following:
Press Ctrl twice. In the invoked popup, start typing bundler, select
bundle installand press Enter.
Click Update, Clean, and so on.. Within this menu, you can also use other Bundler commands such as
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:
When you open a project or change the project SDK, the following message displays:
Click Install to install missing gems.
In the Bundle Install dialog, click Install to run the
bundle installcommand without any arguments:
If necessary, pass the required arguments when running this command:
Wait until gems will be installed. The Run tool window will display this process:
You can see the installed gems in both the Project Settings | Modules | Ruby SDK and Gems Ctrl+Shift+Alt+S page...
… and the External Libraries node of the project tree:
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:
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:
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 button in the Ruby SDK and Gems page:
In the Edit Project Path Mappings dialog, specify the local and remote project root paths:
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 button in the Ruby SDK and Gems page.