A high performance implementation of the Ruby programming language, built on GraalVM.
TruffleRuby is a high-performance implementation of the Ruby programming language.
TruffleRuby aims to be fully compatible with the standard implementation of Ruby, MRI.
The Ruby language component can be added to GraalVM using the gu
utility.
More information is available on the website: http://www.graalvm.org/ruby/
New features:
darwin-aarch64
(Apple Silicon) (#2181, @lewurm, @chrisseaton, @eregon).Bug fixes:
rb_id2name
to ensure the native string will have the same lifetime as the id (#2630, @aardvark179).MatchData#[]
exception when passing a length argument larger than the number of match values (#2636, @nirvdrum).MatchData#[]
exception when supplying a large negative index along with a length argument (@nirvdrum).Hash
(#2635, @eregon).String#[Regexp, Integer]
when the capture group exists but is not matched (@eregon).File.open
mode string parsing when binary option is the third character (@bjfish).rb_scan_args_kw
macro to avoid shadowing variables (#2649, @aardvark179).String#unpack("Z")
to not advance after the null byte, like CRuby (#2659, @aardvark179).Float#round
to avoid losing precision during the rounding process (@aardvark179).String#insert
to not call a subclassed string method (@bjfish).rb_obj_call_init
to pass any block argument to the initialize
method (#2675, @aardvark179)./#{...}/o
to evaluate only once per context when splitting happens (@eregon).Kernel#sprintf
formatting of floats to be like CRuby (@aardvark179).Process.egid=
to accept String
s (#2615, @ngtban)Compatibility:
Marshal.dump
to raise an error when an object has singleton methods (@bjfish).Exception#full_message
now defaults the order to :top
like CRuby 3+ (@eregon).Process.wait2
to return nil
when the WNOHANG
flag is given and the child process is still running (@bjfish).nokogiri
C extension patches when system libraries are not being used (#2693, @aardvark179).rb_gc_mark_maybe
and rb_global_variable
to ensure VALUE
stay live in C extensions (@aardvark179).rb_imemo_tmpbuf
allocation for ripper
(@aardvark179).inherit
argument for Module#class_variables
(#2653, @bjfish).Float#/
when dividing by Rational
(@bjfish).Process.euid=
should accept String (#2615, @ngtban).instance_variable_get
and instance_variable_set
for immutable objects (@bjfish).Thread#raise(exc, message)
now calls exc.exception
in the target thread like CRuby (@eregon).Process::{CLOCK_BOOTTIME,CLOCK_BOOTTIME_ALARM,CLOCK_REALTIME_ALARM}
(#1480, @eregon).:chomp
keyword argument in IO
and StringIO
methods (#2650, @andrykonchin).$PAGER
for --help
and --help*
, similar to CRuby (#2542, @Strech).IO
instances should have T_FILE
as their rb_type()
, not only File
instances (#2662, @eregon).rb_fd_select
retry on EINTR
(#1584, @aardvark179).Performance:
Float#to_s
for better performance (#1584, @aardvark179).RSTRING_PTR
for interned strings (@aardvark179).rb_scan_args_kw
(@aardvark179).Changes:
-Werror=implicit-function-declaration
is now used for compiling C extensions to fail more clearly and earlier if a function is missing, like CRuby 3.2 (#2618, @eregon).TruffleRuby is a high-performance implementation of the Ruby programming language.
TruffleRuby aims to be fully compatible with the standard implementation of Ruby, MRI.
The Ruby language component can be added to GraalVM using the gu
utility.
More information is available on the website: http://www.graalvm.org/ruby/
New features:
Exception
(@eregon).rescue Polyglot::ForeignException
or rescue foreign_meta_object
(#2544, @eregon).Bug fixes:
rb_proc_new
to return a proc that will pass all required arguments to C (#2556, @aardvark179).String#split
to return empty array when splitting all whitespace on whitespace (#2565, @bjfish).RangeError
for Time.at(bignum)
(#2580, @eregon).Integer#{<<,>>}
with RHS bignum and long (@eregon).SIGINT
/Interrupt
/Ctrl+C
now shows the backtrace and exits as signaled, like CRuby (@eregon).Hash#{to_s,inspect}
for keys whose #inspect
return a frozen String (#2613, @eregon).Array#pack
with x*
to not output null characters (#2614, @bjfish).Random#rand
not returning random floats when given float ranges (#2612, @bjfish).Array#sample
for []
when called without n
and a Random
is given (#2612, @bjfish).Module#const_get
to raise a NameError
when nested modules do not exist (#2610, @bjfish).VALUE
s returned from C are unwrapped before the objects can be collected (@aardvark179).Enumerator::Lazy#with_index
to start with new index for multiple enumerations (@bjfish).rb_id2name
to ensure the native string will have the same lifetime as the id (#2630, @aardvark179).MatchData#[]
exception when passing a length argument larger than the number of match values (#2636, @nirvdrum).MatchData#[]
exception when supplying a large negative index along with a length argument (@nirvdrum).Integer#fdiv
and Rational#to_f
for large Integer
values (#2631, @bjfish).Compatibility:
ruby_native_thread_p
for compatibility (#2556, @aardvark179).rb_argv0
for the tk
gem. (#2556, @aardvark179).Array#pack
(#2503, #2504, @aardvark179).Pathname#{empty?, glob}
(#2559, @bjfish)Rational('')
to raise error like MRI (#2566, @aardvark179).Range
but not subclasses, like CRuby (#2570, @MattAlp).#to_a
for converting list
in rescue *list
(#2572, @eregon).digest
so that TruffleRuby implementation is not overridden (@bjfish).*/
directory glob patterns. (#2589, @aardvark179).@gem_prelude_index
variable on the default load paths (#2586 , @bjfish)IO#flush
dynamically from IO#close
(#2594, @gogainda).rb_str_new_static
for C extensions that use it (@aardvark179).ArrayEachIteratorNode
and re-introduced each
specs for MRI parity when mutating arrays whilst iterating, rather than crashing (#2587, @MattAlp)String#rindex
to only accept Regexp
or objects convertable to String
as the first parameter (#2608, @bjfish).String#<<
to require one argument (#2609, @bjfish).String#split
to raise TypeError
when false is given (#2606, @bjfish).String#lstrip!
to remove leading null characters (#2607, @bjfish).File.utime
to return the number of file names in the arguments (#2616, @bjfish).Dir.foreach
to accept an encoding
parameter (#2627, @bjfish).IO.readlines
to ignore negative limit parameters (#2625 , @bjfish).Math.sqrt
to raise a Math::DomainError
for negative numbers (#2621, @bjfish).Enumerable#inject
to raise an ArgumentError
if no block or symbol are given (#2626, @bjfish).Marshal.dump
to raise an error when an object has singleton methods (@bjfish).Performance:
Arrays.mismatch()
in string comparison for better performance (@aardvark179).Dir[]
by sorting entries as they are found and grouping syscalls (#2092, @aardvark179).VALUE
s created during C extension init separately (@aardvark179).ArrayEachIteratorNode
to optimize performance for a constant-sized array and reduce specializations to 1 general case (#2587, @MattAlp)VALUE
s to native handle during common operations in C extensions (@aardvark179).Regexp#match?
) by avoiding match data allocation in TRegex (#2588, @nirvdrum).RDATA_PTR
(@aardvark179).Changes:
RuntimeError
but instead remain as foreign exceptions, see the documentation for how to rescue them (@eregon).TruffleRuby is a high-performance implementation of the Ruby programming language.
TruffleRuby aims to be fully compatible with the standard implementation of Ruby, MRI.
The Ruby language component can be added to GraalVM using the gu
utility.
More information is available on the website: http://www.graalvm.org/ruby/
New features:
Bug fixes:
Compatibility:
Performance:
Changes:
TruffleRuby is a high-performance implementation of the Ruby programming language. TruffleRuby aims to be fully compatible with the standard implementation of Ruby 2.7.3, MRI.
The Ruby support is not available in GraalVM by default and should be installed: gu install ruby
.
More information is available on the website: http://www.graalvm.org/ruby/
New features:
Polyglot.languages
to expose the list of available languages.Polyglot::InnerContext
to eval code in any available language in an inner isolated context (#2169, @eregon).ForeignArray
and are better integrated with Ruby objects (#2149, @eregon and @rbotafogo).Enumerable
and many methods of Array
(#2149, @eregon and @rbotafogo).Enumerable
and many methods of Hash
(#2149).InteropLibrary#hasIterator
) now have all methods of Ruby Enumerable
(#2149).#instance_variables
(readable non-invocable members) and #methods
(invocable members + Ruby methods).Bug fixes:
Marshal.load
of multiple Symbols
with an explicit encoding (#1624).rb_str_modify_expand
to preserve existing bytes (#2392, @bjfish).String#scrub
when replacement is frozen (#2398, @LillianZ).Dir.mkdir
error handling for Pathname
paths (#2397).BasicSocket#*_nonblock(exception: false)
now only return :wait_readable/:wait_writable
for EAGAIN
/EWOULDBLOCK
like MRI (#2400).strspn
used in the date
C extension compiled as a macro on older glibc and then missing the __strspn_c1
symbol on newer glibc (#2406).break
, next
and redo
in define_method(name, &block)
methods (#2418).Float#<=>
(#2432, @chrisseaton).Dir.glob
(#2425).base64
decoding issue with missing output (#2435).StringIO#ungetbyte
to treat a byte as a byte, not a code point (#2436, @aardvark179).defined?(yield)
when used inside a block (#2446).Compatibility:
Process::Status.wait
(#2378).rb_str_modify
and rb_str_modify_expand
to raise a FrozenError
when given a frozen string (#2392).rb_fiber_*
functions (#2402).rb_str_vcatf
.rb_str_catf
.PATH
for subprocesses (#2419).StringScanner#scan
and StringScanner#check
(#2423).Performance:
MonitorMixin
to primitives to deal with interrupts more efficiently (#2375).rb_enc_from_index
by adding cached lookups (#2379, @nirvdrum).MatchData
operations (#2384, @nirvdrum).String#gsub
performance by adding a fast path for the string_byte_index
primitive (#2380, @nirvdrum).String#index
performance by adding a fast path for the string_character_index
primitive (#2383, @LillianZ).ContextThreadLocal
to speedup access to thread-local data.rb_backref*
and rb_lastline*
functions from C extensions.Changes:
foreign_object.class
on foreign objects is no longer special and uses Kernel#class
(it used to return the java.lang.Class
object for a Java type or getMetaObject()
, but that is too incompatible with Ruby code).Java.import name
imports a Java class in the enclosing module instead of always as a top-level constant.foreign_object.keys
no longer returns members, use foreign_object.instance_variables
or foreign_object.methods
instead.foreign_object.respond_to?(:class)
is now always true (before it was only for Java classes), since the method is always defined.Security:
TruffleRuby is a high-performance implementation of the Ruby programming language.
TruffleRuby aims to be fully compatible with the standard implementation of Ruby, MRI.
The Ruby language component can be added to GraalVM using the gu
utility.
More information is available on the website: http://www.graalvm.org/ruby/
Bug fixes:
strspn
used in the date
C extension compiled as a macro on older glibc and then missing the __strspn_c1
symbol on newer glibc (#2406).TruffleRuby is a high-performance implementation of the Ruby programming language.
TruffleRuby aims to be fully compatible with the standard implementation of Ruby, MRI.
The Ruby language component can be added to GraalVM using the gu
utility.
More information is available on the website: http://www.graalvm.org/ruby/
New features:
TruffleRuby::ConcurrentMap
data structure for use in concurrent-ruby
(#2339, @wildmaples).Bug fixes:
Truffle::POSIX.select
was being redefined repeatedly (#2332, @eregon).--backtraces-raise
and --backtraces-rescue
options in JVM mode (#2335).File.{atime, mtime, ctime}
to include nanoseconds (#2337).Array#[a, b] = "frozen string literal".freeze
(#2355).rb_funcall()
now releases the C-extension lock (similar to MRI).rb_str_modify_expand
to preserve existing bytes (#2392).Marshal.load
of multiple Symbols
with an explicit encoding (#1624).String#scrub
when replacement is frozen (#2398, @LillianZ).Compatibility:
resolv
stdlib was not updated (resolv
in 2.7.3 has bugs).require 'socket'
now also requires 'io/wait'
like CRuby (#2326).rb_check_type
(#2307).Hash#rehash
to remove duplicate keys after modifications (#2266, @MattAlp)rb_check_type
for typed data, not wrapped untyped structs (#2331, @aardvark179).Module#define_method
based on self
and the default definee (#2334).mandir
value in RbConfig::CONFIG
and RbConfig::MAKEFILE_CONFIG
(#2315, @bjfish).Fiber#raise
(#2338).File.basename
to return new String
instances (#2343).Fiber#raise
after Fiber#transfer
like Ruby 3.0 (#2342).ObjectSpace._id2ref
for Symbols and frozen String literals (#2358).Enumerator::Lazy#filter_map
(#2356).IO#set_encoding_by_bom
(#2372, pawandubey).Enumerator::Lazy#with_index
(#2356).rb_backref_set
.Float#<=>
when comparing Infinity
to other #infinite?
values.date
library as a C extension to improve compatibility (#2344).rb_str_modify
and rb_str_modify_expand
to raise a FrozenError
when given a frozen string (#2392).Performance:
#dig
iterative to make it faster and compile better for calls with 3+ arguments (#2301, @chrisseaton, @jantnovi).Struct#dig
faster in interpreter by avoiding exceptions (#2306, @kirs).String#chr
(#2318, @chrisseaton).IO#read_nonblock
when no data is available to be read.TruffleSafepoint
is now used instead of custom logic, which no longer invalidates JITed code for guest safepoints (e.g., Thread#{backtrace,raise,kill}
, ObjectSpace
, etc)Time#strftime
for common formats (#2361, @wildmaples, @chrisseaton).rb_funcallv*()
by directly unwrapping the C arguments array instead of going through a Ruby Array
(#2089).Changes:
rb_iterate()
(deprecated since 1.9) no longer magically passes the block to rb_funcall()
, use rb_block_call()
instead.Security:
TruffleRuby is a high-performance implementation of the Ruby programming language. TruffleRuby aims to be fully compatible with the standard implementation of Ruby, MRI. The Ruby language support can be added to GraalVM using the gu utility. More information is available on the GraalVM website: https://www.graalvm.org/ruby/
New features:
context.getBindings("ruby").putMember("my_var", 42);
(#2030).VALUE
s in C extensions now expose the Ruby object when viewed in the debugger, as long as they have not been converted to native values (@aardvark179).Bug fixes:
Range#to_a
wasn't working for long
ranges (#2198, @tomstuart and @LillianZ).Thread#backtrace_locations
(#2229).Thread.handle_interrupt
to defer non-pure interrupts until the end of the handle_interrupt
block (#2219).--single-threaded
(#2265).Enumerator::Lazy#{chunk_while, slice_before, slice_after, slice_when}
to return instances of Enumerator::Lazy
(#2273, @bjfish).Truffle::Interop.source_location
to return unavailable source sections for modules instead of null (#2257).Thread.handle_interrupt
in MonitorMixin#mon_synchronize
.TruffleRuby.synchronized
to handle guest safepoints (#2277).Kernel#raise
argument handling for hashes (#2298).rb_protect
captures a Ruby exception (#2245).Hash
(#2302).Compatibility:
PATH
when installing gems (#1974, #1088, #1343, #1400, #1947, #1931, #1588).nokogiri
gem now defaults to use the vendored libxml2
and libxslt
, similar to CRuby, which means the corresponding system packages are no longer needed (#62).$LOAD_PATH.resolve_feature_path
.Pathname#/
alias to Pathname#+
(#2178).Integer
s in Math.log
(#2184).Regexp.last_match
to support Symbol
and String
parameter (#2179)._1
etc).String#upto
issue with non-ascii strings (#2183).File.extname
return '.'
if the path ends with one (#2192, @tomstuart).Time#inspect
output (#2194, @tomstuart).Integer#[Range]
and Integer#[start, length]
(#2182, @gogainda).self
as an explicit receiver (#2196, @wildmaples).:perm
parameter for File.write
.Time#floor
and #ceil
(#2201, @wildmaples).Range#include?
and #member?
with Time
(#2202, @wildmaples).Comparable#clamp(Range)
(#2200, @wildmaples).Array#minmax
to override Enumerable#minmax
(#2199, @wildmaples).chomp
parameter for IO.{readlines, foreach}
(#2205).Range#{new, bsearch, count, each, equal_value, first, inspect, max, min, size, cover?, include?, ===}
.Array#{[], []=, slice, slice!, to_a, fill, values_at}
(#2155, @LillianZ).String#{byteslice, slice, slice!}
and Symbol#slice
(#2211, @LillianZ).Kernel#{caller, caller_locations}
and Thread#backtrace_locations
(#2211, @LillianZ).String#dump
's formatting of escaped unicode characters (#2217, @meganniu).irb
.String
for BasicSocket#send
(#2209, @HoneyryderChuck).UDPSocket#recvfrom_nonblock
(#2209, @HoneyryderChuck).Integer#digits
implementation to handle more bases (#2224, #2225).inherit
parameter for Module#{private, protected, public}_method_defined?
.Thread.pending_interrupt?
and Thread#pending_interrupt?
(#2219).rb_lastline_set
(#2170).Module#const_source_location
(#2212, @tomstuart and @wildmaples).File.exist?
in Dir.glob
as File.exist?
is often mocked (#2236, @gogainda).Module#const_defined?
and Module#const_get
(#2240).Object#method
and Module#instance_method
(#2004, @ssnickolay).rb_scan_args_kw
in C API (#2244, @LillianZ).RbConfig::CONFIG['LIBPATHFLAG'/'RPATHFLAG']
like MRI to let $LIBPATH
changes in extconf.rb
work.rb_io_t
from C has been changed to improve compatibility for io-console.Time.at
in:
parameter.Kernel#raise
cause
parameter.Signal.trap
and Kernel#trap
(#2287, @chrisseaton).GC.stat(:total_allocated_objects)
as 0
(#2292, @chrisseaton).ObjectSpace::WeakMap
now supports immediate and frozen values as both keys and values (#2267).divmod
when coercion to Float
fails for #sleep
(#2289, @LillianZ).Performance:
irb
1.3.3 and reline
0.2.3 (#2233).Changes:
Truffle::System.synchronized
has been removed.Java.synchronized
has been removed, it did not work on host objects.TruffleRuby is a high-performance implementation of the Ruby programming language. TruffleRuby aims to be fully compatible with the standard implementation of Ruby, MRI. The Ruby language support can be added to GraalVM using the gu utility. More information is available on the GraalVM website: http://www.graalvm.org/ruby/
No changes in Ruby, see https://www.graalvm.org/release-notes/21_0/#21002
TruffleRuby is a high-performance implementation of the Ruby programming language. TruffleRuby aims to be fully compatible with the standard implementation of Ruby, MRI. The Ruby language support can be added to GraalVM using the gu utility. More information is available on the GraalVM website: http://www.graalvm.org/ruby/
Release notes:
io/console
implementation which will be addressed in the next release. A workaround is to use irb --readline
, which disables some IRB features but is much faster for copy/pasting code.New features:
Bug fixes:
Kernel#respond_to?
(#2132, @ssnickolay)Enumerable#count
and Enumerable#uniq
with multiple yielded arguments (#2145, @LillianZ).String#unpack
for w*
format (#2143, @bjfish).Kernel#`
when invalid UTF-8 given (#2118).Method#to_proc
and special variable storage (#2156).offset
parameter for FFI::Pointer#put_array_of_*
(#1525).Struct
s having the same hash values (#2214).Compatibility:
String#undump
(#2131, @kustosz)Errno
constants with the same errno
number are now the same class.Enumerable#tally
and Enumerable#filter_map
(#2144 and #2152, @LillianZ).Range#minmax
.Enumerator::Lazy#uniq
and Enumerator::Lazy#chunk
specs (#2146, @LillianZ).Enumerator#produce
(#2160, @zverok)Complex#<=>
(#2004, @ssnickolay).proc
without block (#2004, @ssnickolay).FrozenError#receiver
.Proc#<<
and Proc#>>
raises TypeError if passed not callable object (#2004, @ssnickolay).Time
(#2166).Dir.{glob,[]}
to raise ArgumentError
for nul-separated strings.Kernel#lambda
with no block in a method called with a block raises an exception (#2004, @ssnickolay).BigDecimal
as C extension to improve compatibility.rb_make_exception
.**kwargs
now accept non-Symbol keys like Ruby 2.7.Enumerator::Yielder#to_proc
.Enumerator::Lazy#eager
.Method#inspect
to include paremeter information.Module#name
to return the same frozen string.Performance:
MatchData#length
(#2147, @LillianZ).Array#sample
(#2148, @LillianZ).String#inspect
is now more efficient.Changes:
InteropLibrary
messages are now exposed consistently as methods on Truffle::Interop
(#2139). Some methods were renamed to match the scheme described in the documentation.TruffleRuby is a high-performance implementation of the Ruby programming language. TruffleRuby aims to be fully compatible with the standard implementation of Ruby, MRI. The Ruby language support can be added to GraalVM using the gu utility. More information is available on the GraalVM website: http://www.graalvm.org/docs/reference-manual/ruby/
Bug fixes:
Enumerable#first
with multiple yielded arguments (#2056, @LillianZ).Kernel#freeze
not freezing singleton class (#2093).String#encode
with options issue (#2091, #2095, @LillianZ)spawn
when :close
redirect is used (#2097).coverage
issue when *eval
is used (#2078).super()
(#2111).SystemStackError
sometimes replaced by an internal Java NoClassDefFoundError
on JVM (#1743).--jvm
as an application argument (#2108).rb_rescue2
to ignore the end marker (VALUE)0
(#2127, #2130).String#{chomp, chomp!}
issue with invalid encoded strings (#2133).Compatibility:
at_exit
handlers even if parsing the main script fails (#2047).-r
) before parsing the main script (#2047).String#split
supports block (#2052, @ssnickolay)String#{grapheme_clusters, each_grapheme_cluster}
.#method_added
(#2059).Float#round
when self
is -0.0
.String#unpack
issue with m0
format (#2065).File.absolute_path
returning a path to current directory (#2062).Range#cover?
to handle Range
parameter.String#{casecmp, casecmp?}
parameter conversion.Regexp
issue which raised syntax error instead of RegexpError
(#2066).Object#autoload
when autoload itself (#1616, @ssnickolay)rb_ivar_count
.rb_yield_values2
.Digest::Base#{update, <<}
(#2100).super
specs (#2104, @chrisseaton).Proc
(#2098, @ssnickolay)FFI::Pointer
accesses when the size of the memory behind is known.#to_s
called by string interpolation (#2110, @ssnickolay)File#path
now returns a new mutable String on every call like MRI (#2115).Warning#warn
and calling Kernel#warn
(#2109).#to_path
in $LOAD_PATH
(#2119).rb_thread_call_without_gvl()
(#2090).Performance:
Symbol#to_proc
is now AST-inlined in order to not rely on splitting and to avoid needing the caller frame to find refinements which apply.Symbol#to_proc
is now globally cached per Symbol and refinements, to avoid creating many redundant CallTargets
.$~
and $_
has been refactored to require less splitting (@aardvark179).Changes:
readline
standard library.