Skip to content

Releases: ruby/ruby

4.1.0-preview1

4.1.0-preview1 Pre-release
Pre-release

Choose a tag to compare

@matzbot matzbot released this 12 Oct 09:21
2d08b5f

NEWS for Ruby 4.1.0-preview1

This document is a list of user-visible feature changes
since the 4.0.0 release, except for bug fixes.

Note that each entry is kept to a minimum, see links for details.

Language changes

  • super in a module method that was called via super from a refinement
    method now works correctly.
    [[Feature #22309]]

  • Module#clone and Module#dup no longer rewrite the lexical scope of
    copied methods. Constants and class variables resolve through the
    original class, consistent with inheritance and mixins.
    [[Feature #21981]]

  • alias and Module#alias_method in a module emit a deprecation warning
    when the original method is not a method of the module or its ancestors
    and is only found through the fallback to Object. The fallback will be
    removed in Ruby 4.3, and such an alias will raise a NameError.
    [[Bug #22276]]

  • alias and Module#alias_method emit a deprecation warning when the
    original method is defined in a prepended module. This behavior will
    be removed in Ruby 4.3, and alias lookup will start at the origin
    class (after prepended modules).
    [[Bug #22273]]

Core classes updates

Note: We're only listing outstanding class updates.

  • C API

    • RB_NOGVL_PENDING_INTR_FAIL is added as a flag for rb_nogvl.
      rb_nogvl does not enter the blocking region (and does not call the
      given function), returning 0, if the current thread has pending
      interrupts, including interrupts masked by Thread.handle_interrupt.
      As with the existing skip path, errno is 0 because the function was
      never called.
    • RHASH_TBL is deprecated. [[Feature #22232]]
  • Array

    • Array#pack accepts new formats R and r for unsigned and signed
      LEB128 encoded integers. [[Feature #21785]]
    • Array#pack accepts new formats x! and @! to align the current
      offset to a byte boundary or to the ABI alignment of another
      directive. [[Feature #22185]]
  • Dir

    • Dir.glob supports ***/ for recursive matching that follows
      directory symbolic links, stopping at links to ancestor directories.
      [[Feature #17548]]
  • ENV

    • ENV.fetch_values is added. It returns an array of values for the
      given names, raising KeyError for missing names unless a block is
      given. [[Feature #21781]]
  • Fiber::Scheduler

    • The fiber_interrupt hook is now required. Schedulers which do not
      implement it can no longer be installed with Fiber.set_scheduler.
  • GC

    • GC.stat accepts scope: :ractor (the default), scope: :local
      (a synonym for :ractor), and scope: :global.
      With the default collector, the global scope reports cumulative collection
      counts and measured marking/sweeping CPU time across Ractors, including
      history from destroyed object spaces, without requesting a stop-the-world
      snapshot. Unscoped GC.stat, GC.count, and GC.total_time retain their
      current-Ractor behavior.
    • GC.stat reports a new key, :global_gc_count: the number of
      stop-the-world global garbage collection cycles the current Ractor
      initiated. Each global collection is attributed to exactly one Ractor,
      so the values sum across Ractors. GC.stat(:global_gc_count, scope: :global) reports the process total, including the counts of
      terminated Ractors.
    • A global garbage collection is not counted in :major_gc_count.
      :count equals :minor_gc_count plus :major_gc_count plus
      :global_gc_count in both scopes. When another Ractor's object space
      exists, including one left by a terminated Ractor that is not yet
      absorbed, or one was absorbed since the last global collection,
      GC.start runs a global collection by default, so it increments
      :global_gc_count rather than :major_gc_count; pass global: false
      for a local major collection.
    • Global compaction no longer counts overlapping CPU intervals in scalar GC
      timing statistics. Profiler wall-time intervals are unchanged.
  • Hash

    • Hash.ruby2_keywords_hash? and Hash.ruby2_keywords_hash are
      deprecated and will be removed in Ruby 4.5. [[Feature #22205]]
  • Integer

    • Integer#bit_count is added. It returns the number of 1 bits in the
      binary representation of a non-negative integer (its population count).
      [[Feature #20163]]
  • IO::Buffer

    • read, write, pread, and pwrite now perform one IO operation using
      (offset, length), where length is the maximum transfer size. Short
      transfers are returned directly.

    • The corresponding fiber scheduler hooks are no longer experimental and
      now use the same (offset, length) argument order and single-operation
      semantics.

  • Kernel

    • Kernel#autoload_relative and Module#autoload_relative are added.
      These methods work like autoload, but resolve the file path relative
      to the file where the method is called, similar to require_relative.
      This makes it easier to autoload constants from files in the same
      directory without hardcoding absolute paths or manipulating $LOAD_PATH.
      [[Feature #15330]]
  • MatchData

    • MatchData#integer_at is added. It converts the matched substring to
      integer and return the result. [[Feature #21932]]
  • Module

    • Module#descendants is added. It returns an array of classes and
      modules that have the receiver in their ancestors. [[Feature #9779]]
    • Module#ruby2_keywords and top-level ruby2_keywords are
      deprecated and will be removed in Ruby 4.4. [[Feature #22205]]
    • Module#method_defined? now accepts a third optional argument to also
      match private methods. [[Feature #22297]]
  • ObjectSpace

    • ObjectSpace._id2ref was removed. [[Feature #22135]]
  • Proc

    • Proc#refined is added. It returns a new Proc that behaves like the
      receiver but with the refinements activated by the given modules
      in effect inside its body, without affecting the original Proc.
      [[Feature #22097]]
    • Proc#ruby2_keywords is deprecated and will be removed in Ruby 4.4.
      [[Feature #22205]]
  • Range

    • Range#clamp is added. It returns a new Range instance whose
      begin and end values are clamped to the given bounds. [[Feature #22175]]
  • Regexp

    • All instances of Regexp are now frozen, not just literals.
      Subclasses of Regexp are not frozen for compatibility.
      [[Feature #8948]]
  • Set

    • A deprecated behavior, Set#to_set, Range#to_set, and
      Enumerable#to_set accepting arguments, was removed. [[Feature #21390]]
  • String

    • String#unpack and String#unpack1 accept new formats R and r
      for unsigned and signed LEB128 encoded integers. [[Feature #21785]]
    • String#unpack and String#unpack1 accept a new format ^ that
      returns the current offset. Useful when combined with variable
      width formats like LEB128. [[Feature #21796]]
    • String#unpack and String#unpack1 accept new formats x! and
      @! to align the current offset to a byte boundary or to the ABI
      alignment of another directive. [[Feature #22185]]
    • Basic bit operations are added. String#bit_get, String#bit_set?,
      String#bit_set, String#bit_clear, String#bit_flip and
      String#bit_count handle individual bits, and String#bitwise_not,
      String#bitwise_and, String#bitwise_or, String#bitwise_xor
      (with their ! variants) handle whole strings. [[Feature #22118]]
    • String#tr now accept a Hash for multi-character replacement.
      [[Feature #22238]]
  • Symbol

    • Symbol#to_s now returns a frozen string. [[Feature #22137]]
  • Thread

    • Assigning nil with Thread#thread_variable_set now deletes the
      thread-local variable. [[Feature #19333]]
  • Thread::Backtrace::Location

    • Thread::Backtrace::Location#source_range is added. It returns a
      Ruby::SourceRange for the Ruby expression associated with the frame.

Stdlib updates

  • Psych

    • An experimental libfyaml backend has been added. It is only
      enabled when psych is built with --enable-libfyaml, and the
      default libyaml backend remains unchanged otherwise. It is not
      supported on Windows. [[GH-psych #805]]
  • Ruby::Prism

    • Ruby::Prism is added. It is the prism parser built into the
      interpreter, i.e., the very parser that parsed the running program,
      independent of the prism gem. It is autoloaded.
      Method#syntax_tree and others return its nodes. Its API may change
      between Ruby minor versions; use the prism gem unless you need the
      parser of the running interpreter. [[Bug #22379]]

The following bundled gems are added.

We only list stdlib changes that are notable feature changes.

Other changes are listed in the following sections. We also listed release
history from the previous bundled version that is Ruby 3.4.0 if it has GitHub
releases.

The following bundled gems are promoted from default gems.

  • prism 1.9.0
  • tsort 0.2.0
  • win32-registry 0.1.2

The following bundled gems are removed.

  • net-ftp 0.3.9
  • net-pop 0.1.2

They are still available on rubygems.org and can be installed with
gem install. [[Feature #21835]]

The following default gem is added.

The following default gems are updated.

  • RubyGems 4.1.0.beta2
    • 4.0.3 to [v4.0.4][RubyGems-v4.0.4], [v4.0.5][RubyGems-v4.0.5], [v4.0.6][RubyGems-v4.0.6], [v4.0.7][RubyGems-v4.0.7], [v4.0.8][RubyGems-v4.0.8], [v4.0.9][RubyGems-v4.0.9], [v4.0.10][RubyGems-v4.0.10], [v4.0.11][RubyGems-v4.0.11], [v4.0.12][RubyGems-v4.0.12], [v4.0.13][...
Read more

3.4.11

Choose a tag to compare

@matzbot matzbot released this 23 Sep 06:13

What's Changed

Note: This list is automatically generated by tool/gen-github-release.rb. Because of this, some commits may be missing.

Full Changelog

v3_4_10...v3_4_11

4.0.7

Choose a tag to compare

@matzbot matzbot released this 15 Sep 00:40

What's Changed

Note: This list is automatically generated by tool/gen-github-release.rb. Because of this, some commits may be missing.

Full Changelog

v4.0.6...v4.0.7

3.3.12

Choose a tag to compare

@matzbot matzbot released this 16 Jul 05:13
0581089

What's Changed

This release includes the following security fixes.

This release updates the default gem erb to 4.0.3.1 and the bundled gem net-imap to 0.4.25. The net-imap update fixes CVE-2026-42245, CVE-2026-42246, CVE-2026-42256, CVE-2026-42257, CVE-2026-42258, CVE-2026-47240, CVE-2026-47241 and CVE-2026-47242. Please see the release notes of net-imap v0.4.24 and net-imap v0.4.25 for the details of these fixes.

Full Changelog

v3_3_11...v3_3_12

4.0.6

Choose a tag to compare

@matzbot matzbot released this 14 Jul 01:46

What's Changed

Note: This list is automatically generated by tool/gen-github-release.rb. Because of this, some commits may be missing.

Full Changelog

v4.0.5...v4.0.6

3.4.10

Choose a tag to compare

@matzbot matzbot released this 30 Jun 11:27

What's Changed

Note: This list is automatically generated by tool/gen-github-release.rb. Because of this, some commits may be missing.

Full Changelog

v3_4_9...v3_4_10

4.0.5

Choose a tag to compare

@matzbot matzbot released this 20 May 00:29

What's Changed

Note: This list is automatically generated by tool/gen-github-release.rb. Because of this, some commits may be missing.

Full Changelog

v4.0.4...v4.0.5

4.0.4

Choose a tag to compare

@matzbot matzbot released this 11 May 21:27

What's Changed

Note: This list is automatically generated by tool/gen-github-release.rb. Because of this, some commits may be missing.

Full Changelog

v4.0.3...v4.0.4

4.0.3

Choose a tag to compare

@matzbot matzbot released this 21 Apr 09:03

3.3.11

Choose a tag to compare

@matzbot matzbot released this 26 Mar 01:18
1f2d151

What's Changed

Note: This list is automatically generated by tool/gen-github-release.rb. Because of this, some commits may be missing.

Full Changelog

v3_3_10...v3_3_11