3432 Commits

Author SHA1 Message Date
Jean Boussier
519a4bdbc1 Optimize File.basename
The actual algorithm is largely unchanged, just allowed to use
singlebyte checks for common encodings.

It could certainly be optimized much further, as here again it often
scans from the front of the string when we're interested in the back of
it. But the algorithm as many Windows only corner cases so I'd rather
ship a good improvement now and eventually come back to it later.

Most of improvement here is from the reduced setup cost (avodi double
null checks, avoid duping the argument, etc), and skipping the multi-byte
checks.

```
compare-ruby: ruby 4.1.0dev (2026-01-19T03:51:30Z master 631bf19b37) +PRISM [arm64-darwin25]
built-ruby: ruby 4.1.0dev (2026-01-21T08:21:05Z opt-basename 7eb11745b2) +PRISM [arm64-darwin25]
```

|           |compare-ruby|built-ruby|
|:----------|-----------:|---------:|
|long       |      3.412M|   18.158M|
|           |           -|     5.32x|
|long_name  |      1.981M|    8.580M|
|           |           -|     4.33x|
|withext    |      3.200M|   12.986M|
|           |           -|     4.06x|
2026-01-21 11:23:01 +01:00
Hiroshi SHIBATA
2d79cc9bfc Added example for bundle/inline 2026-01-15 16:16:16 +09:00
Misaki Shioi
080d66beca
Avoid flaky test failures by retrying on local port conflicts (#15818)
This test obtains an available port number by calling `TCPServer.new`,
then closes it and passes the same port number as `local_port` to `TCPSocket.new`.

However, `TCPSocket.new` could occasionally fail with `Errno::EADDRINUSE`
at the bind(2) step.
I believe this happens when tests are run in parallel and another process
on the same host happens to bind the same port in the short window between
closing the `TCPServer` and calling `TCPSocket.new`.

To address this race condition, the test now retries with a newly selected
available port when such a conflict occurs.
2026-01-08 09:41:42 +09:00
Hiroshi SHIBATA
7d49838038 [ruby/rubygems] bin/rubocop -A
https://github.com/ruby/rubygems/commit/e3f418aa11
2026-01-07 08:49:23 +00:00
Takuya Noguchi
3657700c40 [ruby/rubygems] Bundler: validate more options for add sub-command
Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>

https://github.com/ruby/rubygems/commit/6ca2e28680
2026-01-07 08:49:23 +00:00
eileencodes
e1087c1226 [ruby/rubygems] Fix dependency source bug in bundler
I stumbled across a bundler bug that had me scratching my head for
awhile, because I hadn't experienced it before.

In some cases when changing the source in a gemfile from a
`Source::Gemspec` to either a `Source::Path` or `Source::Git` only the
parent gem will have it's gem replaced and updated and the child
components will retain the original version. This only happens if the gem
version of the `Source::Gemspec` and `Source::Git` are the same. It also
requires another gem to share a dependency with the one being updated.

For example if I have the following gemfile:

```
gem "rails", "~> 8.1.1"
gem "propshaft"
```

Rails has a component called `actionpack` which `propshaft` depends on.

If I change `rails` to point at a git source (or path source), only the
path for `rails` gets updated:

```
gem "rails", github: "rails/rails", branch: "8-1-stable"
gem "propshaft"
```

Because `actionpack` is a dependency of `propshaft`, it will remain in
the rubygems source in the lock file WHILE the other gems are correctly
pointing to the git source.

Gemfile.lock:

```
GIT
  remote: https://github.com/rails/rails.git
  revision: https://github.com/ruby/rubygems/commit/9439f463e0ef
  branch: 8-1-stable
  specs:
    actioncable (8.1.1)
      ...
    actionmailbox (8.1.1)
      ...
    actionmailer (8.1.1)
      ...
    actiontext (8.1.1)
      ...
    activejob (8.1.1)
      ...
    activemodel (8.1.1)
      ...
    activerecord (8.1.1)
      ...
    activestorage (8.1.1)
      ...
    rails (8.1.1)
      ...
    railties (8.1.1)
      ...

GEM
  remote: https://rubygems.org/
  specs:
    action_text-trix (2.1.15)
      railties
    actionpack (8.1.1) <===== incorrectly left in Rubygems source
      ...
```

The gemfile will contain `actionpack` in the rubygems source, but will
be missing in the git source so the path will be incorrect. A bundle
show on Rails will point to the correct place:

```
$ bundle show rails
/Users/eileencodes/.gem/ruby/3.4.4/bundler/gems/rails-9439f463e0ef
```

but a bundle show on actionpack will be incorrect:

```
$ bundle show actionpack
/Users/eileencodes/.gem/ruby/3.4.4/gems/actionpack-8.1.1
```

This bug requires the following to reproduce:

1) A gem like Rails that contains components that are released as their
own standalone gem is added to the gemfile pointing to rubygems
2) A second gem is added that depends on one of the gems in the first
gem (like propshaft does on actionpack)
3) The Rails gem is updated to use a git source, pointing to the same
version that is being used by rubygems (ie 8.1.1)
4) `bundle` will only update the path for Rails component gems if no
other gem depends on it.

