Commit graph

378 commits

Author SHA1 Message Date
David Rodríguez
e42f1aaa5a [rubygems/rubygems] Fix truffleruby failing to install sorbet-static when there's no lockfile
The generic Ruby platform was getting unconditionally added in
truffleruby, preventing resolution in situations where there's no
generic ruby version (sorbet-static). Instead, the generic platform
should be considered per dependency, not globally.

a96afc5351
2025-07-30 11:19:26 +09:00
David Rodríguez
0dc86fd843 [rubygems/rubygems] Remove unnecessary branching
We now run specs against a single version, so I prefer to keep a single
branch. Once we bump the major version, this will need very little
updates, and that seems fine.

3866d25a00
2025-07-28 09:39:03 +09:00
David Rodríguez
e67f595e8f [rubygems/rubygems] Build bundler gem just once for specs
When we need to reset system gems during specs, there's no need to
rebuild bundler, we can copy over the original gem home.

7b4f80747b
2025-07-25 11:10:37 +09:00
David Rodríguez
63c4223775 [rubygems/rubygems] Don't create an empty bundled_app when setting up deps
Running everything in `bundled_app` by default causes the `bundled_app`
helper to be used everytime, and that will create a scoped bundled_app
folder if it does not exist. That causes `bin/rake spec:deps` to create
an empty `tmp/2.1/bundled_app` folder which is a bit weird.

This commit changes specs to not switch to a (possibly empty)
bundled_app directory when not necessary (for example, when running
`gem` commands in order to setup test dependencies).

4bf89c0705
2025-07-25 11:10:36 +09:00
David Rodríguez
60fca1defc
Cancel --force deprecation in favor of --redownload
I realized `--redownload` is not a good name, because it does not
necessarily redownloads gems. It only forces reinstallation even if gem
is already installed.

So I believe `--force` is actually a better name and the introduction of
`--force` was a misunderstanding of what the `--force` flag did at the
time.

Let's cancel the deprecation of `--force`.

For now the `--redownload` alias is left around until we decide what to
do with it.
2025-07-17 11:10:46 +09:00
David Rodríguez
cd3389e5c2 [rubygems/rubygems] Cancel path_relative_to_cwd change
It only affected the `--path` flag which is actually getting removed, so
I don't think it makes sense to make such change. The current behavior
is reasonable and I tried to codify it with a few more specs.

6f520eb146
2025-07-07 11:53:11 +09:00
David Rodríguez
e95adbfa68 [rubygems/rubygems] Remove unnecessary nesting from standalone specs
Originally, all the specs in this file were put inside a shared examples
block, and since then all specs were run only changing the cwd (either
from root, or a subdirectory).

This was in d7291700d0, to cover a fix in
the `bundler_path` method.

However, reverting that fix does not make any of the specs in either of
the main blocks fail! Only an unrelated spec of `bundle install
--standalone --local` fails.

The reason is that all specs set `path` to an absolute path, making the
fix essentially uncovered.

In order to simplify the file structure and improve runtime, I
completely removed the shared examples block, and only run main specs
for the root directory. Then I added a couple of extra specs to cover
the original bug fix.

This cuts runtime of this spec file in half, from 1m30s to 45s on my
laptop.

cc506f17e0
2025-07-07 11:53:05 +09:00
David Rodríguez
81da38b308 Sync RubyGems 2025-07-03 13:43:00 +09:00
David Rodríguez
b5ef0114cd
[rubygems/rubygems] Migrate all remaining specs to run offline
Also removed the helper to install real gems during specs to avoid the
temptation of introducing network stuff again.

a1ab5e319a
2025-07-02 10:34:18 +09:00
David Rodríguez
5386b6568f
[rubygems/rubygems] Verify specs still using realworld gems still pass with latest versions
9da44ade24
2025-07-02 10:34:18 +09:00
David Rodríguez
41c44ff8e6
[rubygems/rubygems] Realworld optparse gem should be no longer necessary
Optparse was vendored a while ago.

