Commit graph

85 commits

Author SHA1 Message Date
Hiroshi SHIBATA
616771e34e Merge RubyGems-3.6.9 and Bundler-2.6.9 2025-05-22 09:20:28 -07:00
Hiroshi SHIBATA
d766eceb48 Merge RubyGems-3.6.8 and Bundler-2.6.8 2025-05-22 09:20:28 -07:00
Hiroshi SHIBATA
e580145171 Merge RubyGems-3.6.7 and Bundler-2.6.7 2025-04-08 17:54:29 -07:00
Hiroshi SHIBATA
a0025b6e5d Merge RubyGems-3.6.4 and Bundler-2.6.4 2025-02-20 16:50:20 -08:00
Hiroshi SHIBATA
19c69f382b Merge RubyGems-3.6.3 and Bundler-2.6.3 2025-02-20 16:50:20 -08:00
David Rodríguez
2b91a56d40 [rubygems/rubygems] Remove no longer necessary code
9ea1539b08
2024-11-26 15:11:05 +09:00
David Rodríguez
10de74b75b [rubygems/rubygems] Avoid needing a second pass to ignore unlocked gems
When converging locked specifications to select the ones that should be
preserved while resolving, we can avoid having to do a second pass to
ignore the ones that have been explicitly unlocked.

411742703e
2024-11-26 15:11:05 +09:00
David Rodríguez
44ad2e3f38 [rubygems/rubygems] Allow some materialized specs to be missing
As long as some spec in the materialization is complete.

9a673b0bbb
2024-11-26 15:11:05 +09:00
David Rodríguez
36fb7994fe [rubygems/rubygems] Deprecate check parameter to Bundler::SpecSet#for
3041b3d784
2024-11-26 15:11:05 +09:00
David Rodríguez
c76b1ea2a6 [rubygems/rubygems] Keep track of materializations in the original resolve
This gives more flexibility to allow further improvements.

f11a890f5e
2024-11-26 15:11:05 +09:00
David Rodríguez
e15921c694 [rubygems/rubygems] Create LazySpecifications directly with most_specific_locked_platform
So there's no need to pass it around in so many places.

784ab7481b
2024-11-26 15:11:05 +09:00
David Rodríguez
7c93460331 [rubygems/rubygems] Simplify more
a2bb68a29b
2024-11-26 15:11:05 +09:00
David Rodríguez
83ce2351ff [rubygems/rubygems] Remove no longer necessary code
e1caeecdf8
2024-11-26 15:11:05 +09:00
David Rodríguez
631908d9a8 [rubygems/rubygems] Use platform local variable
6a6041d073
2024-11-26 15:11:05 +09:00
David Rodríguez
10d694a1ff [rubygems/rubygems] Warn on insecure materialization
bc2537de71
2024-11-08 12:06:32 +00:00
David Rodríguez
4d83f37ff7 [rubygems/rubygems] Reduce global state
43c0c41c6b
2024-11-08 12:06:30 +00:00
David Rodríguez
5fa491b405 Normalize lockfile platforms 2024-10-26 18:44:15 +09:00
David Rodríguez
7285e76493
Fix truffleruby removing gems from lockfile
When resolving on truffleruby, and multiple platforms are included in
the lockfile, Bundler will not respect existing platforms, but always
force ruby variants. That means removal of existing version specific
variants, introducing lockfile churn between implementations.

To prevent this, we introduce the distinction between
`Dependency#force_ruby_platform`, only settable via Gemfile, and
`Dependency#default_force_ruby_platform`, which is always true on
truffleruby for certain dependency names. This way, when resolving
lockfile gems for other platforms on truffleruby, we keep platform
specific variants in the lockfile.

However, that introduces the problem that if only platform specific
variants are locked in the lockfile, Bundler won't be able to
materialize on truffleruby because the generic variant will be missing.
To fix this additional problem, we make sure the generic "ruby" platform
is always added when resolving on truffleruby.
2024-08-05 11:58:07 +09:00
David Rodríguez
e7610582ad [rubygems/rubygems] Fix bundle exec gem uninstall
* `bundle exec` assigns `Gem::Specification.all` to the set of specs
  known to Bundler (a `Bundler::SpecSet`).

* `gem uninstall` recently started calling `#delete` on the set of specs
  stored in `Gem::Specification#all`. This, in RubyGems, is just an
  array of specs, so has a `#delete` method that receives a single
  element.

* However, at some point I added a `SpecSet#delete` method that takes an
  array of specs, breaking the "Array-like" contract and making `gem
  uninstall` break when run in a `bundle exec` context.

The fix is to make `Bundler::SpecSet#delete` handle being given a single
spec.

