RubyMine 2016.2 Help

Running RubyMine as a Diff or Merge Command Line Tool

In this topic:

Overview

Besides using RubyMine as an Integrated Development Environment, you can use it as a command line tool for comparing and merging files.

RubyMine executable is platform-dependent:

  • Windows: RubyMine XX\bin\rubymine.exe or RubyMine XX\bin\rubymine.bat
  • UNIX: RubyMine XX/bin/rubymine.sh
  • OS X: /Applications/RubyMine XX.app/Contents/MacOS/rubymine

    To add the launcher to your path, add its containing directory /Applications/RubyMine.app/Contents/MacOS.

However, for OS X and UNIX, one should create a wrapper script, since this helps avoid some drawbacks related to the usage of RubyMine launcher.

Enabling invocation of RubyMine operations from the command line

For OS X and UNIX platforms, we recommend creating the wrapper script, or the command line launcher to integrate RubyMine with your shell. Then, you need to ensure that the created launcher script is within the search path of your shell.

On Windows, we recommend to add the path to RubyMine to the environment variable Path. Everything is done outside of RubyMine, with the RubyMine executable.

Note that if you have specified location of the RubyMine executable as a Path environment variable, the command will work no matter which directory you are currently in.

To enable invoking RubyMine operations from the command line, follow these steps

  • On OS X or UNIX:
    1. Make sure RubyMine is running.
    2. On the main menu, choose Tools | Create Command-line Launcher. The dialog box Create Launcher Script opens, with the suggested path and name of the launcher script. You can accept default, or specify your own path.

      Make notice of it, as you'll need it later.

    3. Outside of RubyMine, add the path and name of the launcher script to your path.
  • On Windows:
    • Specify the location of the RubyMine executable in the Path system environment variable. In this case, you will be able to invoke the RubyMine executable and other RubyMine commands from any directory.

Comparing files using RubyMine as a command line tool

To compare two files using RubyMine as a diff command line tool

  1. Enable invoking RubyMine operations from the command line.
  2. Type the following command at the command line prompt:
    <RubyMine launcher(Windows) or wrapper script (MacOS or UNIX)> diff <path to file1> <path to file2>
    where file1 is your local copy, file2 is the repository version.

For example:

rubymine diff README.md.bak README.md

Merging files using RubyMine as a command line tool

Most often you need to merge three versions of the same file: your local version, the version in the repository or in the upstream, and the base revision, which is the origin for the two diverged versions.

To merge files using RubyMine as a command line tool

  1. Enable invoking RubyMine operations from the command line.
  2. Type the following command at the command line prompt:
    <RubyMine launcher(Windows) or wrapper script (MacOS or UNIX)> merge <path to file1> <path to file2> <path to file3> <path to output>
    where file1 is your local copy, file2 is the repository version, file3 is the base revision for file1 and file2, and output is the file to save the merge results in (optional).

Passing three arguments to merge tool

It is possible to pass just three arguments to the merge tool:

<path to file1> <path to file2> <path to output>.

In this case, the contents of the output will be taken as the base revision:

<RubyMine launcher> merge <path to file1> <path to file2> <path to output> <path to output>

See the example in this blog to learn how to use RubyMine diff and merge tool with Git.

See Also

Last modified: 1 September 2016