d7afd43756
2025-07-02 10:34:18 +09:00
David Rodríguez
eb979d998a
[rubygems/rubygems] Don't use currently configured value for default branch
1ae8533690
2025-07-02 10:34:18 +09:00
David Rodríguez
2fd1f4e6d9
[rubygems/rubygems] Logger realworld gem is no longer necessary
6e6288a496
2025-07-02 10:34:18 +09:00
David Rodríguez
669813a48d
[rubygems/rubygems] Realworld tsort gem should be no longer necessary
93d9b97182
2025-07-02 10:34:18 +09:00
David Rodríguez
d8cf0013ef
[rubygems/rubygems] These specs need stringio only for old versions
a44cdf4c21
2025-07-02 10:34:18 +09:00
David Rodríguez
9e566141cd [rubygems/rubygems] Remove "double CI" for testing Bundler 4 mode
Since now every functionality that changes in Bundler 4 is under a
setting, we can enable that setting to test the new functionality,
without having to run our full CI twice.

This can actually be seen as increasing coverage, because Bundler 4
functionality will now be tested on Windows, MacOS, or any other
environment where previously "Bundler 4 mode" was not running.

1cb3e009fc
2025-06-30 12:56:50 +09:00
David Rodríguez
bda2d90969 Rewrite specs to not start local dev servers
They cause flakies when different tests start them in parallel, and also
make the specs more complicated.
2025-06-30 12:56:50 +09:00
David Rodríguez
077dbb8d42 [rubygems/rubygems] Remove unnecessary loading of fileutils from path specs
These specs load artifice before Bundler boots because of their global
rubygems source. Artifice in turn loads `rack`, `rack-test`, and
`tmpdir` which in turn load `fileutils`.

Because of this, a missing `require` of `fileutils` in RubyGems would
not be caught by specs.

Loading artifice is not necessary for most of these specs, so remove the
global source to avoid it.

aad871c997
2025-06-25 22:41:55 +09:00
David Rodríguez
c17d381d67 [rubygems/rubygems] Remove message long gone from the code base from expectations
2eaada3508
2025-06-25 22:41:52 +09:00
David Rodríguez
bc6b045153
[rubygems/rubygems] Cleanup now unnecessary RUBYOPT handling
ac83c78635
2025-06-24 12:10:50 +09:00
David Rodríguez
7c115b8633 [rubygems/rubygems] Fix flaky test failures in mirror probing specs
The mirror probing spec file was moved to our regular suite, which runs
in parallel, recently. These specs rely on starting and stopping actual
servers in localhost, but this does not play nice with parallelization,
because a spec may kill the webserver another spec has created.

This commit moves mirror probing specs to not need to start servers in
localhost and do something more similar to what the other specs do.

ca9a19706f
2025-06-23 11:06:57 +09:00
David Rodríguez
441f18df52
Skip to Bundler 4 directly 2025-06-19 10:23:36 +09:00
David Rodríguez
f3ea6c35cc
[rubygems/rubygems] Normalize Bundler version spec filters
28b6a7cf5e
2025-06-19 10:23:36 +09:00
David Rodríguez
af0b184e83
[rubygems/rubygems] Never ignore gems from path sources during activation
The "ignore" attribute is a RubyGems thing to mark when a installed gem
should be ignored for activation because its extensions are not properly
compiled.

In the case of gems from path sources, the warning is not accurate
because extensions are compiled into the local lib path, which is not
where RubyGems leaves its sentinel `gem.build_complete` file.

Also, there's a single version of each gem in the path source available
to Bundler, so we always certainly want to consider that for activation
and never makes sense to ignore it.

ec5d33695e
2025-06-19 10:23:36 +09:00
David Rodríguez
89ce782fed
[rubygems/rubygems] Reword a couple of specs to further clarify them
e28b5e306f
2025-06-17 15:09:35 +09:00
David Rodríguez
632bf3b54b
[rubygems/rubygems] Migrate mirror probe specs to use the compact index API
Could potentially fix some flakies we're using and make the specs more
"modern" and simplifies them because less fallbacks are involved.

30da9a1a93
2025-06-17 15:09:35 +09:00
David Rodríguez
3319d3d76c
[rubygems/rubygems] Consistently use instance variables directly
I don't think the indirection improve things.

b408b28844
2025-06-17 15:09:35 +09:00
David Rodríguez
459f265b56
[rubygems/rubygems] Cleanup dead code, RubyGems 3.3 is no longer supported
945a29a477
2025-06-17 15:09:34 +09:00
David Rodríguez
d95f7a3c43
[rubygems/rubygems] Extract stdboth spec helper
bb13f4e702
2025-06-06 10:09:14 +09:00
David Rodríguez
970eac1530 [rubygems/rubygems] Fix git source unlocking for multi-gem repositories like Rails
If you have