This incorrectly leaves Rails (or any gem like it) using two different
codepaths / gem source code.

https://github.com/ruby/rubygems/commit/dff76ba4f6
2026-01-07 07:30:26 +00:00
Schneems
4377249bbf [ruby/rubygems] Test for removing current bundler version
https://github.com/ruby/rubygems/commit/675342e6d0
2026-01-06 04:38:13 +00:00
Hiroshi SHIBATA
01e8b38f60
Use RUBY_VERSION in specs instead of hardcoded 'Ruby 4.0.0' to make tests version-independent 2026-01-05 11:32:42 +09:00
Benoit Daloze
6eadc01cda Fix condition for UTF-8 default in magic_comment_spec.rb 2026-01-04 18:13:08 +01:00
Benoit Daloze
9888a3e8bd UNIXSocket#recvfrom only returns the path on Linux
* Notably it does not on BSD, macOS and Windows.
2026-01-04 18:10:42 +01:00
Benoit Daloze
2bf9543053 Remove assertion which does not hold
* https://github.com/ruby/ruby/actions/runs/20694508956/job/59407571754
  1)
  UNIXSocket.pair emulates unnamed sockets with a temporary file with a path FAILED
  Expected "C:\\a\\_temp\\102424668889-2384.($)".match? /\\AppData\\Local\\Temp\\\d+-\d+\.\(\$\)\z/
  to be truthy but was false