e3acb7b01d
2024-07-23 19:43:26 +00:00
David Rodríguez
e6c7a309d0 [rubygems/rubygems] Refactor selecting specs from a SpecSet
bcbbff5149
2024-07-09 16:34:09 +00:00
David Rodríguez
dd05191bc3 [rubygems/rubygems] Resolve all platforms directly
Instead of having to do a complete pass after resolve.

To do this, we add to the ruby group all the platform specs with the
same dependencies as the ruby specs.

e50415f2a6
2024-07-09 16:34:08 +00:00
David Rodríguez
744dd5a362 [rubygems/rubygems] Fix performance regression on applications with a local cache
Even if all gems are properly installed and no resolve is needed, we
recently started always reading all packages in `vendor/cache` and
extracting specifications from them.

This commit fixes the problem by longer making considering cached specs
the default and only enable them when a resolve is actually needed.

edeb2c42bf
2024-05-24 15:02:30 +00:00
David Rodriguez
7857061ecd [rubygems/rubygems] Fix regression when caching gems from secondary sources
If `cache_all_platforms` setting is enabled, the secondary source was
no longer considering cached gems.

That means that if the remote secondary source has removed its gems,
then this was now resulting in an error while before the previously
cached gem from the source would still be used.

This commit restores previous behavior.

2d2cd00255
2024-05-16 09:21:32 +00:00
Mike Dalessio
98c84ef42c [rubygems/rubygems] Excluding local platform from lockfile should not affect musl vs gnu case
This case is for not locking things like `arm-darwin-23` when the
lockfile already includes `arm-darwin`, so that we don't infinitely keep
redundant versioned platforms in the lockfile when not necessary.

We detect this with `Gem::Platform#===`. For example,
`Gem::Platform.new("arm-darwin-23") === Gem::Platform.new("arm-darwin")`
but they're not `==`.

However, in the case of `-musl` vs `-gnu`, those act as the platform
"version", but `===` is not commutative for them. This is explained in
`===` docs.

We only want to exclude the local platform in situations when
`Gem::Platform#===` is actually commutative.

8099c4face
2024-04-17 18:17:12 +00:00
David Rodriguez
95c9711d6e [rubygems/rubygems] Fix musl platform not being added to the lockfile
235f7b4266
2024-01-31 19:07:39 +00:00
David Rodríguez
b8f859f0bf Complete missing specs for platforms after resolution
If two platform specific variants have different dependencies, then
resolution may fallback to the non platform specific variant. However,
the platform specific variants that have the same dependencies as the
non specific one can still be kept.

Do a pass to complete those after resolution.
2024-01-11 13:51:52 +09:00
David Rodríguez
7f0dbfc9c8 [rubygems/rubygems] Move resetting the spec set to where it becomes necessary
a8b547c6b1
2024-01-11 13:51:52 +09:00
David Rodríguez
51d2a8e983 [rubygems/rubygems] Extract a couple of helper methods
880a4eae7f
2024-01-11 13:51:52 +09:00
David Rodríguez
ab1936faf9 [rubygems/rubygems] Remove methods to clarify what they do
1d15d8a8ff
2024-01-11 13:51:52 +09:00
David Rodríguez
76916217b6 [rubygems/rubygems] Extract SpecSet#reset! helper
41f9b4d940
2024-01-11 13:51:52 +09:00
Hiroshi SHIBATA
82496f2b38 Merge RubyGems-3.5.2 and Bundler-2.5.2 2023-12-22 07:24:04 +09:00
David Rodriguez
c05495530e [rubygems/rubygems] Fix universal lockfiles regression
If a platform specific variant would not match the current Ruby, we would still be
considering it compatible with the initial resolution and adding its
platform to the lockfile, but we would later fail to materialize it for
installation due to not really being compatible.

Fix is to only add platforms for variants that are also compatible with
current Ruby and RubyGems versions.

75d1290843
2023-11-22 13:17:12 +00:00
David Rodríguez
435eb56f61 [rubygems/rubygems] Automatically lock extra ruby platforms
Since we started locking the specific platform in the lockfile, that has
created an annoying situation for users that don't develop on Linux.
They will create a lockfile on their machines, locking their local
platform, for example, darwin. But then that lockfile won't work
automatically when deploying to Heroku for example, because the lockfile
is frozen and the Linux platform is not included.

There's the chance though that resolving against two platforms (Linux +
the local platform) won't succeed while resolving for just the current
platform will. So, instead, we check other platform specific variants
available for the resolution we initially found, and lock those
platforms and specs too if they satisfy the resolution.

This is only done when generating new lockfiles from scratch, existing
lockfiles should keep working as before, and it's only done for "ruby
platforms", i.e., not Java or Windows which have their own complexities,
and so are excluded.

