Commit graph

94 commits

Author SHA1 Message Date
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
c65d7b4bea When running bundle lock --update <name>, checkout locked revision of unrelated git sources directly
Since Bundler 2.4, we will try to checkout any branch specified in the
Gemfile, while until Bundler 2.3 we would directly checkout the locked
revision.

This should not make any difference in most situations, but in some edge
cases, like if the branch specified in the `Gemfile` has been renamed,
but the locked revision still exist, it causes an error now while before
it would update the lockfile without issues.

I debated which behavior was best, since I was not sure. But my
conclusion is that if the situation does not require expiring the
lockfile source in favor of the Gemfile source, we should use the locked
revision directly and proceed happily. So I restored Bundler 2.3
behavior.

I think this is consistent with how yanked gems are handled, for example.

Of course, if explicitly updating the git source itself, or all gems, we
will still get any errors like missing branches related to the git source.
2023-03-17 18:50:55 +09: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
Julie Haehn
c5296d9396 [rubygems/rubygems] Respect --no-install option for git: sources
Currently, the --no-install option to `bundle package` is totally
ignored for git sources. This can have very strange effects if you have:

- a git-sourced gem,
- with native extensions,
- whose extconf.rb script depends on another gem,
- which is installed from Rubygems in the gemfile.

In that circumstance, `bundle package --no-install --all` will download
the Rubygems dependencies to `vendor/cache` but NOT install them. It
will also check out the git gems to `vendor/cache` (good), and attempt
to build their native extensions (bad!).

The native extension build will fail because the extconf.rb script crashes,
since the dependency it needs is missing.

I implemented a fix for this in `source/git.rb`, since this is analogous
to what's happening in `source/rubygems.rb`. I do admit though the whole
thing is a little strange though - an "install" method that.... proceeds
to look at a global flag to not install anything.

Add test to confirm cache respects the --no-install flag

5a77d1c397

Co-authored-by: KJ Tsanaktsidis <kj@kjtsanaktsidis.id.au>
2023-03-07 22:36:36 +00:00
David Rodríguez
a47e1328e6 [rubygems/rubygems] Give a better message when Gemfile branch does not exist
cb4fc41cbc
2023-02-21 19:28:12 +09:00
David Rodríguez
e7bf85961d [rubygems/rubygems] Restore better error message when locked ref does not exist
c8e024359f
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
Hiroshi SHIBATA
a43f1d90c2 Merge RubyGems and Bundler master
from 0635c1423d
2023-01-10 15:53:07 +09:00
David Rodríguez
8f05e4f54b Update Bundler to 2.4.1 & and RubyGems to 3.4.1 2022-12-25 05:55:36 +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
18ba89093a Merge RubyGems/Bundler master
Pick from ba3adad4d8
2022-12-20 13:15:02 +09:00
Hiroshi SHIBATA
49b0f3b024 Merge RubyGems/Bundler master
Pick from 084f7d1f21
2022-12-15 19:06:40 +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
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
Hiroshi SHIBATA
bfd09b1116 Merge rubygems master from 446cc57a7c 2022-07-29 15:46:15 +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
12a5fa408b Sync RubyGems & Bundler with upstream repo 2022-06-24 10:52: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
David Rodríguez
4a75849680 [rubygems/rubygems] Remove unnecessary spec.remote guard
It's checked before calling the method already.

4eb00e9586
2022-06-11 18:43:22 +09:00
David Rodríguez
d5288c8aad [rubygems/rubygems] Refactor ambiguous gems check
a00c79a4da
2022-06-11 18:43:22 +09:00
David Rodríguez
ea31c5bcd1 [rubygems/rubygems] Fix crash when installing gems with symlinks
If BUNDLE_PATH is configured to a symlinked path, installing gems with
symlinks would crash with an error like this:

