Repository navigation
Description
This feature checklist is based on the NEWS file from CRuby's master branch. We'll update this list until the release has been finalized.
Pull requests to implement Ruby 4.1 features should be based on the ruby-4.1 branch, not master.
Changes not relevant to JRuby have been removed.
NEWS for Ruby 4.1.0
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
-
Module#cloneandModule#dupno longer rewrite the lexical scope of
copied methods. Constants and class variables resolve through the
original class, consistent with inheritance and mixins.
[Feature #21981] -
aliasandModule#alias_methodin 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 toObject. The fallback will be
removed in Ruby 4.3, and such an alias will raise aNameError.
[Bug #22276] -
aliasandModule#alias_methodemit 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.
-
Array
-
Array#packaccepts new formatsRandrfor unsigned and signed
LEB128 encoded integers. [Feature #21785] -
Array#packaccepts new formatsx!and@!to align the current
offset to a byte boundary or to the ABI alignment of another
directive. [Feature #22185]
-
-
Dir
-
Dir.globsupports***/for recursive matching that follows
directory symbolic links, stopping at links to ancestor directories.
[Feature #17548]
-
-
ENV
-
ENV.fetch_valuesis added. It returns an array of values for the
given names, raisingKeyErrorfor missing names unless a block is
given. [Feature #21781]
-
-
Fiber::Scheduler
- The
fiber_interrupthook is now required. Schedulers which do not
implement it can no longer be installed withFiber.set_scheduler.
- The
-
GC
-
GC.statacceptsscope: :ractor(the default),scope: :local
(a synonym for:ractor), andscope: :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. UnscopedGC.stat,GC.count, andGC.total_timeretain their
current-Ractor behavior.
-
-
Hash
-
Hash.ruby2_keywords_hash?andHash.ruby2_keywords_hashare
deprecated and will be removed in Ruby 4.5. [Feature #22205]
-
-
Integer
-
Integer#bit_countis added. It returns the number of1bits in the
binary representation of a non-negative integer (its population count).
[Feature #20163]
-
-
IO::Buffer
-
[ ]
read,write,pread, andpwritenow perform one IO operation using
(offset, length), wherelengthis 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_relativeandModule#autoload_relativeare added.
These methods work likeautoload, but resolve the file path relative
to the file where the method is called, similar torequire_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_atis added. It converts the matched substring to
integer and return the result. [Feature #21932]
- [ ]
-
Module
-
Module#descendantsis added. It returns an array of classes and
modules that have the receiver in their ancestors. [Feature #9779] -
Module#ruby2_keywordsand top-levelruby2_keywordsare
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._id2refwas removed. [Feature #22135]
-
-
Proc
-
Proc#refinedis added. It returns a newProcthat behaves like the
receiver but with the refinements activated by the given modules
in effect inside its body, without affecting the originalProc.
[Feature #22097] -
Proc#ruby2_keywordsis deprecated and will be removed in Ruby 4.4.
[Feature #22205]
-
-
Range
-
Range#clampis added. It returns a newRangeinstance whose
begin and end values are clamped to the given bounds. [Feature #22175]
-
-
Regexp
- All instances of
Regexpare now frozen, not just literals.
Subclasses ofRegexpare not frozen for compatibility.
[Feature #8948]
- All instances of
-
Set
- A deprecated behavior,
Set#to_set,Range#to_set, and
Enumerable#to_setaccepting arguments, was removed. [Feature #21390]
- A deprecated behavior,
-
String
-
String#unpackandString#unpack1accept new formatsRandr
for unsigned and signed LEB128 encoded integers. [Feature #21785] -
String#unpackandString#unpack1accept a new format^that
returns the current offset. Useful when combined with variable
width formats like LEB128. [Feature #21796] -
String#unpackandString#unpack1accept new formatsx!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_flipand
String#bit_counthandle individual bits, andString#bitwise_not,
String#bitwise_and,String#bitwise_or,String#bitwise_xor
(with their!variants) handle whole strings. [Feature #22118] - [ ]
String#trnow accept a Hash for multi-character replacement.
[Feature #22238]
-
-
Symbol
-
Symbol#to_snow returns a frozen string. [Feature #22137]
-
-
Thread
- [ ]Assigning
nilwithThread#thread_variable_setnow deletes the
thread-local variable. [[Feature #19333]]
- [ ]Assigning
-
Thread::Backtrace::Location
-
Thread::Backtrace::Location#source_rangeis added. It returns a
Ruby::SourceRangefor 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] (JRuby should confirm compatibility with SnakeYAML-Engine)
- An experimental libfyaml backend has been added. It is only
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.
- 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.beta1
- bundler 4.1.0.beta1
- erb 6.1.0
- error_highlight 0.7.2
- io-console 0.9.4
- io-wait 999.999.999
- ipaddr 1.2.9
- 1.2.8 to v1.2.9
- json 3.0.2
- net-protocol 0.4.0
- openssl 4.0.2
- pp 0.6.4
- 0.6.3 to v0.6.4
- prism 1.9.0
- psych 5.5.0
- resolv 0.8.0
- stringio 3.2.1.dev
- strscan 3.1.9.dev
- syntax_suggest 3.0.0
- timeout 0.6.1
- 0.6.0 to v0.6.1
- zlib 3.2.3
- 3.2.2 to v3.2.3
The following bundled gems are updated.
- minitest 6.0.6
- power_assert 3.1.0
- 3.0.1 to v3.1.0
- rake 13.4.2
- test-unit 3.7.8
- rss 0.3.3
- 0.3.2 to 0.3.3
- net-imap 0.6.7
- net-smtp 0.5.2
- 0.5.1 to v0.5.2
- rbs 4.2.0
- 3.10.0 to v3.10.1, v3.10.2, v3.10.3, v3.10.4, v4.0.0.dev.1, v4.0.0.dev.2, v4.0.0.dev.3, v4.0.0.dev.4, v4.0.0.dev.5, v4.0.0, v4.0.1.dev.1, v4.0.1.dev.2, v4.0.1, v4.0.2, v4.0.3, v4.1.0.pre.1, v4.1.0.pre.2, v4.1.0, v4.1.1.pre.1, v4.1.1, v4.1.2, v4.1.3, v4.2.0.pre.1, v4.2.0
- typeprof 0.33.2
- mutex_m 0.3.0
- bigdecimal 4.1.3
- resolv-replace 0.2.0
- 0.1.1 to v0.2.0
- nkf 0.3.0
- 0.2.0 to v0.3.0
- syslog 0.4.0
- 0.3.0 to v0.4.0
- csv 3.3.6
- 3.3.5 to v3.3.6
- repl_type_completor 0.1.16
- pstore 0.2.1
- 0.2.0 to v0.2.1
- rdoc 8.1.0
- win32ole 1.9.3
- 1.9.2 to v1.9.3
- irb 1.18.0
- reline 0.7.0
- 0.6.3 to v0.7.0
RubyGems and Bundler
Ruby 4.0 bundled RubyGems and Bundler version 4. see the following links for details.
Compatibility issues
-
A class or module can now be modified only by the Ractor which created it,
its owner. Defining, removing or undefining methods,alias, changing
visibility,include/prepend,Module#refine, defining or removing
constants, registering anautoload, writing the class's own instance
variables and class variables,Module#freezeand
Module#set_temporary_nameraiseRactor::IsolationErrorin any other
Ractor. Reading is unchanged. Everything defined at boot or by the main
Ractor,required libraries included, is owned by the main Ractor, so a
non-main Ractor can no longer monkey-patch it; and since defining a constant
in a foreign class is prohibited, it can not define a top-level class or
module name either. In exchange a Ractor has full use of the classes it
creates itself, including unshareable constant, instance variable and class
variable values, which not even the main Ractor could do before. See
doc/language/ractor.md. [Feature #22226] -
Kernel#at_exitandEND {}now raiseRactor::IsolationErrorwhen called
in a non-main Ractor. Previously the registered handler ran in the main
Ractor at process exit, which was confusing. [Feature #22139] -
Ractor.make_shareablenow raisesRactor::Errorfor anIOobject, and
Ractor.shareable?returnsfalsefor it. A frozenIOused to be
shareable, but almost all of its methods raiseFrozenErrorand it can
still refer to unshareable objects through the members ofrb_io_t.
Stdlib compatibility issues
-
Etc.getloginon Windows now returns the login name determined when the
process starts, from theUSERorUSERNAMEenvironment variable or
GetUserName(). It used to follow later changes toENV['USER']. -
Socket
-
On Windows, a connection that is refused or unreachable now raises the
matchingErrnoclass as soon as Winsock reports it, instead of
Errno::ETIMEDOUTonce the wholeconnect_timeouthas passed. Code
rescuingErrno::ETIMEDOUTthere has to rescue the real error instead. -
On Windows,
BasicSocket#getsockopt(:SOCKET, :ERROR)now reports an
errno as it does on the other platforms, instead of the raw WinSock
error code. Code comparing it with aWSAE*value has to compare it
with the matchingErrno::*::Errnoinstead.
-
Implementation improvements
- The error_highlight, did_you_mean, and syntax_suggest gems are now
loaded lazily on the first error display instead of at interpreter
boot, which reduces startup time.Process.warmuploads them
eagerly so that pre-forking servers keep their code in
copy-on-write shared memory. [Feature #21951]
Ractor
A lot of work has gone into making Ractors more stable, performant, and usable. These improvements bring Ractor implementation closer to leaving experimental status.
-
The default GC now runs per Ractor: each Ractor collects its own heap
on its own thread without stopping the others, and a stop-the-world
collection only runs when it is really needed (explicit fullGC.start,
shareable-object growth, reclaiming dead Ractors' heaps). Allocation-heavy
Ractor programs now scale like forked processes. -
GC.start(global: false)can be used when multiple Ractors are running to force
a Ractor-local GC. By default,GC.startruns a global GC (all Ractors) like
before. This can also be triggered withGC.start(global: true). Theglobal
keyword argument has no effect when a single Ractor is running.Visible behavior changes:
-
Ractor#valuereturns the value only once; a second call raises
Ractor::Error. - [ ]
GC.disable/GC.enableact as per-Ractor holds on a process-wide
switch: one Ractor'sGC.enableno longer overrides another Ractor's
GC.disable. -
ObjectSpace.each_objectenumerates the calling Ractor's own objects
plus other Ractors' shareable objects (ObjectSpace.dump_allstill
covers everything). -
ObjectSpace.define_finalizeron another Ractor's object raises
Ractor::IsolationError.
-
-
Ractor#monitornow sends an Array naming the Ractor and what happened to
it,[ractor, :exited]or[ractor, :aborted], where it used to send the
bare Symbol:exitedor:aborted. Several Ractors can then report to one
port and the receiver still knows which one finished. The Array is built for
the receiving Ractor, so watching many Ractors leaves no shareable objects
behind.r = Ractor.new { :ok } r.monitor(port = Ractor::Port.new) port.receive #=> [r, :exited]One port can therefore watch a whole group, which is all a supervisor
needs:workers.each { |r| r.monitor port } until workers.empty? r, status = port.receive workers.delete(r) workers << restart(r) if status == :aborted end
Activity
headius commentedon Sep 30, 2026
I believe Proc#refined has been fully implemented by @shugo so I marked that one as completed.
@zev Finally got that checklist up! Happy to have your help here if possible!
Update clone/dup lexical scope tests for Ruby 4.1 (GH #9746)
Add Integer#bit_count
Add MatchData#integer_at