Commit graph

326 commits

Author SHA1 Message Date
Hiroshi SHIBATA
4bb5ce8188 [rubygems/rubygems] util/rubocop -A --only Style/StringLiteralsInInterpolation
cb554f6eb7
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
9a1269eaaa [rubygems/rubygems] util/rubocop -A --only Layout/MultilineArrayBraceLayout
f4f45ab27e
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
fe1b0661cb [rubygems/rubygems] Removed RUBY_PATCHLEVEL and modify condition for ruby_version
b420e287a3
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
8c6b349805 [rubygems/rubygems] Removed Gem.datadir.
https://github.com/rubygems/rubygems/pull/2216 is imcomplete to remove this method.

34ef915d12
2023-03-13 09:54:04 +00: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.

1df5009e14

Co-authored-by: Xavier Noria <fxn@hashref.com>
2023-01-31 10:49:08 +09:00
Hiroshi SHIBATA
a43f1d90c2 Merge RubyGems and Bundler master
from 0635c1423d
2023-01-10 15:53:07 +09: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.

cad4cf16cf
2023-01-08 08:09:33 +00:00
Hiroshi SHIBATA
b7ad60a794 Merge RubyGems/Bundler master
from 72fd3dd209
2022-12-26 15:09:21 +09:00
David Rodríguez
8f05e4f54b Update Bundler to 2.4.1 & and RubyGems to 3.4.1 2022-12-25 05:55:36 +09:00
Hiroshi SHIBATA
f6620037ba Merge RubyGems-3.4.0 and Bundler-2.4.0 2022-12-24 16:57:07 +09:00
Ellen Marie Dash
82b86b4c97 [rubygems/rubygems] Delete partial file and re-raise on Errno::ENOSPC.
Add test for not leaving empty files if ENOSPC is raised during 'gem install'

8e0e20f079
2022-12-02 19:21:08 +00:00
Yusuke Endoh
bc3ac86795 [rubygems/rubygems] require bundler/setup only when Bundler is not defined
... to prevent "circular require" when `--disable-gems` is used.

This is a simplified case of e5a0abc5de

```
$ bundle exec ruby -we 'system("ruby", "-w", "--disable-gems", "-e", "")'
<internal:/home/mame/work/ruby/local/lib/ruby/3.2.0+3/rubygems/core_ext/kernel_require.rb>:85: warning: <internal:/home/mame/work/ruby/local/lib/ruby/3.2.0+3/rubygems/core_ext/kernel_require.rb>:85: warning: loading in progress, circular require considered harmful - /home/mame/work/ruby/local/lib/ruby/3.2.0+3/bundler/setup.rb
```

When bundler/setup is require'ed under --disable-gems mode, it loads
rubygems by `require "rubygems" unless defined?(Gem)` in
0b1f682a6d/bundler/lib/bundler/rubygems_integration.rb (L3)
In this case, require'ing bundler/setup from rubygems.rb is circular.

This change makes rubygems.rb to require "bundler/setup" only when
`Bundler` is not defined.

b4608dee5e
2022-12-02 04:12:16 +00:00
Yusuke Endoh
b5f809c496 [rubygems/rubygems] Load "bundler/setup" in lib/rubygems.rb
Ruby interpreter loads some special gems at startup: did_you_mean,
error_highlight, and syntax_suggest. These gems are loaded before
`bundler/setup` is loaded by `RUBYOPT=-rbundler/setup`.
So, the versions of the gems are not controllable by Gemfile.

This change will `require "bundler/setup"` in rubygems.rb (i.e., before
the special gems are loaded). Now `bundle exec` sets an environment
variable `BUNDLER_SETUP`, and rubygems requires the variable if defined.

See also: https://bugs.ruby-lang.org/issues/19089

963cb65a2d
2022-11-10 22:45:31 +00:00
Hiroshi SHIBATA
44264b4fee Merge rubygems/bundler HEAD.
Pick from dfbb5a3811
2022-08-09 12:05:19 +09:00
Hiroshi SHIBATA
71794a75db Merge rubygems/bundler HEAD
Pick from 8331e63263
2022-08-03 13:14:10 +09: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
fd0902bfcd [rubygems/rubygems] Move fileutils require to be even more lazy
If directories are already created (the common case), fileutils won't be
required at all.

