88 Commits

Author SHA1 Message Date
Hiroshi SHIBATA
00dc1cace8 Reapply "[rubygems/rubygems] Fix activation conflicts when circularly requiring a gem"
This reverts commit 04cf66765a8a9d48baea6d9aee266dc9aa21df27.
2024-01-22 09:57:10 +09:00
Hiroshi SHIBATA
d51f4c9288 Reapply "[rubygems/rubygems] Fix require of a default gem when unresolved gems depend on it"
This reverts commit 54552b89e73fc616ba47c1c87d33625af99cbce9.
2024-01-22 09:57:10 +09:00
Hiroshi SHIBATA
54552b89e7
Revert "[rubygems/rubygems] Fix require of a default gem when unresolved gems depend on it"
This reverts commit f1f5f22d22a149f20e019728b1ab35593d29d81a.
2024-01-19 12:12:33 +09:00
Hiroshi SHIBATA
04cf66765a
Revert "[rubygems/rubygems] Fix activation conflicts when circularly requiring a gem"
This reverts commit db44088c2a92040879386aa5f268db4c858e4e5b.

  https://github.com/ruby/ruby/actions/runs/7578672002/job/20641640821
  https://github.com/ruby/ruby/actions/runs/7578672002/job/20641641212
  https://github.com/ruby/ruby/actions/runs/7578672002/job/20641642031
2024-01-19 11:54:17 +09:00
David Rodríguez
db44088c2a [rubygems/rubygems] Fix activation conflicts when circularly requiring a gem
If a gem is required circular, and there are unresolved specs depending
on it, we may end up in an activation conflict.

The solution is to not try to activate unresolved gems when requiring a
default gem, regardless of it having already been activated or not.

https://github.com/rubygems/rubygems/commit/3b2b8f4e3e
2024-01-19 11:28:11 +09:00
David Rodríguez
f1f5f22d22 [rubygems/rubygems] Fix require of a default gem when unresolved gems depend on it
The following conditions must be met:

* A default gem is required.
* A previous require left some gems unresolved, and those dependencies
  themselves depend on the default gem.

In this case, rubygems require will first activate the default version
of the gem, then try to activate another unresolved version of the
default gem that conflicts with the first activation.

The solution is, if we are in the middle of requiring a default gem,
skip this step, because we have already activated it successfully.

https://github.com/rubygems/rubygems/commit/8cd5608db5

Co-authored-by: Stan Hu <stanhu@gmail.com>
2024-01-19 11:28:11 +09:00
David Rodríguez
8044e57907 [rubygems/rubygems] Add a comment to explain default gem activation
https://github.com/rubygems/rubygems/commit/291128268f
2024-01-19 11:28:10 +09: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
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
Nobuyoshi Nakada
0d86cc4caf [rubygems/rubygems] Use the dedicated method to convert file path
The dedicated method `File.path` to deal with pathname-like objects
has been provided since ruby 1.9.0.
Also adds a test for rubygems/rubygems#6837.

https://github.com/rubygems/rubygems/commit/258c6eda80
2023-07-30 01:36:23 +00:00
Nobuyoshi Nakada
989f3add62 Warn default gems which will be gemified in future 2023-07-28 14:57:10 +09:00
Nobuyoshi Nakada
70eeec0cad [rubygems/rubygems] Simplify double loop
https://github.com/rubygems/rubygems/commit/630dc02112
2023-07-25 04:52:54 +00:00
Nobuyoshi Nakada
1b27e7aa1f [rubygems/rubygems] Use Monitor#synchronize to ensure to exit
https://github.com/rubygems/rubygems/commit/b424353239
2023-07-25 04:52:54 +00:00
Hiroshi SHIBATA
f24a86d83f util/rubocop -A --only Layout/EmptyLineAfterMagicComment 2023-03-23 17:18:49 +09:00
Hiroshi SHIBATA
2e3cd1dc3e [rubygems/rubygems] Enabled Style/RedundantReturn cop
https://github.com/rubygems/rubygems/commit/05cc97bdf8
2023-03-23 17:18:49 +09:00
Hiroshi SHIBATA
1a60012612 [rubygems/rubygems] util/rubocop -A --only Lint/RescueException
https://github.com/rubygems/rubygems/commit/e8a5db50af
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
4bb5ce8188 [rubygems/rubygems] util/rubocop -A --only Style/StringLiteralsInInterpolation
https://github.com/rubygems/rubygems/commit/cb554f6eb7
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
83f9aa8f02 [rubygems/rubygems] util/rubocop -A --only Style/Alias
https://github.com/rubygems/rubygems/commit/fba6e94de9
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
583fbc627c [rubygems/rubygems] util/rubocop -A --only Layout/EmptyLinesAroundModuleBody
https://github.com/rubygems/rubygems/commit/48c88466b7
2023-03-17 18:50:55 +09:00
David Rodríguez
a47c54131d [rubygems/rubygems] Remove ensure part in require
I've seen this error sometimes but never found it helpful, since the
culprit has never been thread/monitor related, so it just adds noise.

