291 Commits

Author SHA1 Message Date
Giacomo Benedetti
fce2c386a5 [rubygems/rubygems] Sorting files in metadata for reproducibility
https://github.com/rubygems/rubygems/commit/792117980b
2025-04-01 09:55:19 +09:00
David Rodríguez
c0688c21fe [rubygems/rubygems] Raise a simpler error when RubyGems fails to activate a dependency
If you force uninstall a dependency but leave other gems depending on
it, those gems will fail to be activated.

In that case, RubyGems prints a rather complicated error:

```
$ rails --version
/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1413:in 'block in Gem::Specification#activate_dependencies': Could not find 'activesupport' (= 8.0.1) among 478 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/deivid/.local/share/gem/ruby/3.4.0:/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0' at: /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/specifications/railties-8.0.1.gemspec, execute `gem env` for more information
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1399:in 'Array#each'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1399:in 'Gem::Specification#activate_dependencies'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1381:in 'Gem::Specification#activate'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:283:in 'block in Gem.activate_bin_path'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Thread::Mutex#synchronize'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Gem.activate_bin_path'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/bin/rails:25:in '<main>'
/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/dependency.rb:303:in 'Gem::Dependency#to_specs': Could not find 'activesupport' (= 8.0.1) - did find: [activesupport-7.1.3,activesupport-7.0.8.7] (Gem::MissingSpecVersionError)
Checked in 'GEM_PATH=/Users/deivid/.local/share/gem/ruby/3.4.0:/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0' , execute `gem env` for more information
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1411:in 'block in Gem::Specification#activate_dependencies'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1399:in 'Array#each'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1399:in 'Gem::Specification#activate_dependencies'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1381:in 'Gem::Specification#activate'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:283:in 'block in Gem.activate_bin_path'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Thread::Mutex#synchronize'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Gem.activate_bin_path'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/bin/rails:25:in '<main>'
```

With this commit, the error becomes a bit simpler to parse:

```
$ rails --version
/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1421:in 'block in Gem::Specification#activate_dependencies': Could not find 'activesupport' (= 8.0.1) among 478 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/deivid/.local/share/gem/ruby/3.4.0:/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0' at: /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/specifications/railties-8.0.1.gemspec, execute `gem env` for more information
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1407:in 'Array#each'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1407:in 'Gem::Specification#activate_dependencies'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1389:in 'Gem::Specification#activate'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:283:in 'block in Gem.activate_bin_path'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Thread::Mutex#synchronize'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Gem.activate_bin_path'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/bin/rails:25:in '<main>'
```

And also, we reduce exception based control flow in our code.

https://github.com/rubygems/rubygems/commit/7e48c49f2d
2025-02-03 10:05:34 +09:00
Michael Rykov
3638f67069 [rubygems/rubygems] fix @licenses array unmarshalling
https://github.com/rubygems/rubygems/commit/12f3e78c95
2025-01-16 19:41:11 +09:00
David Rodríguez
9e0eb9778d Merge RubyGems-3.6.2 and Bundler-2.6.2 2024-12-24 07:21:10 +09:00
David Rodríguez
48443c0204 [rubygems/rubygems] Skip unresolved deps warning on Gem::Specification.reset on benign cases
If `Gem::Specification.reset` is used, but there are still unresolved
dependencies, RubyGems prints a warning. There are though, certain cases
where the situation will not cause any issues.

One such case is when the unresolved dependency does not restrict any
versions (>= 0) and there's a default gem matching it.

In this situation, it doesn't matter if Gem paths change, because
default gems are still activatable, so the dependency will be properly
activated if ever needed.

https://github.com/rubygems/rubygems/commit/e5f8a3068e
2024-12-06 15:19:19 +00:00
David Rodríguez
4addaaf4df [rubygems/rubygems] More aggressive Performance/FlatMap cop configuration
https://github.com/rubygems/rubygems/commit/d8d68cc00e
2024-11-26 15:11:05 +09:00
David Rodríguez
350baed6a9 [rubygems/rubygems] Fix manifest in gem package using incorrect platform sometimes
If a gem package is built from a specification whose platform has been
modified, it will include metadata using the old platform.

This change should fix the problem by making sure `original_platform` is
always properly set.

