Граф коммитов

257 Коммитов

Автор SHA1 Сообщение Дата
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.

https://github.com/rubygems/rubygems/commit/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.

https://github.com/rubygems/rubygems/commit/be320f1e0c
2022-04-14 16:24:09 +09:00
Kazuhiro NISHIYAMA 7aabdbe837 [rubygems/rubygems] Fix a typo
https://github.com/rubygems/rubygems/commit/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.

https://github.com/rubygems/rubygems/commit/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.

https://github.com/rubygems/rubygems/commit/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%).

https://github.com/rubygems/rubygems/commit/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.

https://github.com/rubygems/rubygems/commit/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.

https://github.com/rubygems/rubygems/commit/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
https://github.com/rubygems/rubygems/commit/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.

https://github.com/rubygems/rubygems/commit/a672e7555c
2021-11-30 20:54:05 +09:00
David Rodríguez 54ae3f587e [rubygems/rubygems] Prefer `require_relative` to `require` for internal requires
https://github.com/rubygems/rubygems/commit/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.

https://github.com/rubygems/rubygems/commit/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`

https://github.com/rubygems/rubygems/commit/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)

https://github.com/rubygems/rubygems/commit/0a97e12fe1
2021-08-31 19:06:14 +09:00
David Rodríguez 9fa5c4cd07 [rubygems/rubygems] Also load user installed rubygems plugins
https://github.com/rubygems/rubygems/commit/82960c262f
2021-08-31 19:06:14 +09:00
David Rodríguez 2d0d1c339a [rubygems/rubygems] Recommend `bundle install` rather than `gem install -g`
https://github.com/rubygems/rubygems/commit/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`.

https://github.com/rubygems/rubygems/commit/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.

https://github.com/rubygems/rubygems/commit/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.

https://github.com/rubygems/rubygems/commit/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.