```
Gem::Package::SymlinkError: installing symlink 'man/man0/README.markdown' pointing to parent path /usr/home/stevewi/srv/mail/lib/tools/.vendor/ruby/3.1.0/gems/binman-5.1.0/README.markdown of /srv/mail/lib/tools/.vendor/ruby/3.1.0/gems/binman-5.1.0 is not allowed
```

This commit fixes the problem by changing the bundle path to be the
realpath of the configured value, right after we're sure the path has
been created.

3cd3dd142a
2022-05-30 17:42:39 +09:00
Hiroshi SHIBATA
aeea88174d
Merge RubyGems and Bundler HEAD
125415593e
2022-05-20 17:32:19 +09:00
David Rodríguez
4c9ddaac0d [rubygems/rubygems] Fix Gemfile.lock versions leaking to bundler/inline install output
The lockfile is completely ignored in inline mode, yet the previous
output would suggest it wasn't.

763125a745
2022-05-13 15:23:56 +09:00
David Rodríguez
4962e5c417 [rubygems/rubygems] Normalize parameter name
The other sources use `options` which reads better.

a672f9d602
2022-05-13 15:23:56 +09:00
Hiroshi SHIBATA
1056489ea3 Merge 3f7d0352e8 2022-04-28 19:08:49 +09:00
Hiroshi SHIBATA
678d58c850 Merge rubygems master 1e4eda741d732ca1bd7031aef0a16c7348adf7a5 2022-04-28 19:08:49 +09:00
Hiroshi SHIBATA
d6311cb1ca Track RubyGems 3.4.0dev and Bundler 2.4.0dev 2021-12-27 10:45:36 +09:00
Nobuyoshi Nakada
9736cb890b
Check if Kernel#untaint is defined instead of version comparison
Probably `RUBY_VERSION` seems overwritten somewhere in the tests.
2021-12-27 08:56:00 +09:00
Hiroshi SHIBATA
69dc2ea465 Merge RubyGems-3.3.0 and Bundler-2.3.0 2021-12-21 15:27:05 +09:00
David Rodríguez
26303c31f0 [rubygems/rubygems] Pass "--" to git commands to separate positional and optional args
To make sure git uri's specified in Gemfile are never misinterpreted as
optional arguments, potentially allowing for local code execution.

90b1ed8b9f
2021-12-07 23:27:59 +09:00
David Rodríguez
248fae0ec4 [rubygems/rubygems] Improve sources representation
We have two representations of a source. Once used for sorting, which
should not depend on the source's state, but solely on its static
information, like remotes. Another one used for error and informational
messages, which should properly inform about the exact state of the
source when the message is printed.

This commit makes the latter be the default implementation of `to_s`, so
that error and informational messages are more accurate by default.

b5f2b88957
2021-12-03 20:00:50 +09:00
Hiroshi SHIBATA
0b53a8895f
Merge rubygems master fd676ac464491afaa0baf5435cb11b3f86229cbd 2021-12-01 11:00:10 +09:00
David Rodríguez
f634d1ee00 [rubygems/rubygems] Better error when installing a git lockfile and git not present
28f4842196
2021-10-30 06:11:39 +09:00
David Rodríguez
d8e97169ba [rubygems/rubygems] Only delete cached gem when it's corrupted
Rescuing all errors here might end up hiding other errors if the
deletion of the cached gem itself raises an error for some reason. Let's
be more conservative.

3d80dfba08
2021-10-29 02:40:35 +09:00
David Rodriguez
7073870dfa
[rubygems/rubygems] Improve readability by splitting updating the cache and searching it
d0df25bb0f
2021-10-25 20:48:51 +09:00
David Rodriguez
f7f85c1feb
[rubygems/rubygems] Manage global gem cache directly
Previously, it was maintained in sync with the standard cache. That was
less efficient, and it caused some error messages to point to non
existent files.

931f8cb8a9
2021-10-25 20:48:51 +09:00
David Rodriguez
4fc29d17b3
[rubygems/rubygems] Cached gem path resolution should consider default gems
83b2b845b3
2021-10-25 20:48:51 +09:00