https://github.com/rubygems/rubygems/commit/ecd5cd4547
2024-11-06 11:37:29 +00:00
Leo Arnold
e9e66f74e3 [rubygems/rubygems] Add missing comma in documentation
https://github.com/rubygems/rubygems/commit/fe9999f2cf
2024-10-16 21:56:56 +00:00
David Rodríguez
d10e09b7e3 [rubygems/rubygems] Add Gem::Specification#gem_dir back
If old Bundler versions that unconditionally try to remove this method
are run with RubyGems versions _without_ this method, Bundler crashes
because it tries to remove a method that does not exist.

We need to wait until RubyGems cannot install any Bundler versions that
unconditionally remove this method.

https://github.com/rubygems/rubygems/commit/98804d261d
2024-10-09 12:18:05 +00:00
David Rodríguez
73834f11fa [rubygems/rubygems] Fix Gem::Specification#gem_dir losing custom source for some reason
https://github.com/rubygems/rubygems/commit/f8f589b1b8
2024-10-09 05:54:14 +00:00
David Rodríguez
d4ac5c573b [rubygems/rubygems] Don't add duplicated specs to unresolved specs
This could happen when a regular gem shadows a default gem.

https://github.com/rubygems/rubygems/commit/9ef70dd1f7
2024-09-30 05:07:57 +00:00
David Rodríguez
73d60df6e0 [rubygems/rubygems] Don't list duplicated version in Gem::Specification.reset warning
https://github.com/rubygems/rubygems/commit/e6e3db821f
2024-09-30 05:07:57 +00:00
Samuel Giddins
43e3416b70 [rubygems/rubygems] Unconditionally set installed_by_version
It has been supported since RubyGems 2.2.0 via https://github.com/rubygems/rubygems/commit/4525e45a4d45

Signed-off-by: Samuel Giddins <segiddins@segiddins.me>

https://github.com/rubygems/rubygems/commit/bf39c583e8
2024-09-20 14:26:13 +00:00
David Rodríguez
461c48960d [rubygems/rubygems] Add a note about when hack can be removed
https://github.com/rubygems/rubygems/commit/058b29fe98
2024-09-18 16:42:14 +00:00
David Rodríguez
47db8bc01c [rubygems/rubygems] Stop fighting with ourselves
https://github.com/rubygems/rubygems/commit/7cf2fdcfa1
2024-09-18 16:42:13 +00:00
Durable Programming Team
d6fc8f3d57 [rubygems/rubygems] fix @license typo preventing licenses from being correctly unmarshalled
https://github.com/rubygems/rubygems/commit/d6ba7ef79f
2024-08-31 18:30:25 +00:00
David Rodríguez
86c99a8d14 [rubygems/rubygems] Fix gemspec require_paths type validation
It was not properly being detected as an Array attribute, and thus not
properly validated.

Fixing this allows us to remove a strange `rescue` clause in Bundler.

https://github.com/rubygems/rubygems/commit/4121a32408
2024-07-18 09:25:17 +00:00
Nobuyoshi Nakada
c032e2c225 [rubygems/rubygems] Use caller_locations instead of splitting caller
Also limit caller ranges

https://github.com/rubygems/rubygems/commit/a274b1af78
2024-07-18 04:20:07 +00:00
Jerome Dalbert
d5500e621c [rubygems/rubygems] Feature add_dependency more prominently
https://github.com/rubygems/rubygems/commit/0236cb6191
2024-07-02 19:53:29 +00:00
Thomas Marshall
39951293b4 [rubygems/rubygems] Add Specification#validate_for_resolution
This method validates only what is required for resolution, skipping any
irrelevant metadata validation. This will be used by Bundler instead of
doing a full validation, allowing gem authors to use `bundle` commands
immediately in newly created gems without first having to fix invalid
metafata fields in the default gemspec.

https://github.com/rubygems/rubygems/commit/da7704cfc0
2024-06-25 14:32:19 +00:00
David Rodríguez
c2f8e91815 [rubygems/rubygems] Also disambiguate gems not in the first Gem.path position
https://github.com/rubygems/rubygems/commit/7e6e7ccc58
2024-06-13 14:25:14 +00:00
David Rodríguez
5c573b7652 [rubygems/rubygems] Fix default gem priority when sorting specs
https://github.com/rubygems/rubygems/commit/8dbe1dbdc7

