291 Commits

Author SHA1 Message Date
Hiroshi SHIBATA
d22511fd75 Merge rubygems/rubygems HEAD.
Picked at 12aeef6ba9a3be0022be9934c1a3e4c46a03ed3a
2022-01-19 15:01:44 +09:00
David Rodríguez
f04954d95c
[rubygems/rubygems] Normalize end alignment style with Bundler
https://github.com/rubygems/rubygems/commit/f7f504b24c
2022-01-19 11:20:36 +09:00
Nobuyoshi Nakada
6d3ee418c2 [rubygems/rubygems] Markup code with RDoc notations
https://github.com/rubygems/rubygems/commit/c29cd23826
2022-01-11 20:20:51 +09:00
Masataka Pocke Kuwabara
73707e5c51 [rubygems/rubygems] Make SpecificationPolicy autoload constant
It reduces memory usage about 204kb (1.4%).

https://github.com/rubygems/rubygems/commit/b7d4b8c8a6
2021-12-27 10:45:36 +09:00
Hiroshi SHIBATA
b0ad6cb371 Merge RubyGems-3.3.2 and Bundler-2.3.2 2021-12-24 10:35:31 +09:00
Hiroshi SHIBATA
fb1ab27f53 Merge RubyGems-3.3.1 and Bundler-2.3.1 2021-12-23 09:44:45 +09:00
Hiroshi SHIBATA
7e084ed707 Merge RubyGems and Bundler master
Merge from 793ad95ecb
2021-12-15 18:05:18 +09:00
Josef Šimánek
1f4af99383 [rubygems/rubygems] Move required_ruby_version gemspec attribute to recommended section.
https://github.com/rubygems/rubygems/commit/de6552ac30
2021-12-03 06:01:18 +09:00
David Rodríguez
8bdb56fcaf [rubygems/rubygems] Protect specs access at a finer level
https://github.com/rubygems/rubygems/commit/c8cc053bde
2021-11-18 04:37:28 +09:00
David Rodríguez
4bc69a25f3 [rubygems/rubygems] Stop using a constant for something not constant
https://github.com/rubygems/rubygems/commit/5cb0b9d9b8
2021-11-18 04:37:27 +09:00
David Rodríguez
a5cd4a0568 [rubygems/rubygems] Extract a helper method to reset specs
https://github.com/rubygems/rubygems/commit/662de0c990
2021-11-18 04:37:27 +09:00
David Rodríguez
f542ab2e6d [rubygems/rubygems] Make clearing loaded spec cache really private
https://github.com/rubygems/rubygems/commit/19f117652b
2021-11-18 04:37:26 +09:00
David Rodríguez
81eba77fc0 [rubygems/rubygems] We can now use standard memoization
https://github.com/rubygems/rubygems/commit/231be44d38
2021-11-18 04:37:25 +09:00
David Rodríguez
61f023f03b [rubygems/rubygems] Easier preservation of activated specs
https://github.com/rubygems/rubygems/commit/54e923ffc2
2021-11-18 04:37:25 +09:00
David Rodríguez
fdd3eed037 [rubygems/rubygems] Set @@all variable at class definition time
To spare the `defined?` check.

https://github.com/rubygems/rubygems/commit/64d27bba01
2021-11-18 04:37:24 +09:00
Carlos Palhares
38785aa3b9
Update licenses= documentation 2021-11-02 10:24:35 +09:00
Masataka Pocke Kuwabara
d03d122ba1 [rubygems/rubygems] Improve performance of Specification#missing_extensions?
https://github.com/rubygems/rubygems/commit/90c1919f94
2021-10-09 08:04:08 +09:00
Daniel Niknam
f212b9d4f2 [rubygems/rubygems] Refactor Ruby platform priority condition to its own method
The `Gem::Platform::RUBY ? -1 : 1` has been used multiple times in different places and could be refactored to a method (DRY).