Right now I'm seeing an issue in CI where we seem to be crashing during
ensure and showing a weird backtrace:

```
#<Thread:0x000055821d7a73b8 /home/runner/work/rubygems/rubygems/lib/rubygems/request_set.rb:167 run> terminated with exception (report_on_exception is true):
/home/runner/work/rubygems/rubygems/lib/rubygems/platform.rb:141:in `==': undefined local variable or method `to_a' for false:FalseClass (NameError)
Did you mean?  to_s
	from /home/runner/work/rubygems/rubygems/lib/rubygems/core_ext/kernel_require.rb:168:in `!='
	from /home/runner/work/rubygems/rubygems/lib/rubygems/core_ext/kernel_require.rb:168:in `require'
	from /home/runner/work/rubygems/rubygems/lib/rubygems.rb:441:in `block in ensure_subdirectories'
	from /home/runner/work/rubygems/rubygems/lib/rubygems.rb:437:in `each'
	from /home/runner/work/rubygems/rubygems/lib/rubygems.rb:437:in `ensure_subdirectories'
	from /home/runner/work/rubygems/rubygems/lib/rubygems.rb:413:in `ensure_gem_subdirectories'
	from /home/runner/work/rubygems/rubygems/lib/rubygems/resolver/specification.rb:110:in `download'
	from /home/runner/work/rubygems/rubygems/lib/rubygems/request_set.rb:173:in `block (2 levels) in install'
