183 Commits

Author SHA1 Message Date
David Rodríguez
5da1cc6c9c [rubygems/rubygems] Rely on PATH if Ruby is not installed in the same directory as the binstub
https://github.com/rubygems/rubygems/commit/ab7d65cc18

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2024-10-30 19:38:08 +00:00
David Rodríguez
116d6cbc83 [rubygems/rubygems] Simplify enable-load-relative prolog script creation
https://github.com/rubygems/rubygems/commit/f2ed507afe
2024-10-30 19:38:07 +00:00
David Rodríguez
d1324170b6 [rubygems/rubygems] Warning about PATH in --user-install mode is only necessary for gems with executables
https://github.com/rubygems/rubygems/commit/2fe0f452a2
2024-09-27 16:49:32 +00:00
David Rodríguez
fab01b15e9 [rubygems/rubygems] Remove temporary .lock files left around by gem installer
https://github.com/rubygems/rubygems/commit/edbb2e3475
2024-09-16 11:37:58 +00:00
Nobuyoshi Nakada
30176e3f23 [rubygems/rubygems] Ensure that the lock file will be removed
https://github.com/rubygems/rubygems/commit/2706acb271
2024-09-06 14:46:43 +00:00
Nobuyoshi Nakada
5afee4d795 [rubygems/rubygems] Remove the lock file for binstubs
https://github.com/rubygems/rubygems/pull/7806#issuecomment-2241662488

https://github.com/rubygems/rubygems/commit/4f06ee234a
2024-09-06 14:46:42 +00:00
David Rodríguez
e4825a5194 [rubygems/rubygems] Fix another race condition
We also need to protect prior removal of the binstub, otherwise it can
happen that:

* Process A removes prior binstub FOO.
* Process B removes prior binstub FOO (does nothing actually because Process A already removed it).
* Process A writes binstub FOO for gem BAR from the beginning of file.
* Process B writes binstub FOO for gem BAZ from the beginning of file.

Similarly as before, if binstub FOO for gem BAR is bigger that binstub
FOO for gem BAZ, garbage bytes will be left around at the end of the
file, corrupting the binstub.

The solution is to also protect removal of the previous binstub. To do
this, we use a file lock on an explicit `.lock` file.

https://github.com/rubygems/rubygems/commit/d99a80e62d
2024-07-08 14:38:31 +09:00
David Rodríguez
d90a930ede [rubygems/rubygems] Properly protect writing binstubs with a file lock
There's an issue when multiple processes try to write the same binstub.
The problem is that our file locking mechanism is incorrect because
files are truncated _before_ they are locked. So it can happen that:

* Process A truncates binstub FOO.
* Process B truncates binstub FOO.
* Process A writes binstub FOO for gem BAR from the beginning of file.
* Process B writes binstub FOO for gem BAZ from the beginning of file.

If binstub FOO for gem BAR is bigger than binstub FOO for gem BAZ, then
some bytes will be left around at the end of the binstub, making it
corrupt.

This was not a problem in our specs until the spec testing binstubs with
the same name coming from different gems changed from using gems named
"fake" and "rack" to using gems named "fake" and "myrack". Because of
the difference in gem name length, the generated binstub for gem
"myrack" is now longer, causing the above problem if binstub for gem
myrack is written first.

The solution is to make sure when using flock to always use modes that
DON'T truncate the file when opening it. So, we use `r+` if the file
exists previously (it requires the file to exist previously), otherwise
we use `a+`.

https://github.com/rubygems/rubygems/commit/ce8bcba90f
2024-07-08 14:38:30 +09:00
David Rodríguez
6db1c53fce [rubygems/rubygems] Remove unnecessary FileUtils usage
All other `chmod` usages in the file use `File.chmod`, so keep it
consistent.

https://github.com/rubygems/rubygems/commit/3dc0cf8703
2024-07-08 14:38:28 +09:00
David Rodríguez
5c826ebea5 [rubygems/rubygems] Protect binstub access during creation with a flock
https://github.com/rubygems/rubygems/commit/88e3f1d23c
2024-06-28 10:49:07 +00:00
Yuta Saito
273d41b9e3 [rubygems/rubygems] Add --target-rbconfig option to gem install and gem update commands
This patch adds `--target-rbconfig` option to specify the rbconfig.rb file
for the deployment target platform. This is useful when cross-compiling
gems. At the moment, this option is only available for `extconf.rb`-based
extensions.

