Commit graph

82 commits

Author SHA1 Message Date
Randy Stauner
b5beb19825 [rubygems/rubygems] Validate dependencies when doing bundle install
b0983f392f
2025-06-11 08:48:55 +09:00
Samuel Giddins
c0a1e877b3
Move most of Bundler::GemHelpers to Gem::Platform
This will help centralize wheel platform selection logic eventually

Signed-off-by: Samuel Giddins <segiddins@segiddins.me>
2025-06-06 10:22:18 +09:00
David Rodríguez
c910e85b02 [rubygems/rubygems] Extract some logic to a method and expand comment
ed31e888fd
2025-04-15 16:47:19 +09:00
David Rodríguez
0ad7cf17a0 [rubygems/rubygems] Clarify comment
42534e746b
2025-04-15 16:47:19 +09:00
David Rodríguez
806fbb1e47 [rubygems/rubygems] Comparing platforms is only needed for dependency validation
If we materialized to a different platform, then the dependencies may
actually be different so the validation does not really make sense.

68fad98e6f
2025-04-15 16:47:18 +09:00
David Rodríguez
3cb573ee55 [rubygems/rubygems] Only platforms are relevant here
4b6f07f634
2025-04-15 16:47: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
5bff692346 [rubygems/rubygems] Refactor replacing locked specification path sources
Instead of doing an explicit pass, let sources be replaced while checking
if specifications are up to date.

676271e804
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
David Rodríguez
e7720ef8d7
[rubygems/rubygems] Materializing specs for vendor/cache should not be strict
Platforms specific gems not compatible with the current Ruby should not
make `bundle cache` fail and should not get removed from the cache since
they still may be useful in other rubies.

717b43f565
2025-02-13 09:37:50 +09:00
David Rodríguez
5adbad731b
[rubygems/rubygems] Move logic to materialize gems for cache to a new method
And make the current `materialize_strictly` private.

3fc2129147
2025-02-13 09:37:50 +09:00
David Rodríguez
06e3943c38
[rubygems/rubygems] Remove unnecessary source change
We materializing for installation, we already do this, and we
materializing for cache, it does not seem necessary.

1a983c6cbc
2025-02-13 09:37:50 +09:00
David Rodríguez
bb764e42ba
[rubygems/rubygems] Extract some common materialization logic to a method
32982fcd33
2025-02-13 09:37:50 +09:00
David Rodríguez
7ac29372ca
[rubygems/rubygems] Make LazySpecification#__materialize__ private
And rename it to something better.

321174d1ad
2025-02-13 09:37:50 +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
6386d49f9e [rubygems/rubygems] Fix development dependencies considered unnecessarily sometimes
When used with `LazySpecification` objects, `SpecSet#for` was
incorrectly considering development dependencies. This did not cause any
issues because all usages of this method with `LazySpecification`'s are
not strict, meaning the pass `check = false` and ignore incomplete
specifications. But it was still doing more work than necessary because
development dependencies were still added to the `deps` array for
processing and then ignored because of not being found in the spec set.

Same when converging path specifications and replacing their dependencies.

6afca8a95f
2024-11-26 15:11:05 +09:00
David Rodríguez
b56aacba78 [rubygems/rubygems] Define a few inspect methods to help debugging
ad26ccde38
2024-11-19 16:50:04 +00:00
David Rodríguez
10d694a1ff [rubygems/rubygems] Warn on insecure materialization
bc2537de71
2024-11-08 12:06:32 +00:00
David Rodríguez
7f2db15732 [rubygems/rubygems] Small tweak
98641d21a2
2024-11-08 12:06:30 +00:00
David Rodríguez
4d83f37ff7 [rubygems/rubygems] Reduce global state
43c0c41c6b
2024-11-08 12:06:30 +00:00
David Rodríguez
c79d236493 [rubygems/rubygems] Note about why we don't fix lockfile dependencies backed by installed specs
6fa94b5d72
2024-11-06 13:16:58 +00:00
David Rodríguez
54f6b787e3 [rubygems/rubygems] Automatically fix lockfile when the API reveals missing deps
92196ccfdb
2024-11-06 13:16:57 +00:00
David Rodríguez
db7455ae65 [rubygems/rubygems] Check for EndpointSpecification exactly
8fac200ded
2024-11-06 13:16:56 +00:00
David Rodríguez
3e7a43e5e8 [rubygems/rubygems] Simplify code structure
a4dd06f095
2024-11-06 13:16:56 +00:00
David Rodríguez
def5fdf82a [rubygems/rubygems] Delay and refactor verification of changed sources
d5dce93167
2024-10-16 21:57:51 +00:00
Cody Cutrer
94e1d3f3fa [rubygems/rubygems] include MatchMetadata in Bundler::LazySpecification
I'm running into a case in my plugin where matches_current_metadata? is
getting called on a lazy specification, and adding this fixes it

24f962cb42
2024-01-11 04:19:13 +00:00
Hiroshi SHIBATA
82496f2b38 Merge RubyGems-3.5.2 and Bundler-2.5.2 2023-12-22 07:24:04 +09:00
David Rodríguez
2755cb1b2f [rubygems/rubygems] Use modern hashes consistently
bb66253f2c
2023-12-07 22:29:33 +00: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
f273132bc0 [rubygems/rubygems] Extract builder to create a LazySpecification from full spec
957d3d9a7f
2023-11-13 11:06:10 +09:00
David Rodríguez
636b70d2a6 [rubygems/rubygems] Allow setting metadata on LazySpecification
This is a step forward towards eventually including metadata in the
lockfile.

56fc02b251
2023-11-13 11:06:10 +09:00
David Rodríguez
ea7cde64fb [rubygems/rubygems] Set LazySpecification dependencies directly
2462c8e04d
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
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
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
Josef Šimánek
9cfd8330ca [rubygems/rubygems] Onboard Rubocop Naming/MemoizedInstanceVariableName rule to Bundler.
d768be0c65
2023-03-28 15:25:44 +09:00
David Rodríguez
a9fd1860dd Fix flaky when making materialized specs uniq
Sometimes we'll have an heterogenous array of specs which include
`Gem::Specification` objects, which don't define `#identifier`. Let's
use `#full_name` consistently.
2023-03-23 17:18:49 +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
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
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
cb63a3f4c1 [rubygems/rubygems] Materialize platforms strictly on Windows too
ab11545f80
2022-10-18 16:33:15 +09:00
David Rodríguez
4d3dbbe77e [rubygems/rubygems] Remove unnecessary receiver
ba9d9b1890
2022-10-18 16:33:15 +09:00
Hiroshi SHIBATA
f69244cee8 Merge rubygems/bundler HEAD
Pick from 6b3a5a9ab0
2022-08-23 10:45:57 +09:00
David Rodríguez
b30fc03e92 [rubygems/rubygems] Centralize loading Bundler::MatchPlatform mixin
It's explicitly loaded when monkeypatching RubyGems, which we do very
early. So neither autoloading it, nor explicitly loading it anywhere
else is necessary.

fbc7a57161
2022-08-23 10:45:57 +09:00