Co-authored-by: MSP-Greg <Greg.mpls@gmail.com>
2024-06-13 14:25:14 +00:00
David Rodríguez
f4f56b23c3 [rubygems/rubygems] Make stub sorting stable
https://github.com/rubygems/rubygems/commit/6b70e9043d
2024-05-31 11:58:00 +00:00
David Rodriguez
c55c11d7d5 [rubygems/rubygems] Fix binstubs sometimes not getting regenerated when --destdir is given
This was only working for gems also installed in the default gem home.

https://github.com/rubygems/rubygems/commit/47df02dbd9
2024-05-16 13:34:33 +00:00
David Rodriguez
35c5c7edb9 [rubygems/rubygems] Refactor Gem::Specification#find_all_by_name
So that it can also be delegated to `Gem::SpecificationRecord`.

https://github.com/rubygems/rubygems/commit/1407807a99
2024-05-16 13:34:33 +00:00
David Rodriguez
965cb3ab4c [rubygems/rubygems] Fix issue when cleaning up plugin stubs
When `gem uninstall <gem> --install-dir <dir>` is run, if the version
removed had a plugin, and that same version happened to also be
installed globally, then the plugin stub would fail to be removed.

https://github.com/rubygems/rubygems/commit/4e2fa0be77
2024-05-14 16:08:03 +00:00
David Rodriguez
bd84236169 [rubygems/rubygems] Extract a Gem::SpecificationRecord class
This class handles all logic to handle the list of specifications, given
a set of GEM_PATH directories. Makes `Gem::Specification` has less
responsibilities and will help with fixing some bugs next.

https://github.com/rubygems/rubygems/commit/df280dbbed
2024-05-14 16:08:03 +00:00
David Rodriguez
5628cc1229 [rubygems/rubygems] Add missing docs
Other analog methods are documented, so document this one too.

https://github.com/rubygems/rubygems/commit/76da34d44d
2024-05-14 16:08:02 +00:00
David Rodriguez
91e3871970 [rubygems/rubygems] Simplify documentation
I don't think this method is any worse than others, let's only document
what it does.

https://github.com/rubygems/rubygems/commit/dec722187f
2024-05-14 16:08:01 +00:00
David Rodriguez
4dc0b23018 [rubygems/rubygems] Remove redundant receivers
https://github.com/rubygems/rubygems/commit/7b71965a70
2024-05-14 16:08:00 +00:00
David Rodriguez
281df1e495 [rubygems/rubygems] Remove Gem::Specification#mark_version
This gets in the middle if we ever start allowing to build as if using a
different RubyGems version than the one being run.

This could be useful to make `gem rebuild` a little more usable, and
it's already done by Bundler specs which already make this method a noop
when they need this.

I'm not sure forcefully setting this, even if user explicitly specified
something else is helpful.

Since this could potentially prevent gems explicitly setting a constant
RubyGems version from building, I changed the error of incorrect
RubyGems version from a hard error to a warning, since it will start
happening in those cases if we stop overwriting the version.

https://github.com/rubygems/rubygems/commit/45676af80d
2024-05-03 15:12:55 +00:00
Nobuyoshi Nakada
c8fb4f308b [rubygems/rubygems] Skip nil-value keys to make metadata reproducible
Nil-value keys in a mapping end with a space or not depending on
libyaml versions, and result metadata are different per platforms.
This commit makes to skip such keys to make metadata reproducible
accross platforms.

https://github.com/rubygems/rubygems/commit/74b4db8d30
2024-02-21 06:39:36 +00:00
Hiroshi SHIBATA
08753f2037 [rubygems/rubygems] Use https instead of http
https://github.com/rubygems/rubygems/commit/bcbe6f7b7a
2024-02-21 03:30:22 +00:00
Mike Dalessio
31e4300ea7 [rubygems/rubygems] feat: Gem::Specification#initialize_copy deep-copies requirements
to avoid accidentally mutating the original's state when doing:

```ruby
spec2 = spec.dup
spec2.required_rubygems_version.concat([">= 3.3.22"])
```

see https://github.com/rake-compiler/rake-compiler/pull/236 for a
real-world use case that would be made simpler with this behavior.

https://github.com/rubygems/rubygems/commit/c1d52389f0
2024-02-02 21:38:04 +00:00
Olle Jonsson
08edad31a6 [rubygems/rubygems] Drop two TODOs from specification.rb
These were introduced 13 years ago, in a documentation update. Perhaps we can let the TODOs go, without taking any action?

