NEWS - Documentation for Ruby 4.1
Description: NEWS: NEWS for Ruby 4. This document is a list of user-visible feature changes since the **4.
Keywords: ruby,documentation,NEWS

🔍

No recent searches

# 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

## Core classes updates

Note: We’re only listing outstanding class updates.

- `Array`

  - `Array#pack` accepts a new format `R` and `r` for unpacking unsigned and signed LEB128 encoded integers. [Feature #21785]

  - `Array#pack` accepts a new format `^` that returns the current offset. Useful when combined with variable width formats like LEB128. [Feature #21796]

- `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]]

- `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]

- `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]

## Stdlib updates

### 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 default gem is added.

### The following default gems are updated.

- RubyGems 4.1.0.dev

- 4.0.3 to v4.0.4, v4.0.5, v4.0.6, v4.0.7, v4.0.8, v4.0.9, v4.0.10

- bundler 4.1.0.dev

- 4.0.3 to v4.0.4, v4.0.5, v4.0.6, v4.0.7, v4.0.8, v4.0.9, v4.0.10

- erb 6.0.4

- 6.0.1 to v6.0.2, v6.0.3

- ipaddr 1.2.9

- json 2.19.5

- 2.18.0 to v2.18.1, v2.19.0, v2.19.1, v2.19.2, v2.19.3, v2.19.4

- openssl 4.0.1

- 4.0.0 to v4.0.1

- prism 1.9.0

- 1.7.0 to v1.8.0, v1.8.1, v1.9.0

- resolv 0.7.1

- 0.7.0 to v0.7.1

- stringio 3.2.1.dev

- strscan 3.1.9.dev

- 3.1.6 to v3.1.7, v3.1.8

- 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.5

- rake 13.4.2

- 13.3.1 to v13.4.0, v13.4.1, v13.4.2

- test-unit 3.7.7

- 3.7.5 to 3.7.6, 3.7.7

- net-imap 0.6.3

- 0.6.2 to v0.6.3

- rbs 4.0.2

- 3.10.0 to v3.10.1, v3.10.2, v3.10.3, v3.10.4, v4.0.0.dev.5, v4.0.0, v4.0.2

- mutex_m 0.3.0

- bigdecimal 4.1.2

- 4.0.1 to v4.1.0, v4.1.1, v4.1.2

- resolv-replace 0.2.0

- 0.1.1 to v0.2.0

- syslog 0.4.0

- 0.3.0 to v0.4.0

- repl_type_completor 0.1.15

- 0.1.12 to v0.1.13, v0.1.14, v0.1.15

- pstore 0.2.1

- 0.2.0 to v0.2.1

- rdoc 7.2.0

- 7.0.3 to v7.1.0, v7.2.0

- win32ole 1.9.3

- 1.9.2 to v1.9.3

- irb 1.17.0

- 1.16.0 to v1.17.0

### RubyGems and `Bundler`

Ruby 4.0 bundled RubyGems and `Bundler` version 4. see the following links for details.

## Supported platforms

## Compatibility issues

## Stdlib compatibility issues

## C API updates

### Embedded TypedData

- The `RUBY_TYPED_EMBEDDABLE` flag is now public and documented and can be used by C extensions. It allows allocating C structs directly into Ruby object slots, which reduces pointer chasing, and in some case memory usage. See the C extension documentation for details. [Feature #21853]

- Added new C23 inspired allocator functions, that takes the previous memory size. This allow the Ruby `GC` to better keep track of memory usage, improving its heuristics. It also improves the performance of system allocators that support C23 `free_sized`.

However, it is important to note that passing an incorrect size to these function is undefined behavior and may result in crashes or memory leaks.

- `ruby_xfree_sized(void *ptr, size_t size)`

- `ruby_xrealloc_sized(void *ptr, size_t newsiz, size_t oldsiz)`

- `ruby_xrealloc2_sized(void *ptr, size_t newelems, size_t newsiz, size_t oldelems)`

[Feature #21861]

## Implementation improvements

### `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.

## JIT