https://github.com/rubygems/rubygems/commit/cf2843f7a2
2024-06-18 00:59:35 +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 Rodríguez
0ff34aa13e [rubygems/rubygems] More improves to default gem home selection for installation
https://github.com/rubygems/rubygems/commit/966daf7d42
2023-12-16 10:07:05 +08:00
Vít Ondruch
612616925b
[rubygems/rubygems] Allow "default_user_install" to be overridden.
For Ruby re-distributors, automatic user-install might be the right
default. Therefore printing warning about installing into user directory
is not always desirable. Let the default_user_install method be
customizable.

https://github.com/rubygems/rubygems/commit/2320dba544
2023-12-14 20:22:49 +08:00
Vít Ondruch
befbcfd90c [rubygems/rubygems] Explain the 3 states options[:user_install] can have.
This was issue previously, so hopefully this comment tries to state this
explicitly for future readers.

https://github.com/rubygems/rubygems/commit/8ccd830f85
2023-12-13 12:16:55 +09:00
Vít Ondruch
402fd96ddc [rubygems/rubygems] Make sure --no-user-install is respected for auto user installation
The `options[:user_install]` might have three states:
* `true`: `--user-install`
* `false`: `--no-user-install` and
* `nil`: option was not specified

However, this had not been respected previously and the `false` and `nil`
were treated the same. This could lead to auto user installation despite
`--no-user-install` being specified on the command line.

Fixes https://github.com/rubygems/rubygems/pull/7237

https://github.com/rubygems/rubygems/commit/9281545474
2023-12-13 12:16:55 +09:00
Vít Ondruch
b37288c047
[rubygems/rubygems] Make the "auto-user-install" logic easier to follow
https://github.com/rubygems/rubygems/commit/4b4d9c0106
2023-12-12 10:04:56 +09:00
Samuel Giddins
505715ddf1 [rubygems/rubygems] Fewer allocations in gem installation
For now, on a small rails app I have hanging around:

```
==> memprof.after.txt <==
Total allocated: 872.51 MB (465330 objects)
Total retained:  40.48 kB (326 objects)

==> memprof.before.txt <==
Total allocated: 890.79 MB (1494026 objects)
Total retained:  40.40 kB (328 objects)
```

Not a huge difference in memory usage, but it's a drastic improvement
in total number of allocations.

Additionally, this will pay huge dividends once
https://github.com/ruby/zlib/pull/61 is merged, as it will allow us to
completely avoid allocations in the repeated calls to readpartial,
which currently accounts for most of the memory usage shown above.

https://github.com/rubygems/rubygems/commit/f78d45d927
2023-12-11 23:14:58 +00: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
Ellen Marie Dash
7d32830b8c [rubygems/rubygems] Make --build-root disable auto-user-install.
https://github.com/rubygems/rubygems/commit/6a06b0763f
2023-12-07 13:56:23 +09:00
David Rodríguez
33bd956257 [rubygems/rubygems] Better approach to falling back to user installation when GEM_HOME not writable
https://github.com/rubygems/rubygems/commit/f67bced16b
2023-12-07 13:56:22 +09:00
David Rodríguez
7ab877761e [rubygems/rubygems] Instead of checking writability, try to write
Checking writability is prone to errors. For example:

$ mkdir -p foo/bar
$ chmod -w foo
$ touch foo/bar/baz # succeeds even if foo is not writable

https://github.com/rubygems/rubygems/commit/6056138b6a
2023-12-05 14:28:41 +09:00
Benoit Daloze
bbfd735b88 [rubygems/rubygems] TruffleRuby uses a bash prelude in default launchers
https://github.com/rubygems/rubygems/commit/e119f4208a
2023-11-13 14:57:15 +00: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
2d719cd146
[rubygems/rubygems] Remove unnecessary rescue
https://github.com/rubygems/rubygems/commit/c0b549f943
2023-11-08 09:04:28 +09:00
Vít Ondruch
42cf1307c3
[rubygems/rubygems] Make the user installation less exceptional
The main purpose is to put handling of user installation into the same
place as e.g. handling the --build-root option handling. There is no
reason why the --build-root option should not prefix also paths used for
user installation.

