RubyMine 2026.2 Help

Sorbet

RubyMine can infer many types directly from Ruby code. For example, it recognizes a string literal as String and determines that String#length returns Integer.

When a type cannot be inferred reliably, RubyMine can use Sorbet type signatures. You can declare signatures inline in Ruby code by using sig, or store them separately in .rbi files. RubyMine uses type information from both sources to determine the types of parameters, return values, variables, and expressions.

Add type signatures

  • To declare a signature directly in Ruby code, extend T::Sig and add a sig declaration before the method:

    # typed: true module MyFoo class Bar end class Service extend T::Sig sig { params(foo: MyFoo::Bar).returns(MyFoo::Bar) } def process(foo) foo end end end service = MyFoo::Service.new result = service.process(MyFoo::Bar.new)

    The signature declares that process accepts and returns an object of type MyFoo::Bar. RubyMine can therefore determine the types of foo, the method call, and result.

  • To keep the Ruby implementation free of Sorbet annotations, declare the corresponding types in a separate .rbi file:

    # typed: true module MyFoo class Bar end class Service sig { params(foo: MyFoo::Bar).returns(MyFoo::Bar) } def process(foo); end end end

    An explicit # typed: sigil is required. You do not need to add extend T::Sig to a declaration.

View the type info

  1. Place the caret within the expression whose type you want to inspect. Then select View | Type Info or press Ctrl+Shift+P.

  2. If several expressions are available at the caret position, RubyMine displays an expression chooser. Select the expression for which you want to view type information.

    Choosing an expression

The following example shows type information obtained from a sig declaration written directly in Ruby code:

Viewing type information from an inline Sorbet signature

The following example shows type information obtained from a signature stored separately in an RBI file:

Viewing type information from a separate RBI file

Check that the types match

  • RubyMine warns you when a method argument or return value does not match its Sorbet signature. In the following example, the Greeting#greet method expects an instance of User:

    module InspectionExample class User end class Greeting extend T::Sig sig { params(user: User).void } def greet(user) puts "Hello!" end end end greeting = InspectionExample::Greeting.new greeting.greet("Ruby")

    The call passes a String instead of the required User. RubyMine highlights "Ruby" and reports: Expected type 'User', got 'String' instead.

    You can manage these warnings using the Mismatched argument type and Mismatched return type inspections.

    String argument that does not match the expected User type

Navigate between Ruby and RBI files

RubyMine enables you to navigate from a Ruby declaration to its type signature and from an RBI signature to its associated Ruby declaration.

Go to the type signature

  • Select a Ruby declaration and go to Navigate | Type Signature in the main menu.

    Navigate to an RBI file

Go to the associated Ruby declaration

  • Select a type signature and go to Navigate | Associated Declaration in the main menu.

    Navigate to the associated Ruby declaration
14 August 2026