```
gem "rails", git: "https://github.com/rails/rails"
```

and then explicitly pin to an older ref, like

```
gem "rails", git: "https://github.com/rails/rails", ref: "99bacb5aa8"
```

Then `bundle install` fails, because locked sources fail to be updated
to use the new source.

This commit fixes the problem by making sure get their source properly
replaced.

5de8c2e0cf
2025-06-05 19:12:46 +09:00
Nicholas La Roux
869a52f33a
[rubygems/rubygems] Partially phase out x64-mingw32 in favour of x64-mingw-ucrt (platforms)
- the x64-mingw32 platform has been superseded by x64-mingw-ucrt
- the mingw-ucrt platform is present as of Windows 10, which was released 10 years ago in 2015 and all versions prior to 10 are end-of-life and 10 will be by mid October 2025
- newer rubies use the mingw-ucrt platform instead of the mingw32 platform, meaning using the deprecated platform can cause issues during gem installation

b9d871022e
2025-06-03 07:47:14 +09:00
David Rodríguez
57e4176649
[rubygems/rubygems] Fix test warnings introduced by recent CGI changes
They read like this:

```
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/util.rb:13: warning: method redefined; discarding old rfc1123_date
/opt/hostedtoolcache/Ruby/3.4.3/x64/lib/ruby/3.4.0/cgi/util.rb:225: warning: previous definition of rfc1123_date was here
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/util.rb:34: warning: method redefined; discarding old pretty
/opt/hostedtoolcache/Ruby/3.4.3/x64/lib/ruby/3.4.0/cgi/util.rb:246: warning: previous definition of pretty was here
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/escape.rb:16: warning: method redefined; discarding old escape
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/escape.rb:29: warning: method redefined; discarding old unescape
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/util.rb:13: warning: method redefined; discarding old rfc1123_date
/opt/hostedtoolcache/Ruby/3.4.3/x64/lib/ruby/3.4.0/cgi/util.rb:225: warning: previous definition of rfc1123_date was here
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/util.rb:34: warning: method redefined; discarding old pretty
/opt/hostedtoolcache/Ruby/3.4.3/x64/lib/ruby/3.4.0/cgi/util.rb:246: warning: previous definition of pretty was here
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/escape.rb:16: warning: method redefined; discarding old escape
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/escape.rb:29: warning: method redefined; discarding old unescape
```

The problem is that `rspec` loads `erb` for its configuration, which
loads `cgi/util` from system gems.

Then our tests change the `$LOAD_PATH` to make test gems installed in
tmp visible to `require`, and then they all require `cgi` as a
transitive dependency of `rack-test`, this time from `tmp` gems. This
causes system and test specific copies to be mixed together and these
warnings to be printed, but we have also observed failures in some tests
with errors like

> class variable @@accept_charset of CGI::Util is overtaken by CGI::Escape

This changes should also fix those failures.

The fix is to require all of `rack-test` (including `cgi`) before we
have changed the `$LOAD_PATH`. Because the `$LOAD_PATH` is unchanged,
RubyGems respects the version of `cgi` activated by RSpec, avoiding the
double loads.

34e75465c6
2025-05-19 11:19:17 +09:00
David Rodríguez
0f867d97ab
Rename a couple of spec files
Generally are "realworld" specs are the ones using VCR cassettes of real
requests. These files don't use that, so I moved them to a different
place.
2025-05-19 11:19:17 +09:00
David Rodríguez
00389b664b [rubygems/rubygems] Fix false positive warning about insecurely materialized gem
In frozen mode, the previous logic would not set the platform locked
originally in the materialized specification, and that would trigger the
warning about insecure materialization incorrectly.

a18001e10c
2025-04-15 16:47:16 +09:00
David Rodríguez
ce2640dde8 [rubygems/rubygems] Fix edge case making bundle update behave incorrectly
If both a native and a generic version are locked, but the native
version is incompatible with the running Ruby, Bundler will still keep
the native version in the lockfile, since it could be potentially useful
when using other rubies.

However, when `bundle update` is run, this was not the case because the
locked native gems were not using the right source when materializing.
They were using the lockfile source instead of the Gemfile source, and
that meant they could not be found when materializing, because the
lockfile source always uses local mode so does not see them.

