Commit graph

82 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
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
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
David Rodríguez
bb1b5877a7 [rubygems/rubygems] Consistently use "lockfile" over "lock file"
e891be9197
2025-03-24 13:25:07 +09:00
David Rodríguez
91a17fbbad
[rubygems/rubygems] Use preferred :windows value for Windows exclusively
aee52d2874

Co-authored-by: johnnyshields <27655+johnnyshields@users.noreply.github.com>
2025-02-14 16:13:27 +09:00
David Rodríguez
d8394461fd [rubygems/rubygems] Support installing arm native gems on Windows
96496e3f53

Co-authored-by: Johnny Shields <johnny.shields@gmail.com>
2025-01-28 15:31:53 +09:00
David Rodríguez
09b04fefb7 [rubygems/rubygems] Remove unnecessary platform helpers
I think they add unnecessary indirection and inconsistency to the specs.

609924d985
2025-01-28 15:31:49 +09:00
David Rodríguez
22359cda1c [rubygems/rubygems] Refactor specs to use platform strings directly
d24c0c20e3
2025-01-28 15:31:47 +09:00
David Rodríguez
0b1b8bc3ec [rubygems/rubygems] Don't remove platform specific variants from the lockfile unless necessary
Even if they don't match the current Ruby version, they could still work
in other rubies. So it's better to keep them.

9a3e583b0c
2025-01-14 12:24:37 +09:00
David Rodríguez
10d694a1ff [rubygems/rubygems] Warn on insecure materialization
bc2537de71
2024-11-08 12:06:32 +00:00
David Rodríguez
7cb0bb43b9 [rubygems/rubygems] Fix typo
f68a2c30bb
2024-11-08 12:06:31 +00:00
David Rodríguez
8869c3117a [rubygems/rubygems] Simplify tests that deal with lockfile using only "ruby" platform
Using an old bundler version was necessary at the beginning because we
checked the version of Bundler being run in order to enable the new
behavior. But we removed that a long time ago and now we only look at
whether the lockfile only includes "ruby" as a platform or not.

8fc3d38ff3
2024-11-08 12:06:31 +00:00
David Rodríguez
88fa4fe589 [rubygems/rubygems] Make sure platforms in spec lockfile are properly sorted
99b4ac4548
2024-11-08 12:06:28 +00:00
David Rodríguez
a4938e5bc0 [rubygems/rubygems] Add missing spec for materializing lockfiles with only "ruby" platform
4168a7f488
2024-11-06 13:16:57 +00:00
David Rodríguez
481c83453b [rubygems/rubygems] Enable checksums on Bundler 3 for fresh lockfiles
And get specs passing.

c23b5f5b84
2024-07-23 19:40:09 +00:00
David Rodríguez
b0a0eda231 [rubygems/rubygems] Normalize a few specs using sources
Use the standard sources to avoid having to explictly pass ENV with the repo.

95055dba57
2024-07-23 19:40:08 +00:00
David Rodríguez
d62af8e513 [rubygems/rubygems] Fix another removal issue
I failed to ignore (again) specs only considered for resolution under
some platforms that are not the current one.

b72deec57e
2024-07-18 18:08:37 +00:00
David Rodríguez
b07c77730b [rubygems/rubygems] Simplify spec assertion
All that we expect here is no changes.

ff984b6133
2024-07-18 18:08:36 +00:00
David Rodríguez
140d8318db [rubygems/rubygems] Fix generic platform gems getting incorrectly removed when locked for a specific platform
If they are already in the lockfile as the most specific variant for a
platform, we shouldn't change that unless explicitly unlocking.

a901660498
2024-07-09 16:34:09 +00:00
David Rodríguez
1d97c46b35 [rubygems/rubygems] Minor Bundler spec improvements
While working on something else I noticed:

* Usage of uppercased "RUBY" and "JAVA" as platforms, when those don't
  really exist.
* Usage of some test gems with "1.0" as gemspec version and "1.0.0" as
  actual version.

This commit fixes both inconsistencies to make things more expectable.

e3ec32e247
2024-07-09 14:43:18 +00:00
Jerome Dalbert
bbb4da78c7 [rubygems/rubygems] Use preferred add_dependency instead of add_runtime_dependency
9a08043858
2024-07-05 02:24:53 +00:00
David Rodríguez
98c923ff4b
Synchronize Bundler & RubyGems (#11071) 2024-06-28 10:12:29 -04:00
David Rodríguez
bf6b8dd6a8 [rubygems/rubygems] Fix bundle update <gem_name> edge case
When locked only to RUBY, and some locked spec does not meet locked
dependencies, Bundler would remove the only locked platform and end up
creating a lockfile with empty sections.

We can't rely on our criteria to remove invalid platforms if locked
specs are not valid in the first place.

1dba05cf53
2024-06-20 07:14:47 +00:00
David Rodríguez
758e01d39d [rubygems/rubygems] Make sure to not re-resolve when a not fully specific local platform is locked
36a02c6128
2024-06-20 15:21:08 +09:00
David Rodríguez
c6a28b02c9 [rubygems/rubygems] Always resolve against the local platform
If RUBY is the only platform in the lockfile, we were skipping adding
the local platform to the list of resolution platforms. This generally
works anyways, because we had some code to still add it if the RUBY
platform is not valid for the set of locked gems.

However, sometimes it can happen that "RUBY" is valid for the current
set of locked gems, but when adding a new dependency, it becomes
invalid. For example, when adding sorbet to a Gemfile, that will
introduce `sorbet-static` as an indirect dependency which does not have
a generic "RUBY" variant. This will cause resolution to take a long time
continuously backtracking trying to find solutions that don't introduce
`sorbet-static` as a dependency and will eventually fail.

Instead, we can always add the local platform to the set of resolution
platforms before resolving, and remove it as necessary after resolution
so that we lock the correct set of platforms.

6ed1fe6050
2024-06-20 15:20:57 +09:00
David Rodríguez
eef125fd09 [rubygems/rubygems] Fix error messages to not mention cached gems when they were not used
5ce9a7ff17
2024-05-24 15:02:30 +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
7b3ef370f8 [rubygems/rubygems] Fix incorrect bundle update --bundler message
146de56353
2024-03-22 13:14:42 +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
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
Martin Emde
5f0ea3f590 [rubygems/rubygems] Converts Bundler lockfile checksum validation to opt-in only
Looks for the CHECKSUMS section in the lockfile, activating the feature
only if the section exists. Without a CHECKSUMS section, Bundler will
continue as normal, validating checksums when gems are installed while
checksums from the compact index are present.

2353cc93a4
2023-12-05 21:09:53 +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
Bo Anderson
57fa69f26f [rubygems/rubygems] Fix invalid platform removal missing adjacent platforms
4ce66c41a2
2023-11-21 19:11:15 +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 Rodriguez
59b361aaca [rubygems/rubygems] Refactor platform test helpers
7ab4c203f9
2023-11-13 11:06:10 +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
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
Hiroshi SHIBATA
1edbaa850f Merge rubygems/rubygems HEAD
Pick from 880dd95996
2023-06-20 13:35:13 +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
2d8b55fcd2 [rubygems/rubygems] Simplify lockfile_platforms helper
To make it easier to change the default platforms that get locked later.

255c4012ec
2023-03-17 18:50:55 +09:00
John Hawthorn
4064e3e776 [rubygems/rubygems] Update pub_grub
* Replaces the wording of "is forbidden" with "cannot be used"
* Fixes the method signature of VersionRange::Empty#eql?

8c6b3f130b

Co-authored-by: Daniel Colson <danieljamescolson@gmail.com>
2023-02-21 19:28:12 +09:00
Hiroshi SHIBATA
d3822c9a8a Merge RubyGems/Bundler master.
Pick from 5ace20dbec
2023-01-31 10:49:08 +09:00
Mike Dalessio
927141a555 [rubygems/rubygems] Add test for old lockfile with new ruby version
Given an existing application using native gems (e.g., nokogiri)
And a lockfile generated with a stable ruby version
When we test the application against ruby-head and `bundle install`
Then bundler should fall back to the generic ruby platform gem

Note that this test has been passing since 45931ac9

0ecc6de378
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
a4e14b9d9d Merge RubyGems/Bundler master
Pick from 823c776d95
2022-12-09 16:36:22 +09:00