Commit graph

171 commits

Author SHA1 Message Date
David Rodríguez
0ff34aa13e [rubygems/rubygems] More improves to default gem home selection for installation
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.

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.

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

9281545474
2023-12-13 12:16:55 +09:00
Vít Ondruch
b37288c047
[rubygems/rubygems] Make the "auto-user-install" logic easier to follow
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.

f78d45d927
2023-12-11 23:14:58 +00:00
David Rodríguez
2755cb1b2f [rubygems/rubygems] Use modern hashes consistently
bb66253f2c
2023-12-07 22:29:33 +00:00
Ellen Marie Dash
7d32830b8c [rubygems/rubygems] Make --build-root disable auto-user-install.
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
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

6056138b6a
2023-12-05 14:28:41 +09:00
Benoit Daloze
bbfd735b88 [rubygems/rubygems] TruffleRuby uses a bash prelude in default launchers
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
10c26a483d
2023-11-13 11:06:10 +09:00
David Rodríguez
2d719cd146
[rubygems/rubygems] Remove unnecessary rescue
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.

0b10cb41aa
2023-11-08 09:04:28 +09:00
Ellen Marie Dash
28a6c4a1ad [rubygems/rubygems] Update incorrect comments.
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.)

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".

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.

8e17c50f64
2023-04-06 13:07:16 +09:00
Hiroshi SHIBATA
e003784fc8 [rubygems/rubygems] util/rubocop -A --only Style/RegexpLiteral
9264d83421
2023-04-05 09:50:29 +00:00
Hiroshi SHIBATA
a881b33818 [rubygems/rubygems] util/rubocop -A --only Performance/RegexpMatch
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
05cc97bdf8
2023-03-23 17:18:49 +09:00
Hiroshi SHIBATA
0eef33e113 [rubygems/rubygems] util/rubocop -A --only Style/Next
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
02d8147243
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
66bd2c1a1c [rubygems/rubygems] util/rubocop -A --only Style/CommentAnnotation
4e77a1d1d5
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
567db6064b [rubygems/rubygems] util/rubocop -A --only Style/NestedParenthesizedCalls
a875fdb535
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
4bb5ce8188 [rubygems/rubygems] util/rubocop -A --only Style/StringLiteralsInInterpolation
cb554f6eb7
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
f70b46dbc7
More debug for 75829f4d37 2023-03-06 13:01:54 +09:00
Hiroshi SHIBATA
d9fd048351 [rubygems/rubygems] blade is hosted under ruby-lang.org now
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
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
Hiroshi SHIBATA
aeea88174d
Merge RubyGems and Bundler HEAD
125415593e
2022-05-20 17:32:19 +09:00
David Rodríguez
9a20bcd5c8 [rubygems/rubygems] I don't think this is necessary
836f3e5aa5
2022-04-16 22:58:34 +09:00
David Rodríguez
7d42b442bb [rubygems/rubygems] Support binstubs with --enable-load-relative prolog
32a5e9057a
2022-01-15 00:00:11 +09:00
David Rodríguez
044b0ae8e0 [rubygems/rubygems] Extract a bit of common logic to methods
9a1b891435
2022-01-15 00:00:10 +09:00
David Rodríguez
810516ca31 [rubygems/rubygems] Fix method documentation to be more correct English
bcffd92c48
2022-01-15 00:00:09 +09:00
David Rodríguez
1976b38f7a [rubygems/rubygems] Add support in binstubs for trampolining bundler
If `bundler _<version>_` is given, I guess the most reasonable approach
is to completely skip version switching, because the user is technically
opting out of it. But since binstubs completely remove this argument
from `ARGV` after processing it, we have no way of detecting that it was
actually passed in the first place in order to skip the feature. So we
set `BUNDLER_VERSION` explicitly in this case.

e0f360d6d7
2021-12-20 07:42:53 +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
d7f6cb0f78 [rubygems/rubygems] Revert "Remove spec file before building"
This reverts commit af604436d8141c34cb2e1e645b9b0d47bfd55a55.

The issue that led to introducing it was never reproduced. I tried to
repro with this patch and it still works just fine. Since this removal
is getting in the middle for some race conditions I'm facing, I'm
reverting the patch.

2dd267f0e4
2021-11-30 20:54:05 +09:00
David Rodríguez
8bdb56fcaf [rubygems/rubygems] Protect specs access at a finer level
c8cc053bde
2021-11-18 04:37:28 +09:00
Hiroshi SHIBATA
f3bda8987e
Merge the master branch of rubygems repo
Picked from 4b498709a0
2021-11-16 20:19:13 +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
David Rodríguez
553ee573d4 [rubygems/rubygems] Don't use gemdeps on bundler binstub
320fdc1513
2021-08-31 19:06:14 +09:00