From Fedora Project Wiki

Ruby 3.1


Ruby 3.1 is the latest stable version of Ruby. Many new features and improvements are included for the increasingly diverse and expanding demands for Ruby. With this major update from Ruby 3.0 in Fedora 35 to Ruby 3.1 in Fedora 36, Fedora becomes the superior Ruby development platform.


Current status

Detailed Description

Ruby 3.1 is upstream's new major release of Ruby. Many new features and improvements are included.

YJIT: New experimental in-process JIT compiler

Ruby 3.1 merges YJIT, a new in-process JIT compiler developed by Shopify.

Since Ruby 2.6 introduced MJIT in 2018, its performance greatly improved, and finally we achieved Ruby3x3 last year. But even though Optcarrot has shown impressive speedups, the JIT hasn’t benefited real world business applications.

Recently Shopify contributed many Ruby improvements to speed up their Rails application. YJIT is an important contribution, and aims to improve the performance of Rails applications.

Though MJIT is a method-based JIT compiler and uses an external C compiler, YJIT uses Basic Block Versioning and includes JIT compiler inside it. With Lazy Basic Block Versioning (LBBV) it first compiles the beginning of a method, and incrementally compiles the rest when the type of arguments and variables are dynamically determined. See YJIT: a basic block versioning JIT compiler for CRuby for a detailed introduction.

With this technology, YJIT achieves both fast warmup time and performance improvements on most real-world software, up to 22% on railsbench, 39% on liquid-render.

YJIT is still an experimental feature, and as such, it is disabled by default. If you want to use this, specify the --yjit command-line option to enable YJIT. It is also limited to macOS & Linux on x86-64 platforms for now.

debug gem: A new debugger

A new debugger debug.gem is bundled. debug.gem is fast debugger implementation and it provides many features like remote debugging, colorful REPL, IDE (VSCode) integration and more. It replaces lib/debug.rb standard library.

error_highlight: Fine-grained error location in backtrace

A built-in gem, error_highlight, has been introduced. It includes fine-grained error location in backtrace:

$ ruby test.rb test.rb:1:in <main>': undefined method time' for 1:Integer (NoMethodError)

1.time {}


Did you mean? times

This gem is enabled by default. You can disable it by using a command-line option --disable-error_highlight. See the repository in detail.

IRB Autocomplete and Documentation Display

The IRB now has an autocomplete feature, where you can just type in the code, and the completion candidates dialog will appear. You can use Tab and Shift+Tab to move up and down.

If documentation is installed when you select a completion candidate, the documentation dialog will appear next to the completion candidates dialog, showing part of the content. You can read the full documentation by pressing Alt+d.

Other Notable New Features

  • Language
    • Values in Hash literals and keyword arguments can be omitted.
    • Pin operator in pattern matching now takes an expression.
    • Parentheses can be omitted in one-line pattern matching.
  • RBS
    • Generic type parameters can be bounded.
    • Generic type aliases are supported.
    • rbs collection has been introduced to manage gems’ RBSs.
    • Many signatures for built-in and standard libraries have been added/updated.
    • It includes many bug fixes and performance improvements too.
  • TypeProf
    • Experimental IDE support has been implemented.
    • Many bug fixes and performance improvements.

Performance improvements

  • MJIT
    • For workloads like Rails, the default --jit-max-cache is changed from 100 to 10000. The JIT compiler no longer skips compilation of methods longer than 1000 instructions.
    • To support Zeitwerk of Rails, JIT-ed code is no longer cancelled when a TracePoint for class events is enabled.

Other notable changes since 3.0

  • One-line pattern matching, e.g., ary => [x, y, z], is no longer experimental.
  • Multiple assignment evaluation order has been changed slightly.
    • foo[0], bar[0] = baz, qux was evaluated in order baz, qux, foo, and then bar in Ruby 3.0. In Ruby 3.1, it is evaluated in order foo, bar, baz, and then qux.
  • Variable Width Allocation: Strings (experimental)
  • Psych 4.0 changes Psych.load to use safe_load by default. You may need to use Psych 3.3.2 for migrating to this behavior.
  • Standard libraries updates


Benefit to Fedora

With a latest release, Ruby language is supporting the newest language features, which enables even faster and easier development of Ruby applications.


  • Other developers:
    • Rebuild of packages with binary extensions (i.e. packages which depends on libruby) will be handled automatically, but some packages might need fixes/updates to support Ruby 3.1 properly.
  • Release engineering: #10478
    • The packages are going to be rebuild in side-tag, but that does not need releng involvement nowadays.
  • Policies and guidelines: N/A (not needed for this Change)
  • Trademark approval: N/A (not needed for this Change)
  • Alignment with Objectives:

Upgrade/compatibility impact

  • User specific Ruby binary extensions need to be rebuild.
  • Ruby packages/application dependencies might need to be adjusted if net-* and other newly bundled gems are used.

How To Test

  • No special hardware is needed.
  • To test, install Ruby 3.1. The test builds are pusblished in PR or on Ruby-SIG ML
  • Try to locally rebuild your packages using Ruby 3.1.
  • Use the packages with your applications previously written in Ruby.
  • If something doesn't work as it should, let us know.

User Experience

The Ruby programs/scripts should behave as they were used to.


$ dnf repoquery --disablerepo=* --enablerepo=rawhide --enablerepo=rawhide-source --arch=src --whatrequires 'ruby-devel' | sort | uniq | wc -l

Contingency Plan

  • Contingency mechanism: We would like to get a special buildroot tag to be able to rebuild necessary the packages with Ruby 3.1. If anything goes wrong, the tag could be easily dropped and previous version of Ruby 3.0 and its dependencies stays intact. The tag would be merged into F36 after everything is rebuild.
  • Contingency deadline: Mass Rebuild
  • Blocks release? No


Release Notes

  • The Ruby 3.1 bumps soname, therefore Ruby packages, which use binary extensions, should be rebuilt. Nevertheless, since upstream paid great attention to source compatibility, no changes to your code are needed.