https://github.com/rubygems/rubygems/commit/fb23fa84f9
2024-01-18 22:49:32 +00:00
Brave Hager
d5e83a0601 [rubygems/rubygems] Update documentation to use squiggly heredoc
https://github.com/rubygems/rubygems/commit/4691b959ad
2024-01-11 00:51:48 +00:00
David Rodríguez
a06bf001b2
[rubygems/rubygems] Remove non-transparent requirement added to prerelease gems
I think we can safely assume these days that all RubyGems and Bundler
versions that will ever bundle a new gem created in 2023 support
prereleases.

So this non transparent requirement is not necessary.

In my opinion, it should be the gem author to explicitly add this
constraint, not RubyGems.

https://github.com/rubygems/rubygems/commit/b165e6d725
2023-12-12 10:04:57 +09:00
David Rodríguez
2755cb1b2f [rubygems/rubygems] Use modern hashes consistently
https://github.com/rubygems/rubygems/commit/bb66253f2c
2023-12-07 22:29:33 +00:00
David Rodríguez
3757d9027c [rubygems/rubygems] Remove now unnecessary dups
https://github.com/rubygems/rubygems/commit/56ce2a6445
2023-11-13 11:06:10 +09:00
David Rodríguez
a4d80eee17 [rubygems/rubygems] Let RuboCop target Ruby 3.0
https://github.com/rubygems/rubygems/commit/70243b1d72
2023-11-13 11:06:10 +09:00
David Rodríguez
54511303a4 [rubygems/rubygems] Drop support for Ruby 2.6 and Ruby 2.7 in RubyGems
https://github.com/rubygems/rubygems/commit/10c26a483d
2023-11-13 11:06:10 +09:00
David Rodríguez
e6e4b4884d
[rubygems/rubygems] Hack to get Gem::Specification#extensions_dir documented
https://github.com/rubygems/rubygems/commit/625b8293f7
2023-11-08 09:04:28 +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

https://github.com/rubygems/rubygems/commit/86c7084e1c
2023-10-23 13:59:01 +09:00
Mercedes Bernard
69d7e9a12e
[rubygems/rubygems] Use the server checksum, then calculate from gem on disk if possible
1. Use the checksum provided by the server if provided: provides security
knowing if the gem you downloaded matches the gem on the server

2. Calculate the checksum from the gem on disk: provides security knowing
if the gem has changed between installs

3. In some cases, neither is possible in which case we don't put anything
in the checksum and we maintain functionality as it is today

Add the checksums to specs in the index if we already have them

Prior to checksums, we didn't lose any information when overwriting specs
in the index with stubs. But now when we overwrite EndpointSpecifications
or RemoteSpecifications with more generic specs, we could lose checksum
info. This manually sets checksum info so we keep it in the index.

https://github.com/rubygems/rubygems/commit/de00a4f153
2023-10-23 13:59:01 +09:00
Hiroshi SHIBATA
3b47fb2cb6 [rubygems/rubygems] Update suggested variable for bindir
https://github.com/rubygems/rubygems/commit/f9cc6fed25
2023-10-03 00:08:34 +00:00
Samuel Giddins
02fa2acbde [rubygems/rubygems] Freeze more strings in generated gemspecs
Specifically, this will have frozen string literals for:
- Gem platform tuple entries
- Gem::Version strings
- Gem::Specification#installed_by_version
- Dependency requirement strings

https://github.com/rubygems/rubygems/commit/6195da5bdb
2023-09-21 18:25:04 +00:00
Samuel Giddins
d182d83ce9 [rubygems/rubygems] Add a Marshal.load replacement that walks an AST to safely load permitted classes/symbols
https://github.com/rubygems/rubygems/commit/7e4478fe73
2023-09-20 02:02:58 +00:00
Samuel Giddins
7e5c3ec5b1 Update specification.rb
Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
2023-08-20 09:05:29 +00:00
Samuel Giddins
1935433f5f [rubygems/rubygems] Ensure that loading multiple gemspecs with legacy YAML class references does not warn
Before this, you would get constant redefinition warnings on Psych::DefaultKey

Additionally, ensure the retries wont continue infinitely in the case of the ArgumentError not being caused by Marshal trying to load the undefined classes

https://github.com/rubygems/rubygems/commit/919e8c2de4
2023-08-20 09:05:17 +00:00
Nobuyoshi Nakada
419fbc77e0 [rubygems/rubygems] Clear YAML constant if it was undefined previously
https://github.com/rubygems/rubygems/commit/31d0311258
2023-07-19 23:20:54 +00:00