https://github.com/rubygems/rubygems/commit/9d43ca8f0c
2021-08-31 19:06:14 +09:00
David Rodríguez
54ae3f587e [rubygems/rubygems] Prefer require_relative to require for internal requires
https://github.com/rubygems/rubygems/commit/c74fc58695
2021-08-31 19:06:14 +09:00
David Rodríguez
88e46cf6b8
[rubygems/rubygems] Remove all syck traces from rubygems
After reading [this blog
post](https://blog.rubygems.org/2011/08/31/shaving-the-yaml-yak.html),
published almost 10 years ago already, my understanding is that this
problem could come up in two ways:

* Rubygems.org serving corrupted gemspecs". As far as I understand this
was fixed in rubygems.org a lot time ago, since
https://github.com/rubygems/rubygems.org/pull/331.

* Clients having a ten years old gemspec cache with some of these bad
gemspecs. In this case, there's no easy solution but I think ten years
is enough and rebuilding the cache should do the trick.

So, I think it's time we remove this.

https://github.com/rubygems/rubygems/commit/afcb15d556
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
53468cc111 Sync latest development version of bundler & rubygems 2021-03-08 13:47:35 +09:00
Hiroshi SHIBATA
4aca77edde Merge prepare version of RubyGems 3.2.0 2020-12-08 17:30:02 +09:00
Jean Boussier
91865230cd [rubygems/rubygems] Eval defaults with frozen_string_literal: true
https://github.com/rubygems/rubygems/commit/d498ae3d62
2020-09-28 14:54:22 +09:00
Nobuyoshi Nakada
0629e695e3 Added --platform option to build command 2020-09-28 14:54:22 +09:00
Hiroshi SHIBATA
b717f73402
Revert "Manually merged from https://github.com/rubygems/rubygems/pull/2636"
31a6eaabc165d8a222e176f2c809d90622d88ec2 is obsoleted with
  https://github.com/rubygems/rubygems/pull/3820
2020-09-23 22:01:44 +09:00
Hiroshi SHIBATA
31a6eaabc1
Manually merged from https://github.com/rubygems/rubygems/pull/2636
Enable Style/EmptyLinesAroundClassBody rubocop cop.
2020-09-23 21:02:56 +09:00
David Rodríguez
ea8f7d4a81 [rubygems/rubygems] Gem::Specification#to_ruby doesn't need openssl
The `openssl` require when openssl not present was having the
side-effect the our custom require fallbacks would end up loading `Gem::Specification.stubs`.

Co-authored-by: Alyssa Ross <hi@alyssa.is>

https://github.com/rubygems/rubygems/commit/22c4ded4ad
2020-07-31 21:07:19 +09:00
bronzdoc
6c19b0ec6e [rubygems/rubygems] Reword warning
https://github.com/rubygems/rubygems/commit/cbd4abf8cf
2020-07-31 21:07:19 +09:00
bronzdoc
00bdac18cf [rubygems/rubygems] Warn on duplicate dependency in a specification
https://github.com/rubygems/rubygems/commit/af3e5f7883
2020-07-31 21:07:19 +09:00
David Rodríguez
1260d22cae [rubygems/rubygems] Extract some common code into a private method
https://github.com/rubygems/rubygems/commit/d1be8cdb3a
2020-07-31 21:07:19 +09:00
David Rodríguez
d5b5a7ab31 [rubygems/rubygems] Remove very old TODO note
It was added 10 years ago on a "146 additions, 170 deletions" commit
named "Deprecation removals and minor cleanup." that didn't explain much
other than that.

This TODO doesn't necessarily apply nowadays. I don't see how anyways.
TODO notes, if useful at all, should include a clear explanation of what
should be done either via the note itself or the commit message. This
note doens't meet any of these.

So I want to remove it because it distracts me every time I go through
it.

https://github.com/rubygems/rubygems/commit/58d81e8a32
2020-07-31 21:07:19 +09:00
Karol Bucek
e7b6e0ff58 [rubygems/rubygems] remove explicit require(s) for auto-loaded constant(s)
the Gem module's auto-loads will handle loading these as needed,

this started as a redundancy found in *rubygems.rb* which had:
`autoload :Specification, 'rubygems/specification'` as well as
`require 'rubygems/specification'`

https://github.com/rubygems/rubygems/commit/43ceae7ac0
2020-07-31 21:07:19 +09:00
Marc-Andre Lafortune
c3b480b776 [rubygems/rubygems] Test files should not be included in spec.files
https://github.com/rubygems/rubygems/commit/0c0760b734
2020-07-31 21:07:19 +09:00
David Rodríguez
a89665b7b1 Enforce no empty lines around class body in rubygems
To normalize the code style with `bundler`.
2020-07-31 21:07:19 +09:00
David Rodríguez
4784264729 Remove random code 2020-06-15 21:20:37 +09:00
David Rodríguez
955f1837a1 Use space inside block braces everywhere
To make rubygems code style consistent with bundler.
2020-06-15 21:20:37 +09:00
David Rodríguez
3cfe190099 [rubygems/rubygems] Move docs to a better place
https://github.com/rubygems/rubygems/commit/c87ac90528
2020-06-05 07:32:42 +09:00
David Rodríguez
15018f20dd [rubygems/rubygems] Deprecate some methods that are only there for compatibility
https://github.com/rubygems/rubygems/commit/b4948bda74
2020-06-05 07:32:42 +09:00
Olle Jonsson
5eacf4e72c Enable rubocop-performance StartWith cop
- this would keep the could-be-a-string-method matches few
2020-06-05 07:32:42 +09:00
Olle Jonsson
f61ee674d8 [rubygems/rubygems] Prefer start_with? and end_with? over regex.
- In one of the cases, filenames were checked for ending with "gz" -
    this is changed to check for ending with ".gz"
  - The change was made to make it even easier to read the code, and to
    match only from the start of the input (as opposed to start of the
    line)

https://github.com/rubygems/rubygems/commit/aac4290271
2020-06-05 07:32:42 +09:00
David Rodríguez
18ac783ea6 [rubygems/rubygems] Revert adding loaded specs to Gem::Specification.stubs and Gem::Specification.stubs_for
The rationale is that:

* The change has caused realworld issues. See for example
https://github.com/ruby/did_you_mean/issues/117 and specifically [this
comment](https://github.com/ruby/did_you_mean/issues/117#issuecomment-482733159)
for a great explanation of the issue it caused for `did_you_mean`.

* The change also causes problems for our development workflows. For
example, because of it, our `bundler` specs cannot currently be run with
`bin/rake` and we have to use `bin/rspec` or `bin/parallel_spec`
directly. The explanation for this is:

  - Our specs install test dependencies to `tmp` before running specs.
  - `rake` is one of these test dependencies.
  - Before installing each test dependency, we check whether it has
  matching installed specs: 2bbcdcde08/bundler/spec/support/rubygems_ext.rb (L109-L114).

  - Normally, if `rake` has not yet been installed to `tmp`, this check
  fails and `rake` is installed, but since the loaded specs are now
  added to `Gem::Specification.stubs` and `rake`'s specification _is_
  loaded because we're running through `bin/rake`, the check incorrectly
  assumes that `rake` is already installed to `tmp` and skips
  installation.
  - At a later point the specs check whether `rake` is actually
  installed and fail if it's not: 2bbcdcde08/bundler/spec/support/builders.rb (L372-L383)

Essentially, both of the issues are the same. If at runtime we change
the location of gems, we'll _want_ to not consider loaded specifications
when dealing with the new gem location, because the loaded
specifications have not been loaded from there. Loaded specifications is
something different from installed stub specifications and those should
not be mixed.

The PR still seemed to have fixed an issue, so I did my archaeology job
and investigated the original issue to double check if reverting is ok.
The logs for the original error can be found here:
https://ci.appveyor.com/project/rubygems/rubygems/build/1172/job/ogubyucpljcv22ux.

So I installed ruby 2.4.4, checked out the commit reference before the
offending PR, and the exact error reproduced. 🎉

```
$ rake test
/home/deivid/Code/rubygems/lib/rubygems/resolver.rb:231:in `search_for': Unable to resolve dependency: user requested 'bundler (= 1.16.2)' (Gem::UnsatisfiableDependencyError)
  from /home/deivid/Code/rubygems/lib/rubygems/resolver.rb:283:in `block in sort_dependencies'
  from /home/deivid/Code/rubygems/lib/rubygems/resolver.rb:277:in `each'
  from /home/deivid/Code/rubygems/lib/rubygems/resolver.rb:277:in `sort_by'
  from /home/deivid/Code/rubygems/lib/rubygems/resolver.rb:277:in `with_index'
  from /home/deivid/Code/rubygems/lib/rubygems/resolver.rb:277:in `sort_dependencies'
  from /home/deivid/Code/rubygems/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb:52:in `block in sort_dependencies'
  from /home/deivid/Code/rubygems/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb:69:in `with_no_such_dependency_error_handling'
  from /home/deivid/Code/rubygems/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb:51:in `sort_dependencies'
  from /home/deivid/Code/rubygems/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb:165:in `initial_state'
  from /home/deivid/Code/rubygems/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb:106:in `start_resolution'
  from /home/deivid/Code/rubygems/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb:64:in `resolve'
  from /home/deivid/Code/rubygems/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb:42:in `resolve'
  from /home/deivid/Code/rubygems/lib/rubygems/resolver.rb:188:in `resolve'
  from /home/deivid/Code/rubygems/lib/rubygems/request_set.rb:396:in `resolve'
  from /home/deivid/Code/rubygems/lib/rubygems/request_set.rb:408:in `resolve_current'
  from /home/deivid/Code/rubygems/lib/rubygems.rb:243:in `finish_resolve'
  from /home/deivid/Code/rubygems/lib/rubygems/rdoc.rb:13:in `<top (required)>'
  from /home/deivid/Code/rubygems/lib/rubygems/core_ext/kernel_require.rb:54:in `require'
  from /home/deivid/Code/rubygems/lib/rubygems/core_ext/kernel_require.rb:54:in `require'
  from /home/deivid/Code/rubygems/lib/rubygems/test_case.rb:1563:in `<top (required)>'
  from /home/deivid/Code/rubygems/test/rubygems/test_bundled_ca.rb:2:in `require'
  from /home/deivid/Code/rubygems/test/rubygems/test_bundled_ca.rb:2:in `<top (required)>'
  from /home/deivid/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/rake_test_loader.rb:15:in `require'
  from /home/deivid/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/rake_test_loader.rb:15:in `block in <main>'
  from /home/deivid/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/rake_test_loader.rb:4:in `select'
  from /home/deivid/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/rake_test_loader.rb:4:in `<main>'
rake aborted!
Command failed with status (1)

Tasks: TOP => test
```

Now the explanation of the error:

* Rubygems base `TestCase` class requires `bundler` because some tests
use `bundler`:
2bbcdcde08/lib/rubygems/test_case.rb (L26)

* That `require` (our custom rubygems require) would activate the
default bundler spec (1.16.1 for ruby 2.4.4) but then overwrite it with
a 1.16.2 version (the locally provided bundler those days) due to [this
old
hack](9f7bf0ac3a/lib/bundler/version.rb (L7-L23)).

* Rubygems base `TestCase` class requires `rubygems/rdoc`:
2bbcdcde08/lib/rubygems/test_case.rb (L1536)

* And that file ends up calling `Gem.finish_resolve`:
2bbcdcde08/lib/rubygems/rdoc.rb (L13)

* `Gem.finish_resolve` adds the currently loaded specs to the
resolution:
2bbcdcde08/lib/rubygems.rb (L235)

* That means it would try to resolve bundler 1.16.2, but no
specification for that version was installed since the default was
1.16.1. That explains why upgrading to rubygems 2.7.7 fixed the issue,
since it provided bundler 1.16.2 by default so there was not bundler
version discrepancy.

After understanding the error, I conclude that:

* Only this part of the original patch was actually needed to resolve
the error, not any of the changes in `Gem::Specification.stubs` and
`Gem::Specification.stubs_for`:

```diff
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index f1cd3d274c..92c848e870 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -13,6 +13,15 @@ else
   require 'rubygems'
 end

+# If bundler gemspec exists, add to stubs
+bundler_gemspec = File.expand_path("../../../bundler/bundler.gemspec", __FILE__)
+if File.exist?(bundler_gemspec)
+  Gem::Specification.dirs.unshift File.dirname(bundler_gemspec)
+  Gem::Specification.class_variable_set :@@stubs, nil
+  Gem::Specification.stubs
+  Gem::Specification.dirs.shift
+end
+
 begin
   gem 'minitest'
 rescue Gem::LoadError
```

So, I propose to revert adding loaded specification to
`Gem::Specification.stubs` and `Gem::Specification.stubs_for` because I
think it's safe, it fixes the issues caused by their addition, and it
simplifies `Gem::Specification` code, which is already complicated
enough.

https://github.com/rubygems/rubygems/commit/5269cd617c
2020-05-08 14:13:29 +09:00
Vít Ondruch
acc86570dd [rubygems/rubygems] Let @@stubs_by_name to be incrementally populated again.
Originally, the call to `.stubs_for` allowed to incrementally populate
the `@@stubs_by_name` (especially see the `"#{name}-*.gemspec"` pattern
in 4fa03bb7aac9f25f44394e818433fdda9962ae8d). Now it looks like it
expects that all stubs are loaded, but the `.stubs_for` still matches
the .gemspec files by the `name` pattern:

6d45e0f7ac/lib/rubygems/specification.rb (L845)

I think this was done by mistake incrementally by PR #1239 and
4cee8ca9199ac7b3ab8647e0b78615f55d3eb02b. I think the best option is to
get back to the original implementation, to let RubyGems incrementally
populate the array. Other option would be to replace the logic in
`.stub_for` by call to `.stubs`, but the means the performance
improvement from the original commit was lost.

https://github.com/rubygems/rubygems/commit/4d0e18185a
2020-05-08 14:13:29 +09:00
David Rodríguez
314d7f897c Remove builder gem requirement for gem regenerate_index
This requirement was introduced 14 years ago in
7ce7039b390440754954df5efea619e9f57ef823, and I don't think it's
necessary anymore. I made several tests introducing UTF-8 characters in
gemspec files and generating indexes out of them, and couldn't find any
issues. Gemspecs are read with UTF-8 encoding these days.
2020-05-08 14:13:29 +09:00
bronzdoc
7fb694fdb0 [rubygems/rubygems] Show gemspec location when a Gem::MissingSpecError is raised while trying to activate a gem
https://github.com/rubygems/rubygems/commit/4da54a8e8b
2020-05-08 14:13:29 +09:00
David Rodríguez
2205ae8af5 Normalize heredoc delimiters 2020-05-08 07:38:50 +09:00
Josef Šimánek
39322317f3 [rubygems/rubygems] Do not use set.
https://github.com/rubygems/rubygems/commit/1a72c8796f
2020-05-08 07:38:50 +09:00
Josef Šimánek
856cbbdd52 [rubygems/rubygems] Track removed methods calls and warn during build time.
move rubyforge_project= to removed methods

https://github.com/rubygems/rubygems/commit/223f7fd470
2020-05-08 07:38:50 +09:00
Josef Šimánek
4dd46dbad0 [rubygems/rubygems] Deprecate rubyforge_project attribute only during build time.
https://github.com/rubygems/rubygems/commit/c44eb21648
2020-05-08 07:38:50 +09:00