Commit graph

124 commits

Author SHA1 Message Date
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
David Rodriguez
4edcda67b3
[rubygems/rubygems] Simplify gem downloading inside bundler
We can skip most stuff in `Gem::RemoteFetcher#download`, and use
`Gem::RemoteFetcher#update_cache_path` directly.

This has the benefit of allowing us to remove some workarounds to
support several rubygems versions, but also allows us to pass the target
folder where the gem should be downloaded directly and skip the logic
inside `Gem::RemoteFetcher#download` to infer the cache path. This will
be useful later to fix some issues with the `global_gem_cache` feature
flag.

8fe74a77e4
2021-10-25 20:48:51 +09:00
David Rodriguez
9b1b171866
[rubygems/rubygems] Use Gem::Specification#file_name consistently
13b933f49a
2021-10-25 20:48:50 +09:00
David Rodriguez
38542cfffc
[rubygems/rubygems] Extract a default_cache_path helper
8319305d58
2021-10-25 20:48:50 +09:00
David Rodriguez
edc1813190
[rubygems/rubygems] Small refactor
Extract final cache path to a variable and pass that to `download_gem`.
It actually fits better the parameters documentation since it's the
final directory where the downloaded gem will be placed.

1429db6a04
2021-10-25 20:48:50 +09:00
Jean Boussier
5af3f7f357
[rubygems/rubygems] Vendor a pure ruby implementation of SHA1
This allows `Source::Git` to no longer load the `digest` gem as it is causing
issues on Ruby 3.1.

c19a9f2ff7
2021-10-25 20:24:32 +09:00
David Rodriguez
0f1f95a3e3 [rubygems/rubygems] Fix bundle install to force reinstallation of deleted gems
8950631f02
2021-10-13 16:21:42 +09:00
David Rodríguez
bd87397f73 [rubygems/rubygems] Use correct way to detect default gems
The other way, in particular matching a substring in the gemspec
summary, is brittle and no longer used since Ruby 2.0.

This needed rewriting the specs that depended on that way.

059dbfa971
2021-10-13 16:21:42 +09:00
gabriele renzi
ad92651d64 [rubygems/rubygems] Add glob infomation to Bundler::Source::Git#to_s
The glob information was not specified in the string representation for
a source, which led to non-deterministic behaviour when generating the
lockfile, since sources are sorted by this value.

493b880abc
2021-10-09 08:03:43 +09:00
David Rodríguez
c119dd2b5a [rubygems/rubygems] Fix bundle plugin install misdetection of installed versions
9c88db949d
2021-08-31 19:06:14 +09:00
David Rodríguez
e70419d608 [rubygems/rubygems] Explicitly set allow_cached to false when setting local mode
1b8139e9d3
2021-08-31 19:06:14 +09:00
David Rodríguez
3683781f53 [rubygems/rubygems] Restore working bundle check behaviour
As part of a recent bug fix where bundler was accidentally hitting the
network when not supposed to, I made some refactoring, and the commit I'm
reverting here
(d74830d00b)
was some cleanup that those refactorings allowed according to "past me".

That was completely wrong, `bundle check` should never consider cached
gems, only installed gems, so the code that was removed was necessary.

5483e98305
2021-08-31 19:06:14 +09:00
David Rodríguez
97de4c02ad [rubygems/rubygems] Remove now unnecessary code
d74830d00b
2021-08-31 19:06:14 +09:00
David Rodríguez
0e01ad881a [rubygems/rubygems] The --local flag to bundle install shouldn't hit the network
If the cache was missing, `bundler` would try to re-fetch it. With the
`--local` flag, it should just look at installed gems.

630d29c69e
2021-08-31 19:06:14 +09:00
David Rodríguez
0b4dbe2e6a [rubygems/rubygems] Improve "gem not found in source" errors
When printing sources inside these error messages, it's useful to only
consider the current state of the source. For example, when requiring
`bundler/setup`, the source shouldn't be configured to be able to hit
the network, so the error message should only mention "locally installed
gems" to make that more clear.

30eb14f853
2021-08-31 19:06:14 +09:00
Daniel Niknam
91a3f06e98
[rubygems/rubygems] Implement Bundler::Source::Rubygems#no_remotes?
This method is created to tell whether any remote exist in the object or not and it will be used by `Bundler:SourceList` to tell if a global source has been defined implicitly or not.

47e3ff0e47
2021-07-27 09:25:56 +09:00
David Rodríguez
095b5bbcc1
[rubygems/rubygems] Lazily load shellwords
ef6388656a
2021-07-27 09:25:56 +09:00
Hiroshi SHIBATA
c082c6eb7c Sync RubyGems and Bundler with upstream 2021-07-07 15:31:52 +09:00
David Rodríguez
6e2240a2f9 Sync latest bundler & rubygems development version 2021-07-07 13:30:20 +09:00
David Rodríguez
5b0abba931 Sync bundler & rubygems 2021-05-11 11:29:41 +09:00
Hiroshi SHIBATA
ed149dbf46 Merge the master branch of Bundler 2021-04-15 15:36:15 +09:00