Latest in branch 3.1
3.1.7
Released 26 Mar 2025
(1 year ago)
SoftwareRuby
Version3.1
Status
End of life
Initial release3.1.0
25 Dec 2021
(4 years ago)
Latest release3.1.7
26 Mar 2025
(1 year ago)
End of bug fixes01 Apr 2024
(Ended 2 years, 2 months ago)
End of life31 Mar 2025
(Ended 1 year, 2 months ago)
Release notes https://ruby-lang.org/en/news/2025/03/26/ruby-3-1-7-released/
Source codehttps://github.com/ruby/ruby/tree/v3_1_7
Documentationhttps://ruby-doc.org
Downloadhttps://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.7.tar.gz
Ruby 3.1 ReleasesView full list

What Is New in Ruby 3.1

Category Key Changes
Language Features Anonymous block forwarding, Pin operator in pattern matching
Core Classes New File.symlink method, String#unpack updates, Time improvements
Performance YJIT: New experimental in-process JIT compiler
Tooling & Debugging IRB autocomplete and visual indentation, Error highlight improvements
Standard Libraries New Net::Protocol::BufferedIO class, RubyGems and bundler updates

What are the new language features in Ruby 3.1?

Ruby 3.1 introduces anonymous block forwarding, simplifying the delegation of blocks. You can now use a leading &; argument to forward an anonymous block, which cleans up repetitive code in DSLs and wrappers.

The pin operator in pattern matching now supports expressions. This lets you match against the value of a variable or a constant, not just literals, making pattern matching more dynamic and powerful.

def logged_execution(&;)
  log_start
  result = yield
  log_end(result)
  result
end

How has performance improved with YJIT?

YJIT is a new, experimental in-process JIT compiler that can provide significant performance boosts for many workloads. It's designed to be memory-efficient and is supported on x86-64 and arm64/aarch64 CPUs on Unix platforms.

In practice, you'll see the biggest gains on Rails applications and other production workloads. You can enable it with the --yjit command-line flag to test its impact on your specific application.

What core class updates should developers know about?

The File.symlink method was added, providing a direct way to create symbolic links. The String#unpack and String#unpack1 methods now handle the offset keyword argument, offering more control over binary data parsing.

Time parsing became more strict to avoid confusion between local time and UTC. This change prevents subtle bugs that could occur when a time string contains an ambiguous time zone indicator.

# Creating a symlink
File.symlink('target.txt', 'link.txt')

How has the debugging experience been enhanced?

IRB, Ruby's interactive shell, received major quality-of-life improvements. It now features enhanced autocompletion and visual indentation guides, making it much easier to write and debug multi-line code directly in the console.

Error highlighting in the error_highlight gem became the default. It now points more precisely to the exact method argument that caused a NoMatchingPatternError or NoMatchingPatternKeyError, speeding up debugging.

What changes were made to standard libraries?

A new class, Net::Protocol::BufferedIO, was extracted from Net::HTTP for internal use. The RubyGems and bundler were updated to their latest versions, which include various dependency resolution and security improvements.

Several less-used standard libraries like dbm, gdbm, and tracer are now bundled as default gems. This means they are still included but are now versioned and updated independently of the main Ruby release.

FAQ

Is YJIT ready for production use?
YJIT is still marked as experimental. While it shows impressive performance gains on many applications, you should benchmark your specific workload with it enabled before deploying it to critical production environments.

What does anonymous block forwarding actually do?
It allows you to pass along a block to another method without explicitly naming it. This eliminates the need for the old &block syntax and subsequent block.call pattern in many delegation scenarios, making code cleaner.

Do I need to change my code for the new Time parsing strictness?
You might if your code relies on parsing time strings with ambiguous zone formats. The change was made to prevent silent errors, so it's a good practice to ensure your time strings are explicitly formatted to avoid any unexpected behavior.

How do I enable the new IRB features?
The new autocomplete and indentation features are enabled by default in IRB for Ruby 3.1. Just run irb and you'll see the improved interface immediately.

What happened to the debugger?
The legacy debugger (lib/debug.rb) was removed from the standard library. The community is focused on improving the debug.gem, which is the modern, feature-rich alternative that you should use for debugging.

Releases In Branch 3.1

VersionRelease date
3.1.726 Mar 2025
(1 year ago)
3.1.629 May 2024
(2 years ago)
3.1.523 Apr 2024
(2 years ago)
3.1.430 Mar 2023
(3 years ago)
3.1.324 Nov 2022
(3 years ago)
3.1.212 Apr 2022
(4 years ago)
3.1.118 Feb 2022
(4 years ago)
3.1.025 Dec 2021
(4 years ago)
3.1.0-preview109 Nov 2021
(4 years ago)