63a9b94fc9
2022-07-18 23:24:38 +09:00
David Rodríguez
f83c5de6d5 [rubygems/rubygems] Improve error message when operating_system.rb fails to load
Show an absolute path instead of an unhelpful relative path.

f1eed36e2f
2022-06-27 17:03:24 +09:00
David Rodríguez
12a5fa408b Sync RubyGems & Bundler with upstream repo 2022-06-24 10:52:02 +09:00
David Rodríguez
ba38318827 [rubygems/rubygems] Unify loading Gem::Requirement
It was being explicitly required from `Gem::Specification` but also a
strange autoload was set for it at `Gem::Version`. The autoload was non
standard because it should've been done in the `Gem` module, not in
`Gem::Specification`, since that's where the constant is expected to get
defined. Doing this might get deprecated in the future, and it was not
being effective anyways due to the explicit require.

Unify everything with an `autoload` at the right place.

174ea3e24c
2022-06-06 18:36:31 +09:00
Hiroshi SHIBATA
aeea88174d
Merge RubyGems and Bundler HEAD
125415593e
2022-05-20 17:32:19 +09:00
Hiroshi SHIBATA
1056489ea3 Merge 3f7d0352e8 2022-04-28 19:08:49 +09:00
Hiroshi SHIBATA
678d58c850 Merge rubygems master 1e4eda741d732ca1bd7031aef0a16c7348adf7a5 2022-04-28 19:08:49 +09:00
Peter Zhu
1a2490b564 [rubygems/rubygems] Fix formatting in docs
rdoc uses + for typewriter font rather than backticks.

be320f1e0c
2022-04-14 16:24:09 +09:00
Kazuhiro NISHIYAMA
7aabdbe837 [rubygems/rubygems] Fix a typo
3e06a91435
2022-03-15 11:37:43 +09:00
David Rodríguez
2b7025e680 [rubygems/rubygems] Rename Gem.open_with_flock to Gem.open_file
Since it only uses `flock` on Windows.

b877de4d9c
2022-01-20 06:45:28 +09:00
David Rodríguez
ec5bde1a80 [rubygems/rubygems] Restrict flock to Windows
It was introduced to fix some race conditions there, but it doesn't seem
necessary on other systems and it's actually causing issues there.

27b682c812
2022-01-20 06:45:27 +09:00
Hiroshi SHIBATA
d22511fd75 Merge rubygems/rubygems HEAD.
Picked at 12aeef6ba9a3be0022be9934c1a3e4c46a03ed3a
2022-01-19 15:01:44 +09:00
Hiroshi SHIBATA
d6311cb1ca Track RubyGems 3.4.0dev and Bundler 2.4.0dev 2021-12-27 10:45:36 +09:00
Masataka Pocke Kuwabara
73707e5c51 [rubygems/rubygems] Make SpecificationPolicy autoload constant
It reduces memory usage about 204kb (1.4%).

b7d4b8c8a6
2021-12-27 10:45:36 +09:00
Hiroshi SHIBATA
da6a5e3ed1 Merge RubyGems-3.3.3 and Bundler-2.3.3 2021-12-25 07:40:52 +09:00
Yusuke Endoh
71e85ec9b5
[rubygems/rubygems] Do not use IO#flock on Solaris
`io.flock(File::LOCK_EX)` fails on Solaris when the io is opened as
read-only. Due to this issue, `make install` of the ruby package failed
on Solaris.

5905d17ab2
2021-12-24 16:04:29 +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
69dc2ea465 Merge RubyGems-3.3.0 and Bundler-2.3.0 2021-12-21 15:27:05 +09:00
David Rodríguez
9f87c0cc6d [rubygems/rubygems] Pass :bimode explicitly to File.open
The `File::BINARY` flag is apparently ignored due to a ruby bug, and
thus writing can cause encoding issues.

db4efbebf2
2021-12-15 19:46:44 +09:00
Hiroshi SHIBATA
7e084ed707 Merge RubyGems and Bundler master
Merge from 793ad95ecb
2021-12-15 18:05:18 +09:00
Kevin Logan
eb2d3c19fe [rubygems/rubygems] Properly fetch Gem#latest_spec_for with multiple sources
a93ec63df3
2021-12-10 20:54:29 +09:00
Hiroshi SHIBATA
0b53a8895f
Merge rubygems master fd676ac464491afaa0baf5435cb11b3f86229cbd 2021-12-01 11:00:10 +09:00
David Rodríguez
7fd88da935 [rubygems/rubygems] Fix race condition when reading & writing gemspecs concurrently
When bundler parallel installer installs gems concurrently, one can get
confusing warnings like the following:

```
"[/home/runner/work/rubygems/rubygems/bundler/tmp/2/gems/system/specifications/zeitwerk-2.4.2.gemspec] isn't a Gem::Specification (NilClass instead).
```

I've got these warnings several times in the past, but I never managed
to reproduce them, and never look deeply into the root cause, but this
time a got a cause that reproduced quite frequently, so I looked into
it.

The problem is one thread reading a gemspec while another thread is
writing it. The write of the gemspec was not protected, so
`Gem::Specification.load` could end up seeing a truncated gemspec and
thus throw this warning.

The fix involve two changes:

* Change the methods that write gemspecs to use `Gem.binary_write` which
  is protected by a lock.

* Fix `Gem.binary_write` to create the file lock at file creation time,
  not when the file already exists after.

The realworld user problem caused by this issue happens in bundler, but
I'm fixing it in rubygems first, and then I'll backport to bundler
whatever needs backporting to fix the issue on the bundler side.

a672e7555c
2021-11-30 20:54:05 +09:00
David Rodríguez
54ae3f587e [rubygems/rubygems] Prefer require_relative to require for internal requires
c74fc58695
2021-08-31 19:06:14 +09:00
Daniel Niknam
717ad64f41 [rubygems/rubygems] Replace StandardError with Exception
We think it's unlikely that `rubygems/defaults/operating_system` could be shipped with a SyntaxError so StandardError could be better choice to prevent "false positives" errors.

1f73e784dd
2021-08-31 19:06:14 +09:00
Daniel Niknam
34e073c0ca [rubygems/rubygems] Reword the message
For errors that could happened while loading `rubygems/defaults/operating_system`

6e1e2141f8
2021-08-31 19:06:14 +09:00
Daniel Niknam
aafc615b4a [rubygems/rubygems] Enhance error handling when loading the rubygems/defaults/operating_system file
When loading `rubygems/defaults/operating_system`
- we want to keep it silent if the raised exception is a LoadError
- we want to print a message in other cases and ask users to report the issue to their OS support.

Ruby 3 comes with special error handling for loading `rubygems` and it will show a warning when LoadError exception raised for requiring 'rubygem'.
Because of that, we decided to leave the LoadError scenario as it is.
Reference: d1998d8767/gem_prelude.rb (L1-L5)

0a97e12fe1
2021-08-31 19:06:14 +09:00
David Rodríguez
9fa5c4cd07 [rubygems/rubygems] Also load user installed rubygems plugins
82960c262f
2021-08-31 19:06:14 +09:00
David Rodríguez
2d0d1c339a [rubygems/rubygems] Recommend bundle install rather than gem install -g
4028cbc408
2021-08-31 19:06:14 +09:00
David Rodríguez
1663dd5f73 [rubygems/rubygems] Simplify rescue of bundler errors
As far as I understand, this block should only be run when
`bundler/setup` fails. The only other case where these errors could be
run is when bundler itself is required.

If bundler itself fails to be required or activated (like in old rubies
where it was not a default gem, for example), the raw error is much more
helpful than this message.

So we can move the rescue after bundler is succesfully required, and
that simplifies the list of exceptions that we need to track to just
`Bundler::Error`.

3663c11e93
2021-08-31 19:06:14 +09:00
David Rodríguez
0aa9eb9eed [rubygems/rubygems] Move list of exceptions to the rescue clause
Instead of having to match classes and re-raise in the exception body.

5edf74b781
2021-08-31 19:06:14 +09:00
David Rodríguez
87dfb55c16 [rubygems/rubygems] Use Gem.use_gemdeps only from binstubs
The previous behavior was to automatically require `bundler/setup`
everytime `rubygems` was required, which I think was too much.

b25379a295
2021-08-31 19:06:14 +09:00
David Rodríguez
d9ecc97f33 [rubygems/rubygems] Remove bad TODO
The commented out code causes failing tests because it's not correct.

38f0eca91a
2021-08-31 19:06:14 +09:00