Commit graph

241 commits

Author SHA1 Message Date
David Rodríguez
a89460a8a0
[rubygems/rubygems] Reenable skipped specs in truffleruby since they should be fixed
a7cbec95c1
2025-05-14 15:13:45 +09:00
Ellen Marie Dash
6982b80a8b [rubygems/rubygems] Default to a SOURCE_DATE_EPOCH of 315619200, to simplify reproducible builds.
1d5a627398
2025-03-24 13:25:07 +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.

7e48c49f2d
2025-02-03 10:05:34 +09:00
David Rodríguez
d645b62b6d [rubygems/rubygems] Remove already fixed TODO
It was fixed by 3b0d44fbf5.

4cf3429599
2025-02-03 10:05:33 +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.

e5f8a3068e
2024-12-06 15:19:19 +00:00
David Rodríguez
ba91ff5f78 [rubygems/rubygems] Make sure unresolved deps are properly cleared by Gem::Specification.reset
3976326a7b
2024-12-06 15:19:19 +00:00
David Rodríguez
a1492ffdc2 [rubygems/rubygems] Run specs that now pass on JRuby
2af077ee38
2024-10-10 14:51:30 +00:00
David Rodríguez
73d60df6e0 [rubygems/rubygems] Don't list duplicated version in Gem::Specification.reset warning
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 4525e45a4d

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

bf39c583e8
2024-09-20 14:26:13 +00:00
Hiroshi SHIBATA
4e5b3e58e2 Make optional benchmark test in test_find_in_unresolved_tree_is_not_exponentiental 2024-08-29 17:37:44 +09: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.

4121a32408
2024-07-18 09:25:17 +00:00
David Rodríguez
f78a8761c4 [rubygems/rubygems] Remove unnecessary Windows test skip
946180f5c1
2024-07-18 09:25:16 +00:00
Jerome Dalbert
bbb4da78c7 [rubygems/rubygems] Use preferred add_dependency instead of add_runtime_dependency
9a08043858
2024-07-05 02:24:53 +00:00
David Rodríguez
403413e1f1 [rubygems/rubygems] Don't print warning about nil versions being discouraged during tests
39a47c264e
2024-06-26 16:11:44 +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.

da7704cfc0
2024-06-25 14:32:19 +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.

df280dbbed
2024-05-14 16:08:03 +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.

45676af80d
2024-05-03 15:12:55 +00:00
Josef Šimánek
bfb2dc8acf [rubygems/rubygems] Warn on empty or open required_ruby_version specification attribute.
e4bb33747a
2024-02-27 12:33:45 +09: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.

74b4db8d30
2024-02-21 06:39:36 +00:00
Kim Emmanuel
5ddf4f5c95 [rubygems/rubygems] fix Gem::Dependency#to_spec returning nil when prerelease is the only available version
a7dcc7214b
2024-02-07 05:46:49 +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.

c1d52389f0
2024-02-02 21:38:04 +00:00
なつき
1e519abe21 [rubygems/rubygems] Fix rake extension warning
04973e349c
2024-01-24 13:55:42 +09:00
Hiroshi SHIBATA
82496f2b38 Merge RubyGems-3.5.2 and Bundler-2.5.2 2023-12-22 07:24:04 +09:00
Drew Stevenson
beefce1444 [rubygems/rubygems] Warn for duplicate meta data links
Match order of METADATA_LINK_KEYS to order used by rubygems.org in Links model.
Add missing download_uri key.

d2922cd6e9
2023-12-14 00:06:05 +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.

b165e6d725
2023-12-12 10:04:57 +09:00
David Rodríguez
54511303a4 [rubygems/rubygems] Drop support for Ruby 2.6 and Ruby 2.7 in RubyGems
10c26a483d
2023-11-13 11:06:10 +09:00
Josef Šimánek
4cf68908e5 [rubygems/rubygems] Update SPDX list and warn on deprecated identifiers.
61667028f5
2023-09-30 11:20:08 +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

6195da5bdb
2023-09-21 18:25:04 +00:00
Samuel Giddins
b68be40e24 [rubygems/rubygems] Use assert_raise instead of assert_raises
For ruby-core compat

83aa7b794e
2023-08-20 09:05:23 +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

919e8c2de4
2023-08-20 09:05:17 +00:00
John Hong
744bc4d5d0 [rubygems/rubygems] Make nil a valid license spec
675effb67e
2023-08-18 16:42:49 +00:00
Nobuyoshi Nakada
419fbc77e0 [rubygems/rubygems] Clear YAML constant if it was undefined previously
31d0311258
2023-07-19 23:20:54 +00:00
Hiroshi SHIBATA
d89cc317c6
util/rubocop -A --only Style/NumericLiteralPrefix 2023-04-11 19:12:28 +09:00
Hiroshi SHIBATA
fb822076d7 [rubygems/rubygems] util/rubocop -A --only Style/LineEndConcatenation
67ece7b8b6
2023-04-06 23:33:20 +00:00
Hiroshi SHIBATA
e003784fc8 [rubygems/rubygems] util/rubocop -A --only Style/RegexpLiteral
9264d83421
2023-04-05 09:50:29 +00:00
Hiroshi SHIBATA
a464951fc7 [rubygems/rubygems] Unify win_platform? to Gem.win_platform?
b18a4ef076
2023-04-05 05:49:25 +00:00
Hiroshi SHIBATA
cd4b4ac737 [rubygems/rubygems] Use double-quotes instead of single-quotes in warnings
c7f1cb9941
2023-03-28 15:25:45 +09:00
Hiroshi SHIBATA
f24a86d83f util/rubocop -A --only Layout/EmptyLineAfterMagicComment 2023-03-23 17:18:49 +09:00
Hiroshi SHIBATA
19e9c4004b [rubygems/rubygems] util/rubocop -A --only Lint/BinaryOperatorWithIdenticalOperands
Many of class of RubyGems have original <=> methods. We should ignore
  these cops for testing.

0a8645dc3b
2023-03-23 17:18:49 +09:00
Hiroshi SHIBATA
5211900d37 util/rubocop -A --only Style/SymbolProc 2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
0373615948 util/rubocop -A --only Layout/SpaceInsideArrayLiteralBrackets 2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
866831d8e9 [rubygems/rubygems] util/rubocop -A --only Style/Semicolon
97f062be05
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
ee7475734f [rubygems/rubygems] util/rubocop -A --only Style/BarePercentLiterals
02d8147243
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
6ad269dc39 [rubygems/rubygems] util/rubocop -A --only Style/RescueStandardError
80b57da926
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
4cd8a46f45 [rubygems/rubygems] util/rubocop -A --only Style/ParenthesesAroundCondition
c766a65885
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
4ab23df2c4 [rubygems/rubygems] util/rubocop -A --only Style/RedundantParentheses
295691d4dc
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
03b82d1865 [rubygems/rubygems] util/rubocop -A --only Style/SingleLineMethods
fa2e835ed2
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
3d4c3f9e4f [rubygems/rubygems] util/rubocop -A --only Style/ParallelAssignment
5c88c77873
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
83f9aa8f02 [rubygems/rubygems] util/rubocop -A --only Style/Alias
fba6e94de9
2023-03-17 18:50:55 +09:00