aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/specification.rb
Commit message (Collapse)AuthorAgeFilesLines
* Merge prepare version of RubyGems 3.2.0Hiroshi SHIBATA2020-12-081-8/+8
|
* [rubygems/rubygems] Eval defaults with frozen_string_literal: trueJean Boussier2020-09-281-0/+2
| | | | https://github.com/rubygems/rubygems/commit/d498ae3d62
* Added `--platform` option to `build` commandNobuyoshi Nakada2020-09-281-0/+4
|
* Revert "Manually merged from https://github.com/rubygems/rubygems/pull/2636"Hiroshi SHIBATA2020-09-231-2/+0
| | | | | 31a6eaabc165d8a222e176f2c809d90622d88ec2 is obsoleted with https://github.com/rubygems/rubygems/pull/3820
* Manually merged from https://github.com/rubygems/rubygems/pull/2636Hiroshi SHIBATA2020-09-231-0/+2
| | | | Enable Style/EmptyLinesAroundClassBody rubocop cop.
* [rubygems/rubygems] Gem::Specification#to_ruby doesn't need `openssl`David Rodríguez2020-07-311-2/+2
| | | | | | | | | 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
* [rubygems/rubygems] Reword warningbronzdoc2020-07-311-1/+1
| | | | https://github.com/rubygems/rubygems/commit/cbd4abf8cf
* [rubygems/rubygems] Warn on duplicate dependency in a specificationbronzdoc2020-07-311-0/+4
| | | | https://github.com/rubygems/rubygems/commit/af3e5f7883
* [rubygems/rubygems] Extract some common code into a private methodDavid Rodríguez2020-07-311-6/+7
| | | | https://github.com/rubygems/rubygems/commit/d1be8cdb3a
* [rubygems/rubygems] Remove very old TODO noteDavid Rodríguez2020-07-311-1/+0
| | | | | | | | | | | | | | | | 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
* [rubygems/rubygems] remove explicit require(s) for auto-loaded constant(s)Karol Bucek2020-07-311-3/+0
| | | | | | | | | | 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
* [rubygems/rubygems] Test files should not be included in spec.filesMarc-Andre Lafortune2020-07-311-3/+2
| | | | https://github.com/rubygems/rubygems/commit/0c0760b734
* Enforce no empty lines around class body in rubygemsDavid Rodríguez2020-07-311-2/+0
| | | | To normalize the code style with `bundler`.
* Remove random codeDavid Rodríguez2020-06-151-3/+0
|
* Use space inside block braces everywhereDavid Rodríguez2020-06-151-40/+40
| | | | To make rubygems code style consistent with bundler.
* [rubygems/rubygems] Move docs to a better placeDavid Rodríguez2020-06-051-6/+0
| | | | https://github.com/rubygems/rubygems/commit/c87ac90528
* [rubygems/rubygems] Deprecate some methods that are only there for compatibilityDavid Rodríguez2020-06-051-0/+3
| | | | https://github.com/rubygems/rubygems/commit/b4948bda74
* Enable rubocop-performance StartWith copOlle Jonsson2020-06-051-2/+2
| | | | - this would keep the could-be-a-string-method matches few
* [rubygems/rubygems] Prefer start_with? and end_with? over regex.Olle Jonsson2020-06-051-1/+1
| | | | | | | | | | - 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
* [rubygems/rubygems] Revert adding loaded specs to `Gem::Specification.stubs` ↵David Rodríguez2020-05-081-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: https://github.com/rubygems/rubygems/blob/2bbcdcde08b90d4ef03da8fb1f7a8a3313e13bb8/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: https://github.com/rubygems/rubygems/blob/2bbcdcde08b90d4ef03da8fb1f7a8a3313e13bb8/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. :tada: ``` $ 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`: https://github.com/rubygems/rubygems/blob/2bbcdcde08b90d4ef03da8fb1f7a8a3313e13bb8/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](https://github.com/rubygems/bundler/blob/9f7bf0ac3ab8d995e3a274cec3c292a5203f4534/lib/bundler/version.rb#L7-L23). * Rubygems base `TestCase` class requires `rubygems/rdoc`: https://github.com/rubygems/rubygems/blob/2bbcdcde08b90d4ef03da8fb1f7a8a3313e13bb8/lib/rubygems/test_case.rb#L1536 * And that file ends up calling `Gem.finish_resolve`: https://github.com/rubygems/rubygems/blob/2bbcdcde08b90d4ef03da8fb1f7a8a3313e13bb8/lib/rubygems/rdoc.rb#L13 * `Gem.finish_resolve` adds the currently loaded specs to the resolution: https://github.com/rubygems/rubygems/blob/2bbcdcde08b90d4ef03da8fb1f7a8a3313e13bb8/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
* [rubygems/rubygems] Let `@@stubs_by_name` to be incrementally populated again.Vít Ondruch2020-05-081-2/+2
| | | | | | | | | | | | | | | | | | | 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: https://github.com/rubygems/rubygems/blob/6d45e0f7ac1caca22900e39f703e226c4cfdebf7/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
* Remove `builder` gem requirement for `gem regenerate_index`David Rodríguez2020-05-081-7/+1
| | | | | | | | 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.
* [rubygems/rubygems] Show gemspec location when a Gem::MissingSpecError is ↵bronzdoc2020-05-081-1/+5
| | | | | | raised while trying to activate a gem https://github.com/rubygems/rubygems/commit/4da54a8e8b
* Normalize heredoc delimitersDavid Rodríguez2020-05-081-2/+2
|
* [rubygems/rubygems] Do not use set.Josef Šimánek2020-05-081-2/+1
| | | | https://github.com/rubygems/rubygems/commit/1a72c8796f
* [rubygems/rubygems] Track removed methods calls and warn during build time.Josef Šimánek2020-05-081-7/+13
| | | | | | move rubyforge_project= to removed methods https://github.com/rubygems/rubygems/commit/223f7fd470
* [rubygems/rubygems] Deprecate rubyforge_project attribute only during build ↵Josef Šimánek2020-05-081-3/+2
| | | | | | time. https://github.com/rubygems/rubygems/commit/c44eb21648
* [rubygems/rubygems] Rename version horizon deprecation methodsbronzdoc2020-05-081-6/+6
| | | | https://github.com/rubygems/rubygems/commit/6afd914fda
* [rubygems/rubygems] Modify files to use new version horizon deprecationsbronzdoc2020-05-081-6/+6
| | | | https://github.com/rubygems/rubygems/commit/4fe5bb5bf3
* [rubygems/rubygems] Enable `Style/ExtraSpacing` and auto-correctDavid Rodríguez2020-03-301-6/+6
| | | | https://github.com/rubygems/rubygems/commit/6fa0b1b679
* [rubygems/rubygems] Enable Style/PercentLiteralDelimiters cop in rubygemsDavid Rodríguez2020-03-301-1/+1
| | | | | | So it matches the style used by bundler. https://github.com/rubygems/rubygems/commit/ab0580fd65
* Sync rubygems with current master (#2889)David Rodríguez2020-03-241-12/+2
|
* Merge the current master branch of rubygems/rubygems.Hiroshi SHIBATA2020-02-011-17/+16
| | | | Just started to develop RubyGems 3.2.0.
* Merge RubyGems 3.1.0.pre3Hiroshi SHIBATA2019-11-111-6/+6
| | | | | | | | | | | | | | | | | | | * Fix gem pristine not accounting for user installed gems. Pull request #2914 by Luis Sagastume. * Refactor keyword argument test for Ruby 2.7. Pull request #2947 by SHIBATA Hiroshi. * Fix errors at frozen Gem::Version. Pull request #2949 by Nobuyoshi Nakada. * Remove taint usage on Ruby 2.7+. Pull request #2951 by Jeremy Evans. * Check Manifest.txt is up to date. Pull request #2953 by David Rodríguez. * Clarify symlink conditionals in tests. Pull request #2962 by David Rodríguez. * Update command line parsing to work under ps. Pull request #2966 by David Rodríguez. * Properly test `Gem::Specifications.stub_for`. Pull request #2970 by David Rodríguez. * Fix Gem::LOADED_SPECS_MUTEX handling for recursive locking. Pull request #2985 by MSP-Greg.
* Gem::Specification#to_ruby needs OpenSSLNobuyoshi Nakada2019-09-261-0/+1
|
* [rubygems/rubygems] Avoid adding OpenSSL::PKey::RSA instancesbronzdoc2019-09-261-4/+2
| | | | https://github.com/rubygems/rubygems/commit/ba021fb4be
* [rubygems/rubygems] Fix indentation in case statementbronzdoc2019-09-261-10/+10
| | | | https://github.com/rubygems/rubygems/commit/8ac0647659
* [rubygems/rubygems] Make ruby_code method handle OpenSSL::PKey::RSA objectsbronzdoc2019-09-261-0/+1
| | | | https://github.com/rubygems/rubygems/commit/b1d825ab3a
* [rubygems/rubygems] Set SOURCE_DATE_EPOCH env var if not provided.Ellen Marie Dash2019-09-261-1/+1
| | | | | | | | | | | | | Fixes #2290. 1. `Gem::Specification.date` returns SOURCE_DATE_EPOCH when defined, 2. this commit makes RubyGems set it _persistently_ when not provided. This combination means that you can build a gem, check the build time, and use that value to generate a new build -- and then verify they're the same. https://github.com/rubygems/rubygems/commit/d830d53f59
* [rubygems/rubygems] Bump rubocop to 0.74.0 and fix new offensesDavid Rodríguez2019-09-051-4/+4
| | | | https://github.com/rubygems/rubygems/commit/d4fc383497
* [rubygems/rubygems] Revert cadb66037d9b58c80fc795f39384d533229a1f73bronzdoc2019-08-051-0/+8
| | | | https://github.com/rubygems/rubygems/commit/5c3158d975
* [rubygems/rubygems] Move default specifications dir definition out of ↵Vít Ondruch2019-07-311-2/+2
| | | | | | | | | | | | BasicSpecification. This was never the right place. The method got there just by evolution, not by design. Move it within default methods, where it suits better. Since this method is presumably used just internally, it should be safe to deprecate it and remove later. https://github.com/rubygems/rubygems/commit/0c0dd9458a
* [rubygems/rubygems] Autorequire was used by old RubyGems, it is neither ↵bronzdoc2019-07-311-8/+0
| | | | | | supported nor functional. https://github.com/rubygems/rubygems/commit/cadb66037d
* [rubygems/rubygems] Simplify #to_ruby codeNobuyoshi Nakada2019-07-311-11/+3
| | | | | | | | | | Separate #add_runtime_dependency and #add_development_dependency availability condition from #specification_version availability, which is not related to directly. Also check if the former method is available, instead of comparing the version. https://github.com/rubygems/rubygems/commit/5cccc2b836
* [rubygems/rubygems] Remove useless TODO commentbronzdoc2019-07-311-1/+1
| | | | https://github.com/rubygems/rubygems/commit/44bc809dc8
* [rubygems/rubygems] check_version_conflict don't have a 'dep' variable ↵bronzdoc2019-07-311-1/+0
| | | | | | available for use https://github.com/rubygems/rubygems/commit/1783cf0fd3
* [rubygems/rubygems] Explicitly deprecate `rubyforge_project`David Rodríguez2019-07-311-0/+1
| | | | https://github.com/rubygems/rubygems/commit/9094740109
* [rubygems/rubygems] Do not replace the cache entry if there is already oneBenoit Daloze2019-07-311-1/+6
| | | | | | * That way, multiple lookups for the same file always return the same object. https://github.com/rubygems/rubygems/commit/50a431b6db
* [rubygems/rubygems] Synchronize access to the Gem::Specification::LOAD_CACHE ↵Benoit Daloze2019-07-311-3/+8
| | | | | | | | Hash * It's accessed concurrently, notably when installing a gem with a C extension. https://github.com/rubygems/rubygems/commit/543294d7dd
* [rubygems/rubygems] Lazy require stringiobronzdoc2019-07-311-1/+1
| | | | https://github.com/rubygems/rubygems/commit/82f0d4ca69