Commit graph

14675 commits

Author SHA1 Message Date
David Rodríguez
2bfeedc082 [rubygems/rubygems] Simplify handling default gem caching
By the time `cached_gem` is called, default gem cache has already been
handled. So no need to try redownload it again, it's enough to check the
cache location directly.

70e10236b6
2024-09-16 13:13:43 +00:00
David Rodríguez
fab01b15e9 [rubygems/rubygems] Remove temporary .lock files left around by gem installer
edbb2e3475
2024-09-16 11:37:58 +00:00
David Rodríguez
7411caa103 [rubygems/rubygems] Make sure implementations of Gem.open_file_with_flock match
174a8e5284
2024-09-16 11:37:58 +00:00
Kevin Newton
f85efc9748 [ruby/prism] Expose main_script in serialization API
0b527ca93f
2024-09-13 19:13:21 +00:00
Hiroshi SHIBATA
3146cbbbc4
Dont't warn reline called from irb, reline is already declared at irb gemspec 2024-09-13 13:19:31 +09:00
Kevin Newton
38ba15beed [ruby/prism] Check errno for parsing directory
d68ea29d04
2024-09-12 13:43:04 -04:00
tomoya ishida
a542479a75 [ruby/irb] Remove KEYWORD_ALIASES which handled special alias name
of irb_break irb_catch and irb_next command
(https://github.com/ruby/irb/pull/1004)

* Remove KEYWORD_ALIASES which handled special alias name of irb_break irb_catch and irb_next command

* Remove unused instance variable user_aliases

Co-authored-by: Stan Lo <stan001212@gmail.com>

---------

f256d7899f

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-09-12 15:04:37 +00:00
David Rodríguez
12d7ead043 [rubygems/rubygems] Small simplification in Definition class
03ddfd7610

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2024-09-11 18:14:50 +00:00
David Rodríguez
e52d4d462f [rubygems/rubygems] Fix bundle exec rake install failing when local gem has extensions and gemspec DSL is being used
In a `bundle exec` context, the local specification will actually be
part of the known specifications, so RubyGems will assume it has already
been installed, which is not actually true.

This will cause `RequestSet` to rebuild extensions for a gem that's not
actually installed, causing errors.

The fix is to make sure detection of installed activation requests
considers not only that there's a known spec with the same full name as
the one being installed, but also that this spec is installed in the
same gem_home were pretend to install the new gem.

a8ef1286a6
2024-09-11 11:28:35 +00:00
David Rodríguez
89eba5074e [rubygems/rubygems] Only raise DSLError during Gemfile parsing when it's actually useful
DSLError prints the specific line in a Gemfile where the error was
raised. That's helpful when the error was explicitly raised by the
Gemfile DSL or, in the case it's implicitly raised, when the offending
code lives right in the Gemfile.

If it's an internal error, or something buried dowm in user code called
from the Gemfile, `DSLError` is not helpful since it hides the actual
culprit.

This commit tries to only raise `DSLError` in the cases mentioned above
and otherwise let the original error be raised.

b30ff5a682
2024-09-11 11:28:12 +00:00
David Rodríguez
1d72b3bd1a [rubygems/rubygems] Don't rescue Exception when evaluating Gemfile
Things like OOM, or StackOverflow should be raised immediately.

11691ce492
2024-09-11 11:28:12 +00:00
David Rodríguez
f0b9baa2d6 [rubygems/rubygems] Refactor setting current gemfile in DSL
b4ecb66224
2024-09-11 11:28:11 +00:00
David Rodríguez
1d768ebd71 [rubygems/rubygems] The dsl_path parameter in DSLError is documented as a string
ab44fa9ee4
2024-09-11 11:28:11 +00:00
Yuji Yaginuma
c37b667774 [rubygems/rubygems] Make an exe file executable when generating new gems
Currently, an exe file isn't executable when generating new gems
because it doesn't have the correct permission.
This PR sets the correct permission same as files under the `bin`.

6509bf128a
2024-09-11 04:41:20 +00:00
Nobuyoshi Nakada
a79907ed5e [ruby/tmpdir] Reject empty parent path
628c5bdc59
2024-09-10 08:44:50 +00:00
Nobuyoshi Nakada
f622548800 [ruby/resolv] Add spec extensions
3189d16b69
2024-09-10 08:33:32 +00:00
Hiroshi SHIBATA
a5d658cb7a [rubygems/rubygems] Removed duplicated dependencies that used by bundler inline
d46b6a49af
2024-09-10 02:50:48 +00:00
David Rodríguez
f8f9cecd70 [rubygems/rubygems] Retry resolution with activated gems if inline has conflicts
8d94c14ca0

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2024-09-10 02:50:47 +00:00
David Rodríguez
07fa9e3a8f [rubygems/rubygems] Remove unnecessary verification
`DSL#to_definition` already verifies this.

c596f0af83
2024-09-10 02:50:47 +00:00
David Rodríguez
d6baa6258c [rubygems/rubygems] Avoid having to redefine Definition#lock in inline mode
0b7be7bb77

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2024-09-10 02:50:46 +00:00
Koichi ITO
7a65334528 [ruby/prism] Fix a token incompatibility for Prism::Translation::Parser::Lexer
This PR fixes a token incompatibility between Parser gem and `Prism::Translation::Parser` for double splat argument.

## Parser gem (Expected)

Returns `tDSTAR` token:

```console
$ bundle exec ruby -Ilib -rparser/ruby33 -ve \
'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "def f(**foo) end"; p Parser::Ruby33.new.tokenize(buf)[2]'
ruby 3.4.0dev (2024-09-01T11:00:13Z master eb144ef91e) [x86_64-darwin23]
[[:kDEF, ["def", #<Parser::Source::Range example.rb 0...3>]], [:tIDENTIFIER, ["f", #<Parser::Source::Range example.rb 4...5>]],
[:tLPAREN2, ["(", #<Parser::Source::Range example.rb 5...6>]], [:tDSTAR, ["**", #<Parser::Source::Range example.rb 6...8>]],
[:tIDENTIFIER, ["foo", #<Parser::Source::Range example.rb 8...11>]], [:tRPAREN, [")", #<Parser::Source::Range example.rb 11...12>]],
[:kEND, ["end", #<Parser::Source::Range example.rb 13...16>]]]
```

## `Prism::Translation::Parser` (Actual)

Previously, the parser returned `tPOW` token when parsing the following:

```console
$ bundle exec ruby -Ilib -rprism -rprism/translation/parser33 -ve \
'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "def f(**foo) end"; p Prism::Translation::Parser33.new.tokenize(buf)[2]'
ruby 3.4.0dev (2024-09-01T11:00:13Z master eb144ef91e) [x86_64-darwin23]
[[:kDEF, ["def", #<Parser::Source::Range example.rb 0...3>]], [:tIDENTIFIER, ["f", #<Parser::Source::Range example.rb 4...5>]],
[:tLPAREN2, ["(", #<Parser::Source::Range example.rb 5...6>]], [:tPOW, ["**", #<Parser::Source::Range example.rb 6...8>]],
[:tIDENTIFIER, ["foo", #<Parser::Source::Range example.rb 8...11>]], [:tRPAREN, [")", #<Parser::Source::Range example.rb 11...12>]],
[:kEND, ["end", #<Parser::Source::Range example.rb 13...16>]]]
```

After the update, the parser now returns `tDSTAR` token for the same input:

```console
$ bundle exec ruby -Ilib -rprism -rprism/translation/parser33 -ve \
'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "def f(**foo) end"; p Prism::Translation::Parser33.new.tokenize(buf)[2]'
ruby 3.4.0dev (2024-09-01T11:00:13Z master eb144ef91e) [x86_64-darwin23]
[[:kDEF, ["def", #<Parser::Source::Range example.rb 0...3>]], [:tIDENTIFIER, ["f", #<Parser::Source::Range example.rb 4...5>]],
[:tLPAREN2, ["(", #<Parser::Source::Range example.rb 5...6>]], [:tDSTAR, ["**", #<Parser::Source::Range example.rb 6...8>]],
[:tIDENTIFIER, ["foo", #<Parser::Source::Range example.rb 8...11>]], [:tRPAREN, [")", #<Parser::Source::Range example.rb 11...12>]],
[:kEND, ["end", #<Parser::Source::Range example.rb 13...16>]]]
```

With this change, the following code could be removed from test/prism/ruby/parser_test.rb:

```diff
-          when :tPOW
-            actual_token[0] = expected_token[0] if expected_token[0] == :tDSTAR
```

`tPOW` is the token type for the behavior of `a ** b`, and its behavior remains unchanged:

```console
$ bundle exec ruby -Ilib -rprism -rprism/translation/parser33 -ve \
'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "a ** b"; p Prism::Translation::Parser33.new.tokenize(buf)[2]'
ruby 3.4.0dev (2024-09-01T11:00:13Z master eb144ef91e) [x86_64-darwin23]
[[:tIDENTIFIER, ["a", #<Parser::Source::Range example.rb 0...1>]], [:tPOW, ["**", #<Parser::Source::Range example.rb 2...4>]],
[:tIDENTIFIER, ["b", #<Parser::Source::Range example.rb 5...6>]]]
```

66bde35a44
2024-09-09 19:01:30 +00:00
Daniel Colson
966901b39d [rubygems/rubygems] Don't include hook templates in cached git source
With a default git setup, each cloned repo in the cache will end up with
~60K of sample git hooks. These files all end in `.sample`, and they are
disabled by default. Deleting them should be a no-op, and makes the
cache a bit smaller.

d2149999cd
2024-09-09 11:59:52 +00:00
David Rodríguez
155989415b [rubygems/rubygems] Avoid now unnecessary reset
511c7b211b
2024-09-09 08:46:02 +00:00
David Rodríguez
72e80c8f29 [rubygems/rubygems] Make gem exec use the standard GEM_HOME
032b3c518a
2024-09-09 08:46:01 +00:00
David Rodríguez
a304fe00f3 [rubygems/rubygems] Fix gem fetch always exiting with zero status code
5887e6dfa1
2024-09-09 08:44:27 +00:00
Earlopain
19c1f0233e [ruby/benchmark] Set required_ruby_version = ">= 2.1.0"
`Process.clock_gettime` only works since 2.1

94cfe56291
2024-09-08 16:43:50 +00:00
otegami
903f3790ad [ruby/open-uri] Update error message for request_specific_fields option validation
Added `inspect` to the `request_specific_fields` value to provide
better visibility for users in the exception message.

f89ce5112d
2024-09-08 14:13:00 +00:00
otegami
76475bf5c0 [ruby/open-uri] Add documentation for request_specific_fields option
2e7734c061
2024-09-08 14:13:00 +00:00
otegami
6ea2b6f65f [ruby/open-uri] Add request_specific_fields option for customizing headers
This commit introduces the `request_specific_fields` option in OpenURI.
It provides two methods for customizing headers as follows.

1. Specify headers only for the initial request

Use a Hash to apply headers only to the first request.
These headers are automatically removed during redirects.

2. Specify headers dynamically for each request

Use a Proc to dynamically generate headers for each request,
including during redirects, based on the request URL.

This feature allows users to control headers flexibly,
ensuring that sensitive headers like "Authorization" are not unintentionally
transferred during redirects unless explicitly specified.

460f858e3c
2024-09-08 14:12:59 +00:00
Mads Ohm Larsen
ec5d5422ca [ruby/rdoc] Use pointer cursor for navigation toggle
(https://github.com/ruby/rdoc/pull/1175)

964a1982c8
2024-09-08 12:17:36 +00:00
Koichi ITO
4774284124 [ruby/prism] Fix a token incompatibility for Prism::Translation::Parser::Lexer
This PR fixes a token incompatibility between Parser gem and `Prism::Translation::Parser` for left parenthesis.

## Parser gem (Expected)

Returns `tLPAREN2` token:

```console
$ bundle exec ruby -Ilib -rparser/ruby33 \
-ve 'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "foo(:bar)"; p Parser::Ruby33.new.tokenize(buf)[2]'
ruby 3.4.0dev (2024-09-01T11:00:13Z master eb144ef91e) [x86_64-darwin23]
[[:tIDENTIFIER, ["foo", #<Parser::Source::Range example.rb 0...3>]], [:tLPAREN2, ["(", #<Parser::Source::Range example.rb 3...4>]],
[:tSYMBOL, ["bar", #<Parser::Source::Range example.rb 4...8>]], [:tRPAREN, [")", #<Parser::Source::Range example.rb 8...9>]]]
```

## `Prism::Translation::Parser` (Actual)

Previously, the parser returned `tLPAREN` token when parsing the following:

```console
$ bundle exec ruby -Ilib -rprism -rprism/translation/parser33 -ve \
'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "foo(:bar)"; p Prism::Translation::Parser33.new.tokenize(buf)[2]'
ruby 3.4.0dev (2024-09-01T11:00:13Z master eb144ef91e) [x86_64-darwin23]
[[:tIDENTIFIER, ["foo", #<Parser::Source::Range example.rb 0...3>]], [:tLPAREN, ["(", #<Parser::Source::Range example.rb 3...4>]],
[:tSYMBOL, ["bar", #<Parser::Source::Range example.rb 4...8>]], [:tRPAREN, [")", #<Parser::Source::Range example.rb 8...9>]]]
```

After the update, the parser now returns `tLPAREN2` token for the same input:

```console
$ bundle exec ruby -Ilib -rprism -rprism/translation/parser33 -ve \
'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "foo(:bar)"; p Prism::Translation::Parser33.new.tokenize(buf)[2]'
ruby 3.4.0dev (2024-09-01T11:00:13Z master eb144ef91e) [x86_64-darwin23]
[[:tIDENTIFIER, ["foo", #<Parser::Source::Range example.rb 0...3>]], [:tLPAREN2, ["(", #<Parser::Source::Range example.rb 3...4>]],
[:tSYMBOL, ["bar", #<Parser::Source::Range example.rb 4...8>]], [:tRPAREN, [")", #<Parser::Source::Range example.rb 8...9>]]]
```

The `PARENTHESIS_LEFT` token in Prism is classified as either `tLPAREN` or `tLPAREN2` in the Parser gem.
The tokens that were previously all classified as `tLPAREN` are now also classified to `tLPAREN2`.

With this change, the following code could be removed from `test/prism/ruby/parser_test.rb`:

```diff
-          when :tLPAREN
-            actual_token[0] = expected_token[0] if expected_token[0] == :tLPAREN2
```

04d6f3478d
2024-09-07 22:36:38 +00:00
Mads Ohm Larsen
6dc9384694 [ruby/rdoc] Add more space after magnifying glass
(https://github.com/ruby/rdoc/pull/1173)

6a9cad4c54
2024-09-06 21:26:17 +00:00
David Rodríguez
b0adae7fb2 [rubygems/rubygems] Remove unnecessary "./" when appending string to uri
732679306d
2024-09-06 18:44:38 +00:00
David Rodríguez
fe1bace43c [rubygems/rubygems] Fix gem install does-not-exist being super slow
Every time a gem is not found in the Compact Index API, RubyGems will
fallback to the full index, which is very slow. This is unnecessary
because both indexes should be providing the same gems, so if a gem
can't be found in the Compact Index API, it won't be found in the full
index.

We _do_ want a fallback to the full index, whenever the Compact Index
API is not implemented. To detect that, we check that the API responds
to the "/versions" endpoint, just like Bundler does.

Before:

```
$ time gem install fooasdsfafs
ERROR:  Could not find a valid gem 'fooasdsfafs' (>= 0) in any repository
gem  20,77s user 0,59s system 96% cpu 22,017 total
```

After:

```
$ time gem install fooasdsfafs
ERROR:  Could not find a valid gem 'fooasdsfafs' (>= 0) in any repository
gem  5,02s user 0,09s system 91% cpu 5,568 total
```

c0d6b9eea7
2024-09-06 18:44:37 +00:00
David Rodríguez
2a17b4f022 [rubygems/rubygems] Deprecate constant that has been unused for a long time
282dbb3d62
2024-09-06 18:44:37 +00:00
David Rodríguez
4478ca3113 [rubygems/rubygems] Remove incorrect documentation
This exception has not been raised for a long time.

a6271a0b21
2024-09-06 18:44:36 +00:00
David Rodríguez
53f784178a [rubygems/rubygems] Remove unreachable code
Nothing is actually raising this at the moment.

3b824ca7a6
2024-09-06 18:44:36 +00:00
Nobuyoshi Nakada
30176e3f23 [rubygems/rubygems] Ensure that the lock file will be removed
2706acb271
2024-09-06 14:46:43 +00:00
Nobuyoshi Nakada
6dd917bd01 [rubygems/rubygems] Workaround for TruffleRuby
b82e43fd54
2024-09-06 14:46:42 +00:00
Nobuyoshi Nakada
5afee4d795 [rubygems/rubygems] Remove the lock file for binstubs
https://github.com/rubygems/rubygems/pull/7806#issuecomment-2241662488

4f06ee234a
2024-09-06 14:46:42 +00:00
Hiroshi SHIBATA
0e7b6e348f Merge GH-11492 2024-09-06 14:45:17 +09:00
Hiroshi SHIBATA
e43d701f09 Warn irb, reline for Ruby 3.5 2024-09-06 14:45:17 +09:00
Hiroshi SHIBATA
e17d91459c [ruby/time] Bump up v0.4.0
a14fa00ef7
2024-09-06 00:31:38 +00:00
Jean Boussier
72acd1c8b1 [ruby/time] Do not redefine Time#xmlschema if it already exists
[Feature #20707]

Ruby 3.4 will define this method natively, so the time gem shouldn't
redefine it with a slower version.

f05099ce38
2024-09-05 22:37:35 +00:00
mterada1228
d4de8aef37 rake install command is failed (#1170)
* `rake install` command is failed

\### Problems

Several file paths were changed by following PR.

- 4211292ffe
- d7bca12c13

Because rdoc.gemspec doesn't take in this changes,
the `rake install` command is permanently failed.

\### Test

\#### before

```console
❯ bundle exec rake install
Running RuboCop...
Inspecting 4 files
....

4 files inspected, no offenses detected

Tip: Based on detected gems, the following RuboCop extension libraries
might be helpful:
  * rubocop-rake (https://rubygems.org/gems/rubocop-rake)

You can opt out of this message by adding the following to your config
(see
https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions
for more options):
  AllCops:
    SuggestExtensions: false
rake aborted!
Running `gem build -V
/Users/mterada/dev/redDataTools/remove_dependency/rdoc/rdoc.gemspec`
failed with the following output:

WARNING:  See https://guides.rubygems.org/specification-reference/ for
help
ERROR:  While executing gem ... (Gem::InvalidSpecificationException)
    ["RI.rdoc", "lib/rdoc/alias.rb", "lib/rdoc/anon_class.rb",
"lib/rdoc/any_method.rb", "lib/rdoc/attr.rb",
"lib/rdoc/class_module.rb", "lib/rdoc/constant.rb",
"lib/rdoc/context.rb", "lib/rdoc/context/section.rb",
"lib/rdoc/extend.rb", "lib/rdoc/ghost_method.rb", "lib/rdoc/include.rb",
"lib/rdoc/meta_method.rb", "lib/rdoc/method_attr.rb",
"lib/rdoc/mixin.rb", "lib/rdoc/normal_class.rb",
"lib/rdoc/normal_module.rb", "lib/rdoc/require.rb",
"lib/rdoc/single_class.rb", "lib/rdoc/top_level.rb"] are not files

/Users/mterada/.rbenv/versions/3.1.0/bin/bundle:25:in `load'
/Users/mterada/.rbenv/versions/3.1.0/bin/bundle:25:in `<main>'
Tasks: TOP => install => build
(See full trace by running task with --trace)
```

\#### after

```console
❯ bundle exec rake install
Running RuboCop...
Inspecting 4 files
....

4 files inspected, no offenses detected

Tip: Based on detected gems, the following RuboCop extension libraries might be helpful:
  * rubocop-rake (https://rubygems.org/gems/rubocop-rake)

You can opt out of this message by adding the following to your config (see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions for more options):
  AllCops:
    SuggestExtensions: false
rdoc 6.7.0 built to pkg/rdoc-6.7.0.gem.
rdoc (6.7.0) installed.
```

* Add a `bundle exec rake install` step to github workflow

* make intentionally CI failed

* Revert "make intentionally CI failed"

This reverts commit 9fc5dd9423a024594ad26d86a8a6af829e7017f8.
2024-09-05 16:53:31 +00:00
Mari Imaizumi
721a2ceecf [ruby/reline] Bump version to 0.5.10
(https://github.com/ruby/reline/pull/745)

0ebd54f675
2024-09-05 12:48:02 +00:00
Étienne Barrié
bf9879791a Optimized instruction for Hash#freeze
If a Hash which is empty or only using literals is frozen, we detect
this as a peephole optimization and change the instructions to be
`opt_hash_freeze`.

[Feature #20684]

Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2024-09-05 12:46:02 +02:00
Étienne Barrié
a99707cd9c Optimized instruction for Array#freeze
If an Array which is empty or only using literals is frozen, we detect
this as a peephole optimization and change the instructions to be
`opt_ary_freeze`.

[Feature #20684]

Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2024-09-05 12:46:02 +02:00
Takuya Noguchi
2e5a7d768b [rubygems/rubygems] Improve bundle add manpage
* Fix synopsis for mutually exclusive options.
* Add more descriptive examples.

Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>

c0f1efda69

Co-authored-by: Jerome Dalbert <jerome.dalbert@gmail.com>
2024-09-04 13:57:38 +00:00
ydah
dbb8f97eaa [ruby/prism] essentialy ==> essentially
9c68c01bcd
2024-09-04 13:13:37 +00:00