With this change, we expect that MacOS users can bundle locally and
deploy to Heroku without needing to do anything special.

5f24f06bc5
2023-11-13 11:06:10 +09:00
David Rodríguez
bd6aaa78c3 [rubygems/rubygems] Remove unused SpecSet#merge
53e0490b55
2023-11-13 11:06:10 +09:00
David Rodríguez
9f67118d7b
[rubygems/rubygems] Simplify selecting specs with force_ruby_platform set
5f90a43635

Co-authored-by: Martin Emde <martin.emde@gmail.com>
2023-11-08 09:04:28 +09:00
David Rodríguez
73ba4b76c2 [rubygems/rubygems] Automatically remove invalid platforms before re-resolving
40989271dd
2023-10-16 13:52:56 +09:00
Samuel Giddins
83f929316e [rubygems/rubygems] Fix force_ruby_platform: when the lockfile only locks the ruby platform
7c50064c3c
2023-10-15 04:46:32 +00:00
David Rodríguez
f3d69bed62
[rubygems/rubygems] Fix resolver hangs when dealing with an incomplete lockfile
While working on locking multiple platforms by default, I got an
infinite resolution loop in one of our resolver specs.

The culprit ended up being that when dealing with lockfile specs with
incomplete dependencies (spec appears in lockfile, but its dependencies
don't), those specs were not being properly expired and that tripped up
resolution.

The issue for some reason only manifests when dealing with multiple
lockfile platforms, that's why it only manifested when working on
locking multiple platforms by default.

4ca72913bb
2023-04-06 13:07:16 +09:00
David Rodríguez
c257380965
Revert "Refactor incomplete specs handling"
This reverts commit 69580f8b72f41c58cae57d1ada4db909922b3891.
2023-04-06 13:07:16 +09:00
David Rodríguez
192a3a6bfb
[rubygems/rubygems] Revert "Reuse SpecSet#materialize logic"
This reverts commit a20585b451.

aa9102659e
2023-04-06 13:07:16 +09:00
David Rodríguez
a757e21bc0 Reuse SpecSet#materialize logic 2023-03-23 17:18:49 +09:00
David Rodríguez
ebebc90ec2 Refactor incomplete specs handling
Recent bugs fixed made me realize we were relying on state too much
here. We only need to keep incomplete specs to be able to expire them
and retry resolution without them locked. If we use a separate class, we
can do that more transparently and handle them just like we handle
"missing specs".
2023-03-23 17:18:49 +09:00
David Rodríguez
8e6bbc032c Don't remove RUBY platform when healing a lockfile with missing specs 2023-03-23 17:18:49 +09:00
David Rodríguez
4e7c39f98c Don't remove RUBY platform when healing a lockfile with missing specs 2023-03-23 17:18:49 +09:00
David Rodríguez
8371c0eac4 [rubygems/rubygems] Fix incorrect error message when multiple platforms are locked
24d2bf9cb2
2023-03-17 18:50:55 +09:00
Ellen Marie Dash
d2d521b274 [rubygems/rubygems] Regenerate lockfile if spec list is invalid/empty.
d2c56315e2
2023-03-02 00:50:58 +00:00
Daniel Colson
62b3bcba5e [rubygems/rubygems] Auto-heal on corrupted lockfile with missing deps
Following up on https://github.com/rubygems/rubygems/pull/6355, which
turned a crash into a nicer error message, this commit auto-heals the
corrupt lockfile instead.

In this particular case (a corrupt Gemfile.lock with missing
dependencies) the LazySpecification will not have accurate dependency
information, we have to materialize the SpecSet to determine there are
missing dependencies. We've already got a way to handle this, via
`SpecSet#incomplete_specs`, but it wasn't quite working for this case
because we'd get to `@incomplete_specs += lookup[name]` and
`lookup[name]` would be empty for the dependency.

With this commit we catch it a bit earlier, marking the parent spec
containing the missing dependency as incomplete.

486ecb8f20
2023-03-01 02:50:40 +00:00
Hiroshi SHIBATA
f6620037ba Merge RubyGems-3.4.0 and Bundler-2.4.0 2022-12-24 16:57:07 +09:00
Hiroshi SHIBATA
0a9d51ee9d Migrate our resolver engine to PubGrub
https://github.com/rubygems/rubygems/pull/5960

  Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
2022-11-12 07:40:31 +09:00
David Rodríguez
a4860e043e [rubygems/rubygems] Remove unnecessary spec sorting
Specs in a SpecSet with the same name are only sorted by platform
priority when they are read. No need to sort everything eagerly.

aeafff52df
2022-09-12 22:13:28 +09:00