2026-01-04 16:04:02 +01:00
Benoit Daloze
e79f8974b5 Get better error if UNIXSocket.socketpair spec fails 2026-01-04 15:39:31 +01:00
Benoit Daloze
29e7973e05 Update to ruby/spec@94dbd55 2026-01-04 15:36:02 +01:00
Benoit Daloze
1b3382cbab Update to ruby/spec@f54296d 2026-01-04 14:53:24 +01:00
Benoit Daloze
a7fec4d661 Update version guards in ruby/spec 2025-12-30 16:02:39 +01:00
Benoit Daloze
c970d2941d [Bug #21784] Fix the Proc#source_location start_column for stabby lambdas
* Consistent with plain `blocks` and `for` blocks and methods
  where the source_location covers their entire definition.
* Matches the documentation which mentions
  "where the definition starts/ends".
* Partially reverts d357d50f0a74409446f4cccec78593373f5adf2f
  which was a workaround to be compatible with parse.y.
2025-12-30 16:02:39 +01:00
Benoit Daloze
d82fc3360d Reapply "[Feature #6012] Extend source_location for end position
* This reverts commit 065c48cdf11a1c4cece84db44ed8624d294f8fd5.
* This functionality is very valuable and has already taken 14 years
  to agree on the API.
* Let's just document it's byte columns (in the next commit).
* See https://bugs.ruby-lang.org/issues/21783#note-9
2025-12-30 16:02:39 +01:00
Jeremy Evans
38701a4de8 Remove deprecated support for to_set taking arguments 2025-12-29 14:54:41 +09:00
Nobuyoshi Nakada
8c7b1401a5
Remove rb_iterate deprecated since 1.9 2025-12-26 17:53:23 +09:00
Hiroshi SHIBATA
89af235435 Added ruby_41? platform 2025-12-26 11:00:51 +09:00
Hiroshi SHIBATA
74becf1b61 Start to develop 4.1.0.dev 2025-12-26 11:00:51 +09:00
Hiroshi SHIBATA
1c3ef27191 Merge RubyGems 4.0.3 and Bundler 4.0.3 2025-12-23 16:10:04 +09:00
Nobuyoshi Nakada
77c3a9e447 Revert pack/unpack support for LEB128
https://bugs.ruby-lang.org/issues/21785#note-10
> It is too late to introduce it in Ruby 4.0, let's aim for 4.1.

This reverts commits:

* d0b72429a93e54f1f956b4aedfc25c57dc7001aa
  Add support for signed and unsigned LEB128 to pack/unpack.

* 68a900e30b4ca1537d7975c3a619fd94fca7b084
  add news for pack / unpack directives
2025-12-20 16:59:51 +09:00
Nobuyoshi Nakada
6f6ea70dce
Just passing FDs does not need to create IO objects 2025-12-19 13:36:43 +09:00
Nobuyoshi Nakada
bfba65d8c1
Extract Test::JobServer module
A placeholder to handle GNU make jobserver option.
spec/default.mspec didn't handle the jobserver using a FIFO.
2025-12-19 13:36:42 +09:00
Aaron Patterson
d0b72429a9 Add support for signed and unsigned LEB128 to pack/unpack.
This commit adds a new pack format command `R` and `r` for unsigned and
signed LEB128 encoding.  The "r" mnemonic is because this is a
"vaRiable" length encoding scheme.

LEB128 is used in various formats including DWARF, WebAssembly, MQTT,
and Protobuf.

[Feature #21785]
2025-12-18 14:42:47 -08:00
tomoya ishida
7e13fbc0ed
Update bundled bigdecimal and rbs (#15611)
* Bundle rbs-3.10.0.pre.1

* Update rbs gem entry with commit hash

Updated rbs entry to include commit hash.

* Fix rbs entry in bundled_gems

* Update rbs gem to version 3.10.0.pre.2

Updated rbs gem version from 3.10.0.pre.1 to 3.10.0.pre.2.

* Update bundled bigdecimal to v4.0.1

---------

Co-authored-by: Soutaro Matsumoto <matsumoto@soutaro.com>
2025-12-18 03:04:49 +09:00
Hiroshi SHIBATA
3b66efda52 Bundle RubyGems 4.0.2 and Bundler 4.0.2 2025-12-17 12:12:34 +09:00
Nobuyoshi Nakada
85b40c5ea8 Box: fix the class name in tests 2025-12-16 16:53:13 +09:00
Nobuyoshi Nakada
065c48cdf1 Revert "[Feature #6012] Extend source_location for end position
and columns"

This reverts commit 073c4e1cc712064e626914fa4a5a8061f903a637.

https://bugs.ruby-lang.org/issues/6012#note-31
> we will cancel this feature in 4.0 because of design ambiguities
> such as whether to return column positions in bytes or characters as
> in [#21783].

[#21783]: https://bugs.ruby-lang.org/issues/21783
2025-12-16 16:13:07 +09:00
Edouard CHIN
9f593156b6 [ruby/rubygems] Pass down value of BUNDLE_JOBS to RubyGems before compiling:
- ### Problem

  Since https://github.com/ruby/rubygems/pull/9131, we are now
  compiling make rules simultaneously. The number of jobs
  is equal to the number of processors.
  This may be problematic for some users as they want to control
  this value.

  ### Solution

  The number of jobs passed to `make` will now be equal to the
  `BUNDLE_JOBS` value.

  ### Side note

  It's also worth to note that since Bundler installs gems in
  parallel, we may end up running multiple `make -j<JOB>` in parallel
  which would cause exhaust the number of processors we have.
  This problem can be fixed by implementing a GNU jobserver, which I
  plan to do. But I felt that this would be too much change in one PR.

https://github.com/ruby/rubygems/commit/d51995deb9
2025-12-16 04:21:49 +00:00
hituzi no sippo
f3b9509b52 [ruby/rubygems] Fix quote handling in mise format ruby version parsing
The previous regex didn't properly match quoted strings
it would capture the opening quote as part of the version
if quotes were mismatched.
This change properly parses double-quoted, single-quoted,
and unquoted version strings separately.

https://github.com/ruby/rubygems/commit/81e48c8185
2025-12-16 03:56:22 +00:00
hituzi no sippo
3b50f4ba41 [ruby/rubygems] Support single quotes in mise format ruby version
https://github.com/ruby/rubygems/commit/a7d7ab39dd
2025-12-16 03:56:21 +00:00
Hiroshi SHIBATA
060199910a [ruby/rubygems] Allow to show cli_help with bundler executable
https://github.com/ruby/rubygems/commit/a091e3fd10
2025-12-16 02:36:10 +00:00
Edouard CHIN
ff1b8ffa61 [ruby/rubygems] Tweak the Bundler's "X gems now installed message":
- Fix https://github.com/ruby/rubygems/pull/9188
- This message is a bit misleading because it always outputs one extra
  specs, which is Bundler itself.

  This is now fixed when the message is about to be output.

https://github.com/ruby/rubygems/commit/70b4e19506
2025-12-16 00:16:15 +00:00
Edouard CHIN
f88e797090 [ruby/rubygems] Allow bundle pristine to work for git gems in the same repo:
- Fix https://github.com/ruby/rubygems/pull/9186
- ### Problem

  Running `bundle pristine` in a Gemfile where there is many git gem
  pointing to the same repository will result in a error
  "Another git process seems to be running in this repository".

  ### Context

  This error is a regression since https://github.com/ruby/rubygems/commit/a555fd6ccd17
  where `bundle pristine` now runs in parallel which could lead
  to running simultaneous git operations in the same repository.

  ### Solution

  When Bundler pristine a git gem it does a `git reset --hard` without
  specifying a path.
  This means the whole repository will be reset. In this case, we can
  leverage that by just pristining one gem per unique git sources.
  This is also more efficient.

https://github.com/ruby/rubygems/commit/710ba514a8
2025-12-16 00:15:57 +00:00
Nobuyoshi Nakada
3636277dc5
Add NUM2PTR and PTR2NUM macros
These macros have been defined here and there, so collect them.
2025-12-10 12:09:50 +09:00
Nobuyoshi Nakada
f9eb0d8da2
Use ruby_version_is
As the markers for spec/mspec/tool/remove_old_guards.rb.
2025-12-10 09:22:09 +09:00
Jeremy Evans
e436dba9fe Use rb_error_frozen_object in rb_class_modify_check
This provides information on the class of the frozen object. It also
results in a much simpler implementation.

Fixes [Bug #21374]
2025-12-10 07:35:50 +09:00
Hiroshi SHIBATA
875c4c7dfd [ruby/rubygems] Bump Bundler version to 4.0.1
(cherry picked from commit https://github.com/ruby/rubygems/commit/26c1db5a65a8)

https://github.com/ruby/rubygems/commit/bbb5b767d0
2025-12-09 12:09:52 +00:00
Edouard CHIN
12c16f9ded [ruby/rubygems] Fix Bundler removing executables after creating them
When running a fresh `bundle install` with gems that contains
executables, Bundler will generate binstubs but soon after will remove
them. This is a regression introduced in https://github.com/ruby/rubygems/commit/573ffad3ea4a.

This results in doing `bundle install && bundle exec foo` to raise an
error saying `foo` couldn't be found.

This issue only appears if `BUNDLE_CLEAN` is set.

At the end of the installation process, when Bundler has installed
gems and generated binstubs, it runs the cleanup.

1. It [detects](4f8aa3b40c/bundler/lib/bundler/runtime.rb (L182)) the executable for the current specs
2. Any existing executables not detected is then removed 4f8aa3b40c/bundler/lib/bundler/runtime.rb (L194).

The issue being that 1. now returns an empty array where as it should
return the executables of the gems from the current bundle.

The problem is in https://github.com/ruby/rubygems/commit/573ffad3ea4a where we
removed the `executables` method from the `EndpointSpecification`.
When Bundler reads the lockfile, it creates a `EndpointSpecification`
object for each spec. At this point, the EndpointSpecification doesn't
know about the `executables` of a gem. Once Bundler fetches the
`gemspec` from the remote, it swaps the the "spec" with the real one
and from here knows what executables the gem has.

Reintroduce the `executables` method and the `bindir` in the
EndpointSpecification class. From what I'm seeing, the removal
of those wasn't needed to resolve the issue where Bundler remembers
CLI flags. This is probably an oversight.

https://github.com/ruby/rubygems/commit/b47f6b0247
2025-12-09 02:01:59 +00:00
Benoit Daloze
fab94ecd34 [ruby/rubygems] Fix the config suggestion in the warning for $ bundle
* `install_or_cli_help` does not exist for older Bundler like Bundler 2
  and so results in a confusing error on Bundler 2:
  ```
  $ bundle
  Could not find command "".
  ```
* See https://github.com/ruby/rubygems/pull/9136/files#r2592366837
* Merge the behavior of `install_or_cli_help` in `install`.

https://github.com/ruby/rubygems/commit/9b4819ae18
2025-12-09 01:37:50 +00:00
yoshoku
1de15815a8 [ruby/rubygems] Fix native extension loading in newgem template for RHEL-based systems
Add fallback to `require` when `require_relative` fails to load native
extensions. This addresses an issue on RHEL-based Linux distributions
where Ruby scripts and built native extension shared libraries are
installed in separate directories.

https://github.com/ruby/rubygems/commit/68599bd107
2025-12-08 07:03:32 +00:00
Nobuyoshi Nakada
f4f5f0a009
Add error case tests for File.path
- for non-String argument
- for NUL-contained argument
- for ASCII-incompatible argument
2025-12-06 19:32:14 +09:00
Hiroshi SHIBATA
d3a9a17b6f
Skip Windows runner group warning under ruby/ruby repo 2025-12-05 11:00:40 +09:00
Hiroshi SHIBATA
d105709f2b [ruby/rubygems] Add before(:context) hook to warn when spec files are not assigned to any Windows runner group
https://github.com/ruby/rubygems/commit/3ddb740969
2025-12-04 23:01:22 +00:00
Hiroshi SHIBATA
412895ae84 [ruby/rubygems] Try to split and run three runners for Windows
I organized all examples the followings:

```
Total test time: 2468.41 seconds
Total files: 168

Group A: 42 files, 617.08 seconds
Group B: 42 files, 617.05 seconds
Group C: 42 files, 617.14 seconds
Group D: 42 files, 617.14 seconds
```

https://github.com/ruby/rubygems/commit/94d41e6c7c
2025-12-04 23:01:22 +00:00
Nobuyoshi Nakada
cf12aff059
[Bug #21764] Propagate the encoding of ID to warning 2025-12-05 00:27:45 +09:00
Nobuyoshi Nakada
b872fbe3dd
Deprecate rb_eval_cmd_kw 2025-12-04 18:07:49 +09:00
Edouard CHIN
932762f294 [ruby/rubygems] Increase connection pool to allow for up to 70% speed increase:
- ### TL;DR

  Bundler is heavily limited by the connection pool which manages a
  single connection. By increasing the number of connection, we can
  drastiscally speed up the installation process when many gems need
  to be downloaded and installed.

  ### Benchmark

  There are various factors that are hard to control such as
  compilation time and network speed but after dozens of tests I
  can consistently get aroud 70% speed increase when downloading and
  installing 472 gems, most having no native extensions (on purpose).

  ```
  # Before
  bundle install  28.60s user 12.70s system 179% cpu 23.014 total

  # After
  bundle install  30.09s user 15.90s system 281% cpu 16.317 total
  ```

  You can find on this gist how this was benchmarked and the Gemfile
  used https://gist.github.com/Edouard-chin/c8e39148c0cdf324dae827716fbe24a0

  ### Context

  A while ago in #869, Aaron introduced a connection pool which
  greatly improved Bundler speed. It was noted in the PR description
  that managing one connection was already good enough and it wasn't
  clear whether we needed more connections. Aaron also had the
  intuition that we may need to increase the pool for downloading
  gems and he was right.

  > We need to study how RubyGems uses connections and make a decision
  > based on request usage (e.g. only use one connection for many small
  > requests like bundler API, and maybe many connections for
  > downloading gems)

  When bundler downloads and installs gem in parallel 4f85e02fdd/bundler/lib/bundler/installer/parallel_installer.rb (L128)
  most threads have to wait for the only connection in the pool to be
  available which is not efficient.

  ### Solution

  This commit modifies the pool size for the fetcher that Bundler
  uses. RubyGems fetcher will continue to use a single connection.

  The bundler fetcher is used in 2 places.

  1. When downloading gems 4f85e02fdd/bundler/lib/bundler/source/rubygems.rb (L481-L484)
  2. When grabing the index (not the compact index) using the
    `bundle install --full-index` flag.
    4f85e02fdd/bundler/lib/bundler/fetcher/index.rb (L9)

  Having more connections in 2) is not any useful but tweaking the
  size based on where the fetcher is used is a bit tricky so I opted
  to modify it at the class level.
  I fiddle with the pool size and found that 5 seems to be the sweet
  spot at least for my environment.

https://github.com/ruby/rubygems/commit/6063fd9963
2025-12-04 06:47:46 +00:00