The effect of this was normally that they were incorrectly removed from
the lockfile and a strange "this spec has been possibly yanked" was
printed in verbose mode. However, in certain situations (i.e., when the
generic gem would bring extra dependencies), it could also make `bundle
update` crash.

The solution is, when adding this extra locked specs to the result after
resolving, maybe sure they inherit the source from the resolved specs,
so they can be found when materializing.

`bundle install` did not have the issue because it passes locked specs
to the resolver, and assigns the right source to them in
`Definition#converge_locked_specs`.

91ce881fda
2025-04-14 16:17:50 +09:00
David Rodríguez
ab4a25e48e [rubygems/rubygems] Follow up to removal of rubyinstaller2 workaround
5b312fd040
2025-04-09 08:11:10 +09:00
David Rodríguez
710bf4a472 [rubygems/rubygems] Rubyinstaller2 fixed this
08b3c48f41
2025-04-04 08:54:47 +09:00
David Rodríguez
cd1952484c [rubygems/rubygems] Stay away from FileUtils.rm_rf in Bundler specs
Instead, skip the spec when run by ruby-core. Maybe the root cause can
be fixed at some point.

09594ae5b8
2025-04-01 13:31:48 +09:00
David Rodríguez
79f3167e0b [rubygems/rubygems] Let compact index response parser consistently return a mutable dependencies array
That restores support for compact index dummy implementations that only lists
versions, without checksums or dependencies.

This format is undocumented, so we may want to get rid of it in the
future. However, some of our tests rely on it, and some implementations
did use it (gems.mutant.dev at least). And the way the code was written
suggest that support was intentional.

So for now, we should restore it.

0427d8c983
2025-04-01 09:57:40 +09:00
David Rodríguez
dea505dea0
[rubygems/rubygems] Allow ruby platform to be remove also when dependencies have changed
Since we will now add it back if the final resolution is compatible, we
can also get this kind of edge case (`bundle add`) working.

cdc5ebec77
2025-03-31 09:39:22 +09:00
Hiroshi SHIBATA
ef7c7f9e77 Revert "Fix broken CI. (#12963)"
This reverts commit eb91c664dc.
2025-03-24 13:25:07 +09:00
David Rodríguez
55930987e1 [rubygems/rubygems] Raise an error in frozen mode if CHECKSUMS entries are missing
054a0cd76c
2025-03-24 13:25:07 +09:00
David Rodríguez
60d00da083 [rubygems/rubygems] Fix redundant path configurations
The deployment setting already does this implicitly.

402b11fa39
2025-03-24 13:25:07 +09:00
David Rodríguez
4e1df25b15 [rubygems/rubygems] Improve grammar of some error messages
558a4765c7
2025-03-24 13:25:07 +09:00
David Rodríguez
bb1b5877a7 [rubygems/rubygems] Consistently use "lockfile" over "lock file"
e891be9197
2025-03-24 13:25:07 +09:00
Samuel Williams
eb91c664dc
Fix broken CI. (#12963)
* Increase timeout to fix flaky tests?

* Fix bundler test - wording changed.

expect "fatal: Remote branch deadbeef not found in upstream origin" to
include "Revision deadbeef does not exist in the repository"
2025-03-23 12:49:18 +13:00
Hiroshi SHIBATA
1a222816fb Restore to use rm_rf for failing example
3861666452
2025-03-12 18:02:09 +09:00
David Rodríguez
510edbccf9 [rubygems/rubygems] Fix ENAMETOOLONG error when creating compact index cache
If a custom rubygems source URI is long enough, Bundler may end up
raising an `ENAMETOOLONG` error and crash.

This commit fixes the problem by trimming the cache slug size to fit
usual OS requirements.

df40ff1e14

Co-authored-by: mbclu <mbclu@users.noreply.github.com>
Co-authored-by: martinemde <martinemde@users.noreply.github.com>
2025-03-12 18:02:09 +09:00
David Rodríguez
13020ac069 [rubygems/rubygems] Path helper to build paths in compact index cache
d28f9b8515
2025-03-12 18:02:09 +09:00
David Rodríguez
51958bae66 [rubygems/rubygems] Prefer FileUtils.rm_r to FileUtils.rm_rf for specs
Because it does not swallow errors if it fails to remove the given
folders, making issues easier to debug.

0db12d7afc
2025-03-12 18:02:09 +09:00