Commit graph

157 commits

Author SHA1 Message Date
David Rodríguez
e7d845b1d0
[rubygems/rubygems] Restore using old way of passing Ruby version to resolver
We used `Bundler::RubyVersion.system.gem_version` for a long time, but I
changed this to `Gem.ruby_version` at
94f9643943. It's unclear why I did that
though since I believe it was unrelated to the fix in there.

Bootboot patches `Bundler::RubyVersion` to customize how Bundler works
with Ruby versions, and that change broke that.

Since it's unclear to me how to achieve what Bootboot is doing with the
current code, and there was no strong reason for the change, let's
restore it for now.

8ec36c6017
2023-10-23 13:59:01 +09:00
Martin Emde
c667de72ff
[rubygems/rubygems] Improve errors and register checksums reliably
Improve error reporting for checksums, raises a new error class.

Solve for multi-source checksum errors.

Add CHECKSUMS to tool/bundler/(dev|standard|rubocop)26_gems.rb

26ceee0e76

Co-authored-by: Samuel Giddins <segiddins@segiddins.me>
2023-10-23 13:59:01 +09:00
Martin Emde
6362bfdc33
[rubygems/rubygems] rename Index#== to Index#subset?
a96a561087
2023-10-23 13:59:01 +09:00
Martin Emde
92f23a48e3
[rubygems/rubygems] Refactor Checksum classes and methods to reduce
code.
(https://github.com/rubygems/rubygems/pull/6917)

2238bdaadc
2023-10-23 13:59:01 +09:00
Samuel Giddins
c5fd94073f
[rubygems/rubygems] Refactor to checksums stored via source
This gets the specs passing, and handles the fact that we expect
checkums to be pinned only to a particular source

This also avoids reading in .gem files during lockfile generation,
instead allowing us to query the source for each resolved gem to grab
the checksum

Finally, this opens up a route to having user-stored checksum databases,
similar to how other package managers do this!

Add checksums to dev lockfiles

Handle full name conflicts from different original_platforms when adding checksums to store from compact index

Specs passing on Bundler 3

86c7084e1c
2023-10-23 13:59:01 +09:00
Mercedes Bernard
69d7e9a12e
[rubygems/rubygems] Use the server checksum, then calculate from gem on disk if possible
1. Use the checksum provided by the server if provided: provides security
knowing if the gem you downloaded matches the gem on the server

2. Calculate the checksum from the gem on disk: provides security knowing
if the gem has changed between installs

3. In some cases, neither is possible in which case we don't put anything
in the checksum and we maintain functionality as it is today

Add the checksums to specs in the index if we already have them

Prior to checksums, we didn't lose any information when overwriting specs
in the index with stubs. But now when we overwrite EndpointSpecifications
or RemoteSpecifications with more generic specs, we could lose checksum
info. This manually sets checksum info so we keep it in the index.

de00a4f153
2023-10-23 13:59:01 +09:00
Thong Kuah
ad08674d8d
[rubygems/rubygems] Add CHECKSUMS for each gem in lockfile
We lock the checksum for each resolved spec under a new CHECKSUMS
section in the lockfile.

If the locked spec does not resolve for the local platform, we preserve
the locked checksum, similar to how we preserve specs.

Checksum locking only makes sense on install. The compact index
information is only available then.

bde37ca6bf
2023-10-23 13:59:01 +09:00
David Rodríguez
73ba4b76c2 [rubygems/rubygems] Automatically remove invalid platforms before re-resolving
40989271dd
2023-10-16 13:52:56 +09:00
David Rodríguez
a1c73f1c88 [rubygems/rubygems] Consistent usage of local_platform in Definition
5f28a68d79
2023-10-16 13:52:55 +09:00
David Rodriguez
cbf2e133c1
Re-resolve when lockfile is invalid
Move the check for unmet dependencies in lockfile just in time to be
able to re-resolve if unmet dependencies are found.
2023-10-16 13:49:49 +09:00
Ry Biesemeyer
bece880874 [rubygems/rubygems] Centralize logic using Pathname#relative_path_from
To avoid potential crashes when trying to jump from a drive to another
on Windows, and take the change refactor things a bit.

7c9a9a431a
2023-09-27 05:20:58 +00:00
David Rodríguez
2e04336b67
[rubygems/rubygems] Fix git source conservativeness
9a0e0dfd5b
2023-08-16 15:03:38 +09:00
David Rodríguez
4a3777bf6b
[rubygems/rubygems] Extract s.name to a variable
689c39b42f
2023-08-16 15:03:38 +09:00
David Rodríguez
e92ace6be7
[rubygems/rubygems] Remove unneeded stuff
This should be only for path sources, and unrelated to git.

0d8f31eeed
2023-08-16 15:03:38 +09:00
David Rodríguez
7bb3e637ff
[rubygems/rubygems] Don't update locked sources when not necessary
cfc82b592a
2023-08-16 15:03:38 +09:00
David Rodríguez
c57ab646cb
[rubygems/rubygems] Extract a default_source method
784e08348e
2023-08-16 15:03:38 +09:00
David Rodríguez
002165f8fe
[rubygems/rubygems] Move lockfile_source variable out of condition branch
efebc64250
2023-08-16 15:03:38 +09:00
David Rodríguez
6bc63ab9bb
[rubygems/rubygems] Refactor locked dep filtering more
We only need to check whether the spec if for a direct dependency once.

65b455a5cb
2023-08-16 15:03:38 +09:00
David Rodríguez
86492fca65
[rubygems/rubygems] Avoid unnecessary loop through dependencies
2ab63bb94d
2023-08-16 15:03:38 +09:00
David Rodríguez
8c82b35791
[rubygems/rubygems] Exclude Bundler from missing locked dependencies check
Bundler is special since it's not actually locked in the lockfile as a
regular gem (only via `BUNDLED WITH`). So exclude it from that check.

9f1756ec47
2023-07-24 15:03:15 +09:00
David Rodríguez
0ae2709dd7 [rubygems/rubygems] When printing frozen errors, print only Gemfile information
93f74abc5f
2023-07-04 14:54:25 +09:00
David Rodríguez
0fcb4c6af7 [rubygems/rubygems] Fix another incorrect removal of "ruby" platform from lockfile
When dependencies in path sources have changed, we'll be re-resolving,
and we can't really know whether the resolution will be valid or invalid
for the Ruby platform, so skip the removal in that case.

afc3b0956f
2023-07-04 14:54:25 +09:00
Hiroshi SHIBATA
1edbaa850f Merge rubygems/rubygems HEAD
Pick from 880dd95996
2023-06-20 13:35:13 +09:00
David Rodríguez
3e7f5b02ae [rubygems/rubygems] Improve error message in frozen mode edge case
When a top level dependency is missing from the lockfile, and we're in
frozen mode, we should also print a "frozen error".

3e82b835e3
2023-06-15 07:01:25 +09:00
David Rodríguez
e86f4c581b [rubygems/rubygems] Improve frozen mode error message
This error message is also printed when using `bundler/setup` in frozen
model, so we're not necessarily installing any gems when it happens.

This new message play nicer with all situations.

6874bbacce
2023-06-15 07:01:25 +09:00
David Rodríguez
23ecaab8dd [rubygems/rubygems] Use "frozen" rather than "deployment" in error message
I think it communicates better what's going on.

07a25767a4
2023-06-15 07:01:24 +09:00
David Rodríguez
2ff9b7b93d [rubygems/rubygems] Show missing spec in lockfile incomplete error message
b86caaa3d5
2023-06-15 07:01:24 +09:00
David Rodríguez
21238f38a8 [rubygems/rubygems] Extract Definition#no_resolved_needed?
1ff8626571
2023-06-15 07:01:23 +09:00
David Rodríguez
4f1b1817a8 [rubygems/rubygems] There should always be a reason
4180008c2d
2023-06-15 07:01:23 +09:00
David Rodríguez
c12168185e [rubygems/rubygems] Show relative path to Gemfile in error message
For conciseness and consistency with printing the relative path to the
lockfile just before.

74cf6aea7c
2023-06-15 07:01:22 +09:00
David Rodríguez
e7749c4dea [rubygems/rubygems] Remove weird line breaks in the middle of error message
22b8caf42f
2023-06-15 07:01:21 +09:00
David Rodríguez
90c60e8138 [rubygems/rubygems] Simplify checking Gemfile vs lockfile sources
251e80aec6
2023-06-15 07:01:21 +09:00
David Rodríguez
96e3f31c1e [rubygems/rubygems] Make frozen mode spec also pass on Bundler 3
ad52f840f2
2023-06-15 07:01:20 +09:00
David Rodríguez
1f9e66836b [rubygems/rubygems] Fix inline mode with multiple sources
If we're in inline mode, Bundler first resolves using only local gems,
and if some gems are missing, then it re-resolves using remote gems.
However, "source resolution" from the initial "local" try was being
memoized, resulting in Bundler not looking for some gems remotely in the
second resolution.

This commit forces a proper re-resolve in this case.

fdc631075e
2023-06-06 10:52:53 +09:00
Hiroshi SHIBATA
4bbeed6134 Merge RubyGems/Bundler master from 4076391fce5847689bf2ec402b17133fe4e32285 2023-05-30 21:50:07 +09: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
674c960513 [rubygems/rubygems] Fix incorrect removal of "ruby" platform from lockfile
When dependencies have changed, we'll be re-resolving, and we can't
really know whether the resolution will be valid or invalid for the Ruby
platform, so skip the removal in that case.

The fix worked, but made some other specs fail, and surfaced that the
`@dependencies_changed` attribute was actually being incorrect set when
explicitly unlocking. Fixed that with an early return.

20d8f5e5d9
2023-03-28 15:25:42 +09:00
David Rodríguez
eaddd386ec [rubygems/rubygems] Also set min locked requirements when not unlocking
3561ac23d6
2023-03-28 15:25:40 +09:00
Hiroshi SHIBATA
d3822c9a8a Merge RubyGems/Bundler master.
Pick from 5ace20dbec
2023-01-31 10:49:08 +09:00
Hiroshi SHIBATA
a43f1d90c2 Merge RubyGems and Bundler master
from 0635c1423d
2023-01-10 15:53:07 +09:00
Hiroshi SHIBATA
b7ad60a794 Merge RubyGems/Bundler master
from 72fd3dd209
2022-12-26 15:09:21 +09:00
Hiroshi SHIBATA
f6620037ba Merge RubyGems-3.4.0 and Bundler-2.4.0 2022-12-24 16:57:07 +09:00
David Rodríguez
3fd33590f6 [rubygems/rubygems] Fix crash when lockfile is missing dependencies
We have a check for a corrupt lockfile right before installing. However,
the check accounted for locked specs not satisfying locked dependencies,
but not for locked specs missing for some locked dependencies.

Instead of fixing this check, I decided to remove it in favor of
automatically detecting the situation and re-resolve to automatically
fix the lockfile rather than printing a warning but leave the problem
there.

4a7a584252
2022-12-20 13:15:02 +09:00
David Rodríguez
16b36a5b0c [rubygems/rubygems] Remove unused code
b88c43a28c
2022-12-20 13:15:02 +09:00
Hiroshi SHIBATA
bbe56a6437 Merge RubyGems/Bundler master
from bfb0ae6977
2022-12-12 10:49:43 +09:00
Hiroshi SHIBATA
a4e14b9d9d Merge RubyGems/Bundler master
Pick from 823c776d95
2022-12-09 16:36:22 +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
Hiroshi SHIBATA
28611be6ee Merge RubyGems/Bundler master from ee2f8398324af4bc1b95f7565ce2fda98126e026 2022-11-11 17:24:08 +09:00
Hiroshi SHIBATA
f5df47d1f3 Merge RubyGems/Bundler master
6214d00b23
2022-10-18 16:33:15 +09:00
David Rodríguez
67de00053a [rubygems/rubygems] Inline helper method
e60459d6b6
2022-10-18 16:33:15 +09:00