Commit graph

14659 commits

Author SHA1 Message Date
Hiroshi SHIBATA
ff3f61556f
Only warn fiddle as optional dependency 2024-09-27 18:39:05 +09:00
David Rodríguez
a70adce1ce Only warn about bundled gems when require succeeds 2024-09-27 17:03:45 +09:00
Nithin Bekal
d7e5133d6d [ruby/benchmark] Add example for Benchmark.realtime
0f278be6c1
2024-09-27 04:31:47 +00:00
Nithin Bekal
3209bb950b [ruby/benchmark] Specify unit of time for Benchmark.realtime
388236685c
2024-09-27 04:31:47 +00:00
Stan Lo
49057f36ef [ruby/irb] Bump version to v1.14.1
(https://github.com/ruby/irb/pull/1009)

04cd2317ef
2024-09-26 13:38:04 +00:00
Kevin Newton
b97ff7dfda [ruby/prism] Fix up lex difference when ~ heredoc with 0 dedent and line continuation
84a9251915
2024-09-25 18:35:05 +00:00
David Rodríguez
b48add3c65 [rubygems/rubygems] Fix bundler/inline overwriting lockfiles
This was introduced by 0b7be7bb77, because
the original patch was not adapted to some recent refactorings.

0bca60d6e5

Co-authored-by: Hiroshi SHIBATA <hsbt@ruby-lang.org>
2024-09-24 14:17:23 +00:00
Luke Gruber
2a0ee408af [ruby/error_highlight] Fix error with prism when method given no arguments
such as:

  p = Proc.new

This now matches the RubyVM::AbstractSyntaxTree behavior, which is
not to highlight anything.

d5c592a1ba
2024-09-24 13:28:01 +00:00
Kevin Newton
414a848cc6 [ruby/prism] Accept version shorthand like 3.4
098f1c4607
2024-09-24 13:21:36 +00:00
Benoit Daloze
ed4a55fc4d [ruby/prism] Accept all 3.3.x and 3.4.x Ruby versions for Prism.parse
a4fcd5339a
2024-09-24 12:24:19 +00:00
David Rodríguez
5228d349d9
[rubygems/rubygems] Restore gem_dir as an instance variable accessor
I suspect someone could be setting this instance variable, and the
previous changes made that no longer effective.

Also I implemented a previous TOOD in `full_gem_path` the other way
around:

> # TODO: This is a heavily used method by gems, so we'll need
> # to aleast just alias it to #gem_dir rather than remove it.

I made `gem_dir` an alias of `full_gem_path` rather than the opposite.

This alternative change keeps both methods symmetric without deprecating
either of them for now.

28983973a3
2024-09-24 15:33:31 +09:00
David Rodríguez
5f47f0f759
[rubygems/rubygems] Remove TODO I can't make much sense of
6d627e0671
2024-09-24 15:33:31 +09:00
Adam Hess
4b1e852d3e
[ruby/error_highlight] Prism added node_id and Node#breadth_first_search in the 1.0 release. These methods are required for Prism to be able to find the method from the backtrace.
https://github.com/ruby/prism/blob/main/CHANGELOG.md#100---2024-08-28

In practice you will likely only end up in this situation if you previously had pre-1.0 prism installed and upgrade Ruby to a version with Prism as the default parser.

cb574daf62
2024-09-24 15:33:31 +09:00
David Rodríguez
5d53993a37 [rubygems/rubygems] Don't try to auto-install dev versions of Bundler not available remotely
1a7a3fdeb9
2024-09-23 10:53:32 +00:00
Daniel Colson
d0925c075b [rubygems/rubygems] Ensure refs directory in cached git source
See https://github.com/rubygems/rubygems/issues/8046 for details

Prior to this commit a cached git source without a specific ref wouldn't
survive pushing to a remote and then pulling on a different machine.
We'd end up without a refs directory in the cache, at which point git
won't recognize it as a repo.

This commit fixes the problem by adding a refs directory if it's not
already there. This needs to be done as early as possible, so any git
commands will work as expected, so this commit adds it before creating
the app cached git proxy.

8c89f0b065
2024-09-23 10:49:21 +00:00
David Rodríguez
c071fedb32 [rubygems/rubygems] Fix bundle outdated with --group option
It was printing incorrect output and returning incorrect status.

96f5979c7d
2024-09-23 10:37:57 +00:00
Koichi ITO
75ed086348 [ruby/prism] Fix kDO_LAMBDA token incompatibility for Prism::Translation::Parser::Lexer
## Summary

This PR fixes `kDO_LAMBDA` token incompatibility between Parser gem and `Prism::Translation::Parser` for lambda `do` block.

### Parser gem (Expected)

Returns `kDO_LAMBDA` token:

```console
$ bundle exec ruby -Ilib -rparser/ruby33 -ve \
'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "-> do end"; p Parser::Ruby33.new.tokenize(buf)[2]'
ruby 3.4.0dev (2024-09-01T11:00:13Z master eb144ef91e) [x86_64-darwin23]
[[:tLAMBDA, ["->", #<Parser::Source::Range example.rb 0...2>]], [:kDO_LAMBDA, ["do", #<Parser::Source::Range example.rb 3...5>]],
[:kEND, ["end", #<Parser::Source::Range example.rb 6...9>]]]
```

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

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

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

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

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

## Additional Information

Unfortunately, this kind of edge case doesn't work as expected; `kDO` is returned instead of `kDO_LAMBDA`.
However, since `kDO` is already being returned in this case, there is no change in behavior.

### Parser gem

Returns `tLAMBDA` token:

```console
$ bundle exec ruby -Ilib -rparser/ruby33 -ve \
'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "-> (foo = -> (bar) {}) do end"; p Parser::Ruby33.new.tokenize(buf)[2]'
ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [x86_64-darwin23]
[[:tLAMBDA, ["->", #<Parser::Source::Range example.rb 0...2>]], [:tLPAREN2, ["(", #<Parser::Source::Range example.rb 3...4>]],
[:tIDENTIFIER, ["foo", #<Parser::Source::Range example.rb 4...7>]], [:tEQL, ["=", #<Parser::Source::Range example.rb 8...9>]],
[:tLAMBDA, ["->", #<Parser::Source::Range example.rb 10...12>]], [:tLPAREN2, ["(", #<Parser::Source::Range example.rb 13...14>]],
[:tIDENTIFIER, ["bar", #<Parser::Source::Range example.rb 14...17>]], [:tRPAREN, [")", #<Parser::Source::Range example.rb 17...18>]],
[:tLAMBEG, ["{", #<Parser::Source::Range example.rb 19...20>]], [:tRCURLY, ["}", #<Parser::Source::Range example.rb 20...21>]],
[:tRPAREN, [")", #<Parser::Source::Range example.rb 21...22>]], [:kDO_LAMBDA, ["do", #<Parser::Source::Range example.rb 23...25>]],
[:kEND, ["end", #<Parser::Source::Range example.rb 26...29>]]]
```

### `Prism::Translation::Parser`

Returns `kDO` token:

```console
$ bundle exec ruby -Ilib -rprism -rprism/translation/parser33 -ve \
'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "-> (foo = -> (bar) {}) do end"; p Prism::Translation::Parser33.new.tokenize(buf)[2]'
ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [x86_64-darwin23]
[[:tLAMBDA, ["->", #<Parser::Source::Range example.rb 0...2>]], [:tLPAREN2, ["(", #<Parser::Source::Range example.rb 3...4>]],
[:tIDENTIFIER, ["foo", #<Parser::Source::Range example.rb 4...7>]], [:tEQL, ["=", #<Parser::Source::Range example.rb 8...9>]],
[:tLAMBDA, ["->", #<Parser::Source::Range example.rb 10...12>]], [:tLPAREN2, ["(", #<Parser::Source::Range example.rb 13...14>]],
[:tIDENTIFIER, ["bar", #<Parser::Source::Range example.rb 14...17>]], [:tRPAREN, [")", #<Parser::Source::Range example.rb 17...18>]],
[:tLAMBEG, ["{", #<Parser::Source::Range example.rb 19...20>]], [:tRCURLY, ["}", #<Parser::Source::Range example.rb 20...21>]],
[:tRPAREN, [")", #<Parser::Source::Range example.rb 21...22>]], [:kDO, ["do", #<Parser::Source::Range example.rb 23...25>]],
[:kEND, ["end", #<Parser::Source::Range example.rb 26...29>]]]
```

As the intention is not to address such special cases at this point, a comment has been left indicating that this case still returns `kDO`.
In other words, `kDO_LAMBDA` will now be returned except for edge cases after this PR.

2ee480654c
2024-09-20 17:17:21 +00:00
Kevin Newton
f515a1ab4b [ruby/prism] Introduce partial_script option
b28877fa4f
2024-09-20 15:42:12 +00:00
Samuel Giddins
43e3416b70 [rubygems/rubygems] Unconditionally set installed_by_version
It has been supported since RubyGems 2.2.0 via 4525e45a4d

Signed-off-by: Samuel Giddins <segiddins@segiddins.me>

bf39c583e8
2024-09-20 14:26:13 +00:00
tomoya ishida
34e008d075 [ruby/irb] Fix debug command in nomultiline mode
(https://github.com/ruby/irb/pull/1006)

* Fix debug command in nomultiline mode

* context.colorize_code -> context.colorize_input

71f4d6bfb5
2024-09-20 10:13:39 +00:00
David Rodríguez
cf29594c03 [rubygems/rubygems] Don't try to install locked bundler when --local is passed
907d46964d
2024-09-20 09:58:24 +00:00
Hiroshi SHIBATA
46ee05f05a
Added missing block arg 2024-09-19 16:23:08 +09:00
Akinori MUSHA
59db92a1a1 [ruby/set] 2024
ea95c5a3d2
2024-09-19 07:12:00 +00:00
Akinori MUSHA
e53d2f2092 [ruby/set] Reword the document for to_a and clarify the implementation notes
ref. https://github.com/ruby/ruby/pull/11453

3cf6d11bd2
2024-09-19 07:11:58 +00:00
David Rodríguez
461c48960d [rubygems/rubygems] Add a note about when hack can be removed
058b29fe98
2024-09-18 16:42:14 +00:00
David Rodríguez
ae214be9d6 [rubygems/rubygems] Fix TODO
2cd13005f6
2024-09-18 16:42:14 +00:00
David Rodríguez
47db8bc01c [rubygems/rubygems] Stop fighting with ourselves
7cf2fdcfa1
2024-09-18 16:42:13 +00:00
David Rodríguez
39679d7fab [ruby/uri] Fix spelling of "cannot"
77241d6508
2024-09-17 22:12:12 +00:00
David Rodríguez
b203e667c9 [rubygems/rubygems] Fix spelling, it's "cannot" rather than "can not"
3434f094a2
2024-09-17 20:09:07 +00:00
David Rodríguez
80e934c29c [rubygems/rubygems] Fix --local hitting the network when default gems are included
b9a2d4d539
2024-09-17 14:39:06 +09:00
David Rodríguez
7428709d20 [rubygems/rubygems] Inline a private method
Removes an (in my opinion) excessive indirection and handles options
more consistently.

642e6d2c0c
2024-09-17 14:39:04 +09:00
David Rodríguez
7e0934d33e [rubygems/rubygems] Consistently access install options through symbol keys
7ddf1dc70a
2024-09-17 14:39:04 +09:00
Kevin Newton
2ea1950510 [ruby/prism] Do not leak explicit encoding
Fixes [Bug #20744]

f1b8b1b2a2
2024-09-16 18:57:54 +00:00
tomoya ishida
6c4ce72609 [ruby/irb] Use InstructionSequence#script_lines to get method source
(https://github.com/ruby/irb/pull/1005)

It works with both prism and parse.y

bcfaa72d5a
2024-09-16 17:36:27 +00:00
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