Please note that the `util_installer` in
`test_generate_plugins_with_user_install` enforced the `:install_dir`,
which is against what user install is about.

https://github.com/rubygems/rubygems/commit/0b10cb41aa
2023-11-08 09:04:28 +09:00
Ellen Marie Dash
28a6c4a1ad [rubygems/rubygems] Update incorrect comments.
https://github.com/rubygems/rubygems/commit/6b21f593f3
2023-10-11 19:07:28 +00:00
Ellen Marie Dash
e84b73398b [rubygems/rubygems] Call check_that_user_bin_dir_is_in_path ANY time Gem.paths.home == Gem.user_dir.
(As opposed to only if `--user-install` is passed.)

https://github.com/rubygems/rubygems/commit/0b42d0e869
2023-10-11 19:07:28 +00:00
Sutou Kouhei
d83f32c34b [rubygems/rubygems] Load plugin immediately
We can install RubyGems plugin by "gem install XXX". The installed
plugin is used from the NEXT "gem ...".

For example, "gem install gem-src kaminari" doesn't use gem-src plugin
for kaminari. "gem install gem-src && gem install kaminari" uses
gem-src plugin for kaminari.

How about loading a plugin immediately when the plugin is installed?
If this proposal is implemented, "gem install gem-src kaminari" works
like "gem install gem-src && gem install kaminari".

https://github.com/rubygems/rubygems/commit/4917d96f4c
2023-05-25 21:51:15 +00:00
Hiroshi SHIBATA
d89cc317c6
util/rubocop -A --only Style/NumericLiteralPrefix 2023-04-11 19:12:28 +09:00
Vít Ondruch
69460791cc
[rubygems/rubygems] Improve comment explaining the neccessity of write_default_spec method.
The intention is not obvious from the commit log and it might avoid
temptation to remove the method without further consideration.

https://github.com/rubygems/rubygems/commit/8e17c50f64
2023-04-06 13:07:16 +09:00
Hiroshi SHIBATA
e003784fc8 [rubygems/rubygems] util/rubocop -A --only Style/RegexpLiteral
https://github.com/rubygems/rubygems/commit/9264d83421
2023-04-05 09:50:29 +00:00
Hiroshi SHIBATA
a881b33818 [rubygems/rubygems] util/rubocop -A --only Performance/RegexpMatch
https://github.com/rubygems/rubygems/commit/52ae4452c2
2023-04-04 12:20:43 +00:00
Josef Šimánek
1cbb501127
Onboard Rubocop Naming/MemoizedInstanceVariableName rule to RubyGems. 2023-03-28 15:27:35 +09: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
0eef33e113 [rubygems/rubygems] util/rubocop -A --only Style/Next
https://github.com/rubygems/rubygems/commit/e5868e92f7
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
ee7475734f [rubygems/rubygems] util/rubocop -A --only Style/BarePercentLiterals
https://github.com/rubygems/rubygems/commit/02d8147243
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
66bd2c1a1c [rubygems/rubygems] util/rubocop -A --only Style/CommentAnnotation
https://github.com/rubygems/rubygems/commit/4e77a1d1d5
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
567db6064b [rubygems/rubygems] util/rubocop -A --only Style/NestedParenthesizedCalls
https://github.com/rubygems/rubygems/commit/a875fdb535
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
f70b46dbc7
More debug for 75829f4d37d31658aeebd9799b513e35fea805e0 2023-03-06 13:01:54 +09:00
Hiroshi SHIBATA
d9fd048351 [rubygems/rubygems] blade is hosted under ruby-lang.org now
https://github.com/rubygems/rubygems/commit/00fdef8a41
2023-01-23 05:55:46 +00:00
David Rodríguez
24fd2f73d0 Resync Bundler & RubyGems 2022-09-08 11:25:03 +09:00
Hiroshi SHIBATA
44264b4fee Merge rubygems/bundler HEAD.
Pick from dfbb5a3811
2022-08-09 12:05:19 +09:00
David Rodríguez
542040fb83 [rubygems/rubygems] Warn dangling symlinks
https://github.com/rubygems/rubygems/commit/425b78637f
2022-08-04 13:36:45 +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
Hiroshi SHIBATA
437a5ae9d6 Merge RubyGems and Bundler master 2022-07-13 14:11:55 +09:00