RubyMine 2017.3 Help

Using WSL as a Remote Interpreter

Prerequisites

This guide is valid for Windows with the Fall Creator's Updates installed.

We have to prepare our Windows system for work with WSL. So, fulfil the preliminary steps:

  1. Install Linux distributions from the Windows Store:
  2. Next, configure your distribution. Below is an example for Ubuntu:
    In the Windows command line, run:
    ubuntu config --default-user root

    Install and configure Ruby and its libraries. To do that, execute the following command:

    ubuntu run "apt update && apt -y upgrade && apt -y install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev ruby ruby-dev nodejs && gem update"

    This will install libraries that are currently necessary to build native extensions later.

Limitation

There are two known problems on WSL side (confirmed by Microsoft):

Preparing an example

In RubyMine, create an empty project intended for pure Ruby programming, give it the name "QuadraticEquation", then in the Project tool window right-click the project root, choose to create a Ruby file and type the following code:

class QuadraticEquation loop do p "insert first quotient" a = gets.to_f p "insert second quotient" b = gets.to_f p "insert third quotient" c = gets.to_f discriminant = b**2 - 4 * a * c square_root = Math.sqrt(discriminant) x1 = ((-b + square_root) / (2 * a)) x2 = ((-b - square_root) / (2 * a)) if discriminant > 0 square_root = Math.sqrt(discriminant) x1 = ((-b + square_root) / (2 * a)) x2 = ((-b - square_root) / (2 * a)) p "D = #{discriminant}, x1 = #{x1}, x2 = #{x2}" elsif discriminant == 0 x = (-b / (2 * a)) p "D = #{discriminant}, x1 = x2 = #{x}" else p "D = #{discriminant}, no roots" end end end

Configuring remote interpreter via WSL

Next, open the Settings dialog, and click the Ruby SDK and Gems page.

On this page, click add and choose New remote.... In the Configure Remote Ruby Interpreter dialog box that opens, click the WSL options:

rm configure remote interpreter wsl 1

Click OK.

Back on the Ruby SDK and Gems page of the Settings dialog, the new interpreter appears in the list of available interpreters, prepended with the prefix Remote: and followed by the suffix wsl.

You have to select the radio-button to the left to make this interpreter the project one:

rm configure remote interpreter wsl

Apply changes and close the dialog.

Running and debugging under WSL

Let's run and debug a script.

To run the script, right-click the editor background and choose Run <script name> on the context menu.

The script runs under the remote interpreter based on WSL.

rm wsl run

Let's do some debugging: you have to set a breakpoint and launch the debugger session.

  • Place a breakpoint. To do this, click the left gutter at a line where you want to place a breakpoint. See the Creating Line Breakpoints section.
  • To start the debugger session, right-click the editor background and choose Debug <script name>' on the context menu.

The script is debugged under the remote interpreter based on WSL.

rm wsl debug

Summary

Let's summarize what was done in this tutorial:

  • First, we prepared for installing WSL.
  • Second, we installed Ruby.
  • In RubyMine, we configured the remote interpreter via WSL.
  • We ran and debugged our script.
Last modified: 4 April 2018

See Also