https://github.com/rubygems/rubygems/commit/38f0eca91a
2021-08-31 19:06:14 +09:00
David Rodríguez 19d77a1cfc [rubygems/rubygems] Remove unnecessary spec manipulation
https://github.com/rubygems/rubygems/commit/c7c00c280f
2021-08-31 19:06:14 +09:00
David Rodríguez 88e46cf6b8
[rubygems/rubygems] Remove all `syck` traces from `rubygems`
After reading [this blog
post](https://blog.rubygems.org/2011/08/31/shaving-the-yaml-yak.html),
published almost 10 years ago already, my understanding is that this
problem could come up in two ways:

* Rubygems.org serving corrupted gemspecs". As far as I understand this
was fixed in rubygems.org a lot time ago, since
https://github.com/rubygems/rubygems.org/pull/331.

* Clients having a ten years old gemspec cache with some of these bad
gemspecs. In this case, there's no easy solution but I think ten years
is enough and rebuilding the cache should do the trick.

So, I think it's time we remove this.

https://github.com/rubygems/rubygems/commit/afcb15d556
2021-07-27 09:25:56 +09:00
Hiroshi SHIBATA c082c6eb7c Sync RubyGems and Bundler with upstream 2021-07-07 15:31:52 +09:00
David Rodríguez 5b0abba931 Sync bundler & rubygems 2021-05-11 11:29:41 +09:00
Hiroshi SHIBATA 96741765d8 Merge the master branch of RubyGems 2021-04-15 15:36:15 +09:00
David Rodríguez 53468cc111 Sync latest development version of bundler & rubygems 2021-03-08 13:47:35 +09:00
Hiroshi SHIBATA 5537adf719 Track RubyGems master(3.3.0.dev) branch at 55634a8af18a52df86c4275d70fa1179118bcc20 2021-01-04 13:14:43 +09:00
Hiroshi SHIBATA 339227363c Merge RubyGems 3.2.3 and Bundler 2.2.3 2020-12-23 10:17:41 +09:00
Hiroshi SHIBATA 0e40cc9b19 Merge RubyGems 3.2.2 and Bundler 2.2.2 2020-12-18 13:33:18 +09:00
Hiroshi SHIBATA 2fa9f3c032 Prepare to release rubygems-3.2.1 and bundler-2.2.1 2020-12-15 10:54:09 +09:00
Hiroshi SHIBATA 4aca77edde Merge prepare version of RubyGems 3.2.0 2020-12-08 17:30:02 +09:00
Hiroshi SHIBATA ab6c4f8be3 Merge rubygems-3.2.0.rc.2 2020-10-15 14:12:02 +09:00
Hiroshi SHIBATA b717f73402
Revert "Manually merged from https://github.com/rubygems/rubygems/pull/2636"
31a6eaabc1 is obsoleted with
  https://github.com/rubygems/rubygems/pull/3820
2020-09-23 22:01:44 +09:00
Hiroshi SHIBATA 31a6eaabc1
Manually merged from https://github.com/rubygems/rubygems/pull/2636
Enable Style/EmptyLinesAroundClassBody rubocop cop.
2020-09-23 21:02:56 +09:00
David Rodríguez e0bfc77824 [rubygems/rubygems] Remove unnecessary guard clause
Since 1ccf0912a161d20e0c4a7b139fd76e8739a411ba, this method no longer
uses `Kernel.gem`, so this guard clause is now unnecessary.

https://github.com/rubygems/rubygems/commit/8a19e7401c
2020-07-31 21:07:19 +09:00
Jean Boussier 76722c4928 [rubygems/rubygems] Optimize Gem.already_loaded?
Profiling a simple `ruby -e '1'` I see:

```
==================================
  Mode: wall(10)
  Samples: 3414 (55.10% miss rate)
  GC: 856 (25.07%)
==================================
     TOTAL    (pct)     SAMPLES    (pct)     FRAME
       689  (20.2%)         669  (19.6%)     Gem.already_loaded?
       462  (13.5%)         462  (13.5%)     (marking)
       393  (11.5%)         393  (11.5%)     (sweeping)
       815  (23.9%)         365  (10.7%)     Gem::Specification.load
      1050  (30.8%)         156   (4.6%)     Gem.register_default_spec
       100   (2.9%)          84   (2.5%)     Gem::Specification#files
        64   (1.9%)          64   (1.9%)     Gem::BasicSpecification#internal_init
       136   (4.0%)          59   (1.7%)     <top (required)>
      2312  (67.7%)          58   (1.7%)     <top (required)>
        57   (1.7%)          57   (1.7%)     RbConfig.expand
        81   (2.4%)          55   (1.6%)     Gem::Requirement.parse
       191   (5.6%)          51   (1.5%)     <top (required)>
       128   (3.7%)          47   (1.4%)     Gem::Requirement#initialize
        41   (1.2%)          41   (1.2%)     Gem.suffix_regexp
       229   (6.7%)          35   (1.0%)     <module:Gem>
       260   (7.6%)          34   (1.0%)     Kernel#require
```

So clearly `Gem.already_loaded?` is a major hotspot.

After this optimization, it's down to:
```
==================================
  Mode: wall(10)
  Samples: 2653 (58.21% miss rate)
  GC: 718 (27.06%)
==================================
     TOTAL    (pct)     SAMPLES    (pct)     FRAME
       416  (15.7%)         416  (15.7%)     (marking)
       715  (27.0%)         312  (11.8%)     Gem::Specification.load
       299  (11.3%)         299  (11.3%)     (sweeping)
       279  (10.5%)         279  (10.5%)     Gem.already_loaded?
       564  (21.3%)         106   (4.0%)     Gem.register_default_spec
        95   (3.6%)          80   (3.0%)     Gem::Specification#files
        72   (2.7%)          72   (2.7%)     Gem::BasicSpecification#internal_init
       129   (4.9%)          58   (2.2%)     <top (required)>
        53   (2.0%)          53   (2.0%)     RbConfig.expand
      1697  (64.0%)          52   (2.0%)     <top (required)>
        68   (2.6%)          49   (1.8%)     Gem::Requirement.parse
       183   (6.9%)          48   (1.8%)     <top (required)>
       112   (4.2%)          44   (1.7%)     Gem::Requirement#initialize
       220   (8.3%)          33   (1.2%)     <module:Gem>
       250   (9.4%)          32   (1.2%)     Kernel#require
```

The idea is that the vast majority of the time `already_loaded?` won't match
anything. So by first looking for candidate paths that `end_with?` the file we
look for, we save `default_gem_load_paths.size` iterations and string concatenations.

https://github.com/rubygems/rubygems/commit/c60ce88d49
2020-07-31 21:07:19 +09:00
Hiroshi SHIBATA 832fe77879 Bump version to 3.2.0.rc.1 2020-07-31 21:07:19 +09:00
Karol Bucek e7b6e0ff58 [rubygems/rubygems] remove explicit require(s) for auto-loaded constant(s)
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
2020-07-31 21:07:19 +09:00
David Rodríguez a89665b7b1 Enforce no empty lines around class body in rubygems
To normalize the code style with `bundler`.
2020-07-31 21:07:19 +09:00