```

Let's get this out of the picture in case that helps clarify the
culprit.

https://github.com/rubygems/rubygems/commit/87ce40b70e
2023-03-17 18:50:55 +09:00
David Rodríguez
4cbfd87e5a [rubygems/rubygems] Allow disabling RubyGems require decorations
Currently Bundler needs to do cumbersome operations to revert custom
RubyGems require on a `bundler/setup` context. This causes issues when
third party gems also monkeypatch require, since Bundler will also undo
those decorations.

This commit allows it to use the simpler approach of properly telling
RubyGems that it needs to default to built-in require without any extra
magic.

https://github.com/rubygems/rubygems/commit/1df5009e14

Co-authored-by: Xavier Noria <fxn@hashref.com>
2023-01-31 10:49:08 +09:00
Nobuyoshi Nakada
55aa1a206c [rubygems/rubygems] LoadError#path on the caught exception does not need to protect
https://github.com/rubygems/rubygems/commit/a31f5d1a18
2023-01-08 08:09:34 +00:00
Nobuyoshi Nakada
1a1b653c9c [rubygems/rubygems] Let RDoc parse the doc of Kernel#require
Since RDoc does not parse string literals as documents, `eval` the
entire file instead of embedding in a here-document.
On the contrary, as `gem_original_require` alias is an implementation
detail but not for users, it should not be documented.

https://github.com/rubygems/rubygems/commit/cad4cf16cf
2023-01-08 08:09:33 +00:00
Takuya Noguchi
d7ffd3fea4
RubyGems: Enable Style/StringLiterals cop
Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
2022-07-22 12:07:23 +09:00
David Rodríguez
12a5fa408b Sync RubyGems & Bundler with upstream repo 2022-06-24 10:52:02 +09:00
Hiroshi SHIBATA
4aca77edde Merge prepare version of RubyGems 3.2.0 2020-12-08 17:30:02 +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
Yuki Nishijima
77ba8a1d61 [rubygems/rubygems] Use LoadError#path to figure out the argument passed to 'require'
https://github.com/rubygems/rubygems/commit/5995394ec4
2020-06-05 07:32:42 +09:00
David Rodríguez
b9d431a7b1 [rubygems/rubygems] Remove direct reference to PR
The code is quite different now, so I think the link might be even
confusing. If you want to know more, use git history.

https://github.com/rubygems/rubygems/commit/db872c7a18
2020-06-05 07:32:42 +09:00
David Rodríguez
f0f138aa5d [rubygems/rubygems] Fix $LOADED_FEATURES cache sometimes not respected
In the cases where the initial manually `-I` path resolution succeeded,
we were passing a full path to the original require effectively skipping
the `$LOADED_FEATURES` cache. With this change, we _only_ do the
resolution when a matching requirable path is found in a default gem. In
that case, we skip activation of the default gem if we detect that the
required file will be picked up for a `-I` path.

https://github.com/rubygems/rubygems/commit/22ad5717c3
2020-06-05 07:32:42 +09:00
David Rodríguez
07dca5c02c [rubygems/rubygems] Extract a local outside the loop
https://github.com/rubygems/rubygems/commit/da1492e9d7
2020-06-05 07:32:42 +09:00
David Rodríguez
5aa5aad48a [rubygems/rubygems] Refactor Gem.load_path_insert_index
https://github.com/rubygems/rubygems/commit/ae95885dff
2020-06-05 07:32:42 +09:00
David Rodríguez
a18e81d797 [rubygems/rubygems] Fix performance regression in require
Our check for `-I` paths should not go through all activated gems.

https://github.com/rubygems/rubygems/commit/00d98eb8a3
2020-06-05 07:32:42 +09:00
David Rodríguez
1039c32de6 [rubygems/rubygems] Simplify nested require exceptions
https://github.com/rubygems/rubygems/commit/7fbef2f0e3
2020-05-08 14:13:29 +09:00
David Rodríguez
96064e6f1c
Sync rubygems with current master (#2889) 2020-03-24 15:39:24 +09:00
Hiroshi SHIBATA
8c67080381
Revert "[rubygems/rubygems] Fix require issue with file extension priority"
This reverts commit d767da428c28b7b9fec56b383bb32f6f76c6ad26.

  It fails with spec/ruby/core/kernel/require_spec.rb:5
2020-02-06 22:07:39 +09:00
David Rodríguez
d767da428c
[rubygems/rubygems] Fix require issue with file extension priority
If `require "a"` is run when two folders have been specified in the -I
option including a "a.rb" file and a "a.so" file respectively, the ruby
spec says that the ".rb" file should always be preferred. However, the
logic we added in https://github.com/rubygems/rubygems/commit/6b81076d9
to make the -I option always beat default gems does not respect this
spec, creating a difference from the original ruby-core's require.

[the ruby spec says]: d80a6e2b22/core/kernel/shared/require.rb (L234-L246)

https://github.com/rubygems/rubygems/commit/b3944384f4
2020-02-06 21:57:18 +09:00
Kazuhiro NISHIYAMA
d336db6568
Fix a typo 2019-11-13 15:04:49 +09:00
Hiroshi SHIBATA
f36a53d038
Only enabled mon_owned condition with Ruby 2.5+ 2019-11-12 19:36:41 +09:00
Koichi Sasada
fef4370b40 check more. 2019-11-12 10:07:45 +09:00
Koichi Sasada
4a30fabfcf Monitor owner state check correctly.
Monitor can be owned at the beginning of this method.
2019-11-12 09:37:34 +09:00
Yusuke Endoh
2407e89725 Revert "Use untaint for File.symlink in kernel_require.rb"
This reverts commit d9978ce5d397866afae536db2aa708af3b7a4b2f.

Untaint was tentatively restored due to test failures.  But now, the
failed tests have been removed, so we can revert the tentative fix.
2019-11-12 08:39:38 +09:00
Hiroshi SHIBATA
d9978ce5d3
Use untaint for File.symlink in kernel_require.rb
Partly reverted 7d463e360b9c4718b17378eb52783116a01b884b
2019-11-12 08:03:26 +09:00
Koichi Sasada
b8d242d221 release RUBYGEMS_ACTIVATION_MONITOR correctly.
`File.symlink? safe_lp` can raise SecurityError and raising an
exception can leave RUBYGEMS_ACTIVATION_MONITOR locking. This
patch release it correctly.
2019-11-12 04:33:28 +09:00
Koichi Sasada
4be1e84d78 more messages 2019-11-12 04:13:54 +09:00
Koichi Sasada
a815053a3e check monitor is owning for debug 2019-11-12 04:03:33 +09:00
Hiroshi SHIBATA
7d463e360b Merge RubyGems 3.1.0.pre3
* 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.
2019-11-11 16:59:49 +09:00
David Rodríguez
f48655d04d Remove unneeded exec bits from some files
I noticed that some files in rubygems were executable, and I could think
of no reason why they should be.

In general, I think ruby files should never have the executable bit set
unless they include a shebang, so I run the following command over the
whole repo:

```bash
find . -name '*.rb' -type f -executable -exec bash -c 'grep -L "^#!" $1 || chmod -x $1' _ {} \;
```
2019-11-09 21:36:30 +09:00
David Rodríguez
4f87a1583d
[rubygems/rubygems] Introduce default prerelease requirement
https://github.com/rubygems/rubygems/commit/506c5bce49
2019-09-26 17:48:01 +09:00