Commit graph

90 commits

Author SHA1 Message Date
David Rodríguez
78ef59acf7 [rubygems/rubygems] Refine messages about gem installations being missing
The previous wording was too specific, there may be situations when the
gem has actually never installed (so never deleted either).

e4a0d71fbe
2025-02-06 15:57:59 +09:00
David Rodríguez
ee7b74799c [rubygems/rubygems] Fix --prefer-local not respecting default gems
3df86cd9c6
2025-01-20 13:50:27 +09:00
David Rodríguez
3fdf0e7e6d [rubygems/rubygems] Fix specs with missing extensions getting activated
c80998a22a
2024-10-10 14:51:32 +00:00
David Rodríguez
f63873e7a2 [rubygems/rubygems] Remove more compatibility code with old RubyGems
74e8eff779
2024-10-10 14:51:32 +00:00
David Rodríguez
80e934c29c [rubygems/rubygems] Fix --local hitting the network when default gems are included
b9a2d4d539
2024-09-17 14:39:06 +09:00
David Rodríguez
2bfeedc082 [rubygems/rubygems] Simplify handling default gem caching
By the time `cached_gem` is called, default gem cache has already been
handled. So no need to try redownload it again, it's enough to check the
cache location directly.

70e10236b6
2024-09-16 13:13:43 +00:00
David Rodríguez
c9d2343f5c [rubygems/rubygems] Fix incorrect standalone script when default gems with extensions are used
55649cd09b
2024-07-18 18:07:09 +00:00
David Rodríguez
f7acfeb4ce [rubygems/rubygems] Fix credentials being readded when re-resolving without a full unlock
a8670e43f8
2024-06-20 07:15:06 +00:00
David Rodríguez
568132af16 [rubygems/rubygems] Keep credentials in lockfile if they are already there
So that those lockfiles still work with older Bundler versions.

880275bb66
2024-06-11 16:27:44 +00:00
David Rodríguez
939d389c54 [rubygems/rubygems] Improve default gem handling by treating default gems as any other gem
For backwards compatibility, make sure default gems are still used as a
last resort when materializing, in case no remote, cached, or installed
specs are found.

93788f689f
2024-05-29 13:55:25 +00: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
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
bc652d7568
[rubygems/rubygems] Never write credentials to lockfiles
e8a363713e
2024-04-18 11:07:09 +09:00
David Rodriguez
7b3ef370f8 [rubygems/rubygems] Fix incorrect bundle update --bundler message
146de56353
2024-03-22 13:14:42 +00:00
David Rodríguez
f3123f8af2 [rubygems/rubygems] Use rubygems vendored uri from Bundler when available
5d6a8f2fb4
2024-01-29 12:15:10 +09:00
David Rodríguez
b300f5a0e1
[rubygems/rubygems] Revert "Improve default gem handling"
This reverts commit 091b4fcf2b.

dcade3235f
2023-12-14 20:22:48 +08:00
David Rodríguez
ac939d9ca3 [rubygems/rubygems] Improve default gem handling
If a gem is specified in the Gemfile (or resolved as a transitive
dependency), it's always resolved from remote/installed sources. Default
gems are only used as a fallback for gems not included in the bundle.

I believe this leads to more consistent behavior and more portable apps,
since all gems will be installed to the configured bundle path,
regardless of whether they are default gems or not.

091b4fcf2b
2023-12-13 13:02:22 +09:00
David Rodríguez
2755cb1b2f [rubygems/rubygems] Use modern hashes consistently
bb66253f2c
2023-12-07 22:29:33 +00:00
Samuel Giddins
b69bbf588a [rubygems/rubygems] User bundler UA when downloading gems
Gem::RemoteFetcher uses Gem::Request, which adds the RubyGems UA.
Gem::RemoteFetcher is used to download gems, as well as the full index.
We would like the bundler UA to be used whenever bundler is making
requests.

This PR also avoids unsafely mutating the headers hash on the shared
`Gem::RemoteFetcher.fetcher` instance, which could cause corruption or
incorrect headers when making parallel requests. Instead, we create one
remote fetcher per rubygems remote, which is similar to the connection
segregation bundler is already doing

f0e8dacdec
2023-11-15 08:33:14 +00: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
Martin Emde
d43765c3a9 [rubygems/rubygems] Unify LockfileParser loading of SPECS section
Ensure unrecognized SPECS types are ignored

5b33e91075
2023-09-12 19:42:46 +00:00
Martin Emde
89cb95679d [rubygems/rubygems] Reduce excess index creation and merging
When @allow_cached is true, @allow_local is always true,
therefore, the #installed_specs will always be merged after #cached_specs
is called. This makes starting with installed_specs.dup redundant.

When #cached_specs is called because @allow_remote is true and
@allow_cached is false, then installed_specs will be added after
cached_specs based on @allow_local.

We never need to add installed_specs here, so don't.

49b38f9750
2023-09-07 00:33:29 +00:00
Martin Emde
86b93f7481 [rubygems/rubygems] Improve efficiency of Index#use and #search_all
Rename Index#use(override = true) to #merge!

Rename Index @all_specs to @duplicates, it is not actually all specs.
@duplicates only holds specs that would have been overridden during a call to
Index#use or Index#merge!

Reduced dupes in @duplicates by not double adding the new spec to the
index and the @duplicates during #merge!

Reduce Array creation by using specialized methods when the one result
or no results are needed from the search.

47e91125db
2023-09-07 00:33:28 +00:00
Martin Emde
af1bedbbd9 [rubygems/rubygems] Source::Rubygems#fetch_names is only called with override = false
790202691d
2023-09-07 00:33:28 +00:00
David Rodríguez
2edf9fa23a [rubygems/rubygems] Remove redundant checks
d66815633b
2023-08-28 11:15:34 +09:00
David Rodríguez
279dcfab7a [rubygems/rubygems] Fix standalone install crashing when using legacy multi remote gemfiles
If a legacy multi remote Gemfile depends transitively on a default gem,
then in standalone mode we'd fail to fetch the proper version from the
source that includes it, since we were adding it to `specs` (instead of
`remote_specs`), which was already including the default version of the
gem, and thus preventing the remote version from "overwriting that" and
being added to the index. We should add it to the `remote_specs` index
directly instead.

05f4f9dfc0
2023-08-28 11:15:33 +09:00
Martin Emde
7bf5f78028 [rubygems/rubygems] Refactor Fetcher#api_fetcher? and fetcher loading logic
f664d60114
2023-08-28 11:15:32 +09:00
David Rodríguez
023b8ddd22
[rubygems/rubygems] Don't use full indexes unnecessarily on legacy Gemfiles
On legacy Gemfiles with multiple remote sources, where all of them
support the compact index API, we were still falling back to full
indexes.

Fixing this also allows to simplifying the code.

b1357c8e72
2023-08-25 18:34:47 +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
Hiroshi SHIBATA
1edbaa850f Merge rubygems/rubygems HEAD
Pick from 880dd95996
2023-06-20 13:35:13 +09:00
David Rodríguez
79e8d91410 [rubygems/rubygems] Delay cache access in LockfileParser
It's the only part that needs "root folder resultion" to figure out the
folder for the cache, but it's only needed for some things, so run that
logic lazily when needed.

c7b9eae0bc
2023-06-06 10:52:57 +09:00
David Rodríguez
4df7c3946a [rubygems/rubygems] Remove one fallback to full indexes on big gemfiles
If Gemfile has a lot of dependencies, we have an optimization that uses
the full index in that case, assuming it's going to be faster.

I think this is an old optimization that predates compact index API
times, I believe we no longer need it these days.

Also, since a few releases ago we check for circular dependencies when
resolving by looping through all versions of each name and removing
those that have circular dependencies that would trip up the resolver.

This loop becomes actually very slow when full indexes are used because
to find dependencies of a gemspec, we need to explicitly fetch the
marshaled gemspec (`gemspec.rz` endpoint) for it, so the optimization
has the opposite effect of making things very slow.

2f46289bd3
2023-04-07 13:53:00 +00:00
David Rodríguez
ddc4fd5644 Normalize git sources
Just like gem sources, a "style-only" change, like adding a trailing
slash, should not expire them.
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
d3822c9a8a Merge RubyGems/Bundler master.
Pick from 5ace20dbec
2023-01-31 10:49:08 +09:00
Hiroshi SHIBATA
bbe56a6437 Merge RubyGems/Bundler master
from bfb0ae6977
2022-12-12 10:49:43 +09:00
David Rodríguez
24fd2f73d0 Resync Bundler & RubyGems 2022-09-08 11:25:03 +09:00
Hiroshi SHIBATA
3eca1e438d Merge 16c3535413 2022-09-05 14:37:12 +09:00
David Rodríguez
7b78aba53a [rubygems/rubygems] Account for default gems not having remote when caching
b93d4de2ff
2022-07-02 19:41:02 +09:00
David Rodríguez
9101269e94 [rubygems/rubygems] Move rubygems source specific logic to rubygems source
6aa4c422a7
2022-07-02 19:41:02 +09:00
David Rodríguez
4f5eb48dea [rubygems/rubygems] Fix bundle package --no-install no longer skipping install
This is a regression from cf749f8ffa. The
funny thing is that we have a spec for this feature, so it was unclear
how we regressed here. It turns out there was a bug in one of our
negative matchers checking that gems ARE NOT included in a bundle.

This commit fixes the bug in the negative matcher and reverts
cf749f8ffa (with a slightly simpler diff).

3f9a4ff32a
2022-06-23 18:17:08 +09:00
David Rodríguez
7f9eb888a3 [rubygems/rubygems] Reuse package from the installer for extracting the specification
Previously we would instantiate two different packages and extract the
specification from the package twice for each gem installed. We can
reuse the installer for this so that we just need to do it once.

e454f850b1
2022-06-11 18:43:28 +09:00
David Rodríguez
965c314e34 [rubygems/rubygems] Move security exception handling to the only place using it
ba975b3b7f
2022-06-11 18:43:27 +09:00
David Rodríguez
bf8dc36e40 [rubygems/rubygems] Swapping should not raise any errors
600a9ac658
2022-06-11 18:43:27 +09:00
David Rodríguez
6292b36529 [rubygems/rubygems] Remove unclear comment
This is the explanation of why we do the swapping, not of why we
download the gem.

1a25eb7e7b
2022-06-11 18:43:26 +09:00
David Rodríguez
52cc76d134 [rubygems/rubygems] Gem::Specification.loaded_from is already set by the installer
796eebfdbf
2022-06-11 18:43:26 +09:00
David Rodríguez
22c97ab8ae [rubygems/rubygems] Refactor some more duplicated logic
9bd389e1b6
2022-06-11 18:43:25 +09:00
David Rodríguez
95f5194b3c [rubygems/rubygems] Move no_install setting check to a more sensible place
It's only related to the `bundle cache` command, so it should be checked
there.

cf749f8ffa
2022-06-11 18:43:25 +09:00
David Rodríguez
3f69774b76 [rubygems/rubygems] No need to redownload if package already there
285ccbc07e
2022-06-11 18:43:24 +09:00
David Rodríguez
a9077af75b [rubygems/rubygems] No need to overwrite path when there's a remote
d86fb2c316
2022-06-11 18:43:24 +09:00