Commit graph

14659 commits

Author SHA1 Message Date
Ellen Marie Dash
38331c8981 [rubygems/rubygems] [gemspec_helpers] Fix Rubocop warning.
4ebf6ee5ac
2024-03-29 08:03:41 +00:00
Ellen Marie Dash
d19744fbd6 [rubygems/rubygems] [build, rebuild] Split common find_gemspec() out to GemspecHelpers.
2f80a595c4
2024-03-29 08:03:40 +00:00
Ellen Marie Dash
d916dbcb84 [rubygems/rubygems] Improve formatting of "gem rebuild --help" output.
701550f9dd
2024-03-29 08:03:40 +00:00
Ellen Marie Dash
54d90e1355 [rubygems/rubygems] [rebuild] If --diff is not passed and a rebuild fails, suggest passing --diff.
7caadd182c
2024-03-29 08:03:39 +00:00
Ellen Marie Dash
dfe83df03e [rubygems/rubygems] [rebuild_command] Bail early if the RubyGems version doesn't match.
a691170dc7
2024-03-29 08:03:39 +00:00
Ellen Marie Dash
88d7be46b5 [rubygems/rubygems] [rebuild_command] Use Gem.* helpers.
8644ce7193
2024-03-29 08:03:39 +00:00
Ellen Marie Dash
fe096f64e8 [rubygems/rubygems] [rebuild_command] Clean up help text.
4446389f2e
2024-03-29 08:03:38 +00:00
Ellen Marie Dash
54e0b8073b [rubygems/rubygems] [rebuild_command] Use temporary directory instead of the working directory.
f2e4e5b56f
2024-03-29 08:03:38 +00:00
Ellen Marie Dash
a28087affc [rubygems/rubygems] [rebuild_command] Add --diff flag to try using diffoscope.
3e9545193a
2024-03-29 08:03:38 +00:00
Ellen Marie Dash
cd12dfd388 [rubygems/rubygems] [rebuild_command] Avoid leaking files.
3b88553d0d
2024-03-29 08:03:37 +00:00
Ellen Marie Dash
e5def27fbf [rubygems/rubygems] Add "gem rebuild" command.
6d661573f0
2024-03-29 08:03:37 +00:00
Kevin Newton
fcc06fa82a [ruby/prism] CLI -x flag
2068e3c30a
2024-03-28 12:04:35 -04:00
Jake Zimmerman
97b2cc3435 Allow FormatError to take either String or Gem for source
Most of the calls to `FormatError.new` pass `@gem` for the second argument, which has a `path` method.

But in one case—on package.rb:691 in `verify_gz`, the `source` argument is a `String`.

So if there's ever a GZip decode error when attempting to read the contents of the `data.tar.gz` file, instead of reporting the underlying GZip error (which might be something like "unexpected end of file"), we would report instead a NoMethodError coming from package.rb

```
Exception while verifying sorbet-0.5.11301.gem
ERROR:  While executing gem ... (NoMethodError)
    undefined method `path' for "data.tar.gz":String

        @path = source.path
                      ^^^^^
```

There are two ways to fix this:

1. Make `FormatError#initialize` aware of the fact that `source` might sometimes be a `String`
2. Make the call to `FormatError.new` in `verify_gz` pass `@gem` instead of `entry.full_name`.

I've chosen 1 because I think it's more useful to see "unexpected end of file in data.tar.gz" instead of "unexpected end of file in sorbet-0.5.11301.gem." The end of file **is actually** in data.tar.gz, not in the gem file itself, which was decoded successfully.
2024-03-28 15:54:33 +00:00
Hiroshi SHIBATA
7630a89a4b Use www.rfc-editor.org for RFC text.
We use the following site for that now:

* https://tools.ietf.org/ or http
* https://datatracker.ietf.org or http

Today, IETF said the official site of RFC is www.rfc-editor.org.

FYI: https://authors.ietf.org/en/references-in-rfcxml

I replaced them to www.rfc-editor.org.
2024-03-28 11:44:45 +09:00
Cody Cutrer
44b5c912da [rubygems/rubygems] Allow installing plugins from path via CLI
Also bring the man page up to date.

a849bd6947
2024-03-27 11:34:46 +00:00
Hiroshi SHIBATA
e51435177e
Update vendored resolv to 0.4.0 2024-03-27 12:17:58 +09:00
Kevin Newton
240fb3957b [ruby/prism] Freeze internal parts, again
50372fee5c
2024-03-26 12:11:09 -04:00
Hiroshi SHIBATA
8cfa8e87b2 [ruby/irb] Fix a typo (https://github.com/ruby/irb/pull/912)
2057248e40
2024-03-26 11:30:33 +00:00
David Rodriguez
06d5d4f1d0 [rubygems/rubygems] Fix resolver bug where ActivationRequest objects were not properly compared
They were delegating their `#hash` value to a class not overriding that
method, and so were returning inconsistent results.

723e4ee0fc
2024-03-25 19:45:51 +00:00
Cody Cutrer
552647175e [rubygems/rubygems] Improve validation of bundle plugin install options
Ensure only one source type is specified, and ensure options that
are only relevant to git sources are only specified with git.

58b043215e
2024-03-25 14:25:46 +00:00
Koichi ITO
56a2fad2a4 [ruby/prism] Fix incorrect paring when using invalid regexp options
Fixes https://github.com/ruby/prism/pull/2617.

There was an issue with the lexer as follows.
The following are valid regexp options:

```console
$ bundle exec ruby -Ilib -rprism -ve 'p Prism.lex("/x/io").value.map {|token| token[0].type }'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
[:REGEXP_BEGIN, :STRING_CONTENT, :REGEXP_END, :EOF]
```

The following are invalid regexp options. Unnecessary the `IDENTIFIER` token is appearing:

```console
$ bundle exec ruby -Ilib -rprism -ve 'p Prism.lex("/x/az").value.map {|token| token[0].type }'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
[:REGEXP_BEGIN, :STRING_CONTENT, :REGEXP_END, :IDENTIFIER, :EOF]
```

As a behavior of Ruby, when given `A` to `Z` and `a` to `z`, they act as invalid regexp options. e.g.,

```console
$ ruby -e '/regexp/az'
-e:1: unknown regexp options - az
/regexp/az
-e: compile error (SyntaxError)
```

Thus, it should probably not be construed as `IDENTIFIER` token.

Therefore, `pm_byte_table` has been adapted to accept those invalid regexp option values.
Whether it is a valid regexp option or not is checked by `pm_regular_expression_flags_create`.
For invalid regexp options, `PM_ERR_REGEXP_UNKNOWN_OPTIONS` is added to diagnostics.

d2a6096fcf
2024-03-25 12:16:32 +00:00
Justin Collins
f5a2f55aca [ruby/prism] Use Sexp#line_max not Sexp#max_line
for RubyParser translation

a37169621a
2024-03-25 12:13:52 +00:00
Mari Imaizumi
daf1d7bfef [ruby/reline] Bump version to v0.5.0
(https://github.com/ruby/reline/pull/664)

1d6569600c
2024-03-25 12:13:31 +00:00
tomoya ishida
f53209f023 [ruby/irb] Cache RDoc::RI::Driver.new
(https://github.com/ruby/irb/pull/911)

* Cache RDoc::RI::Driver.new to improve performance and to avoid flaky test

* Insert sleep to fix flaky rendering test that renders document dialog

da84e6cb56
2024-03-25 11:48:11 +00:00
Stan Lo
5f334b67d2 [ruby/reline] Remove useless tests
(https://github.com/ruby/reline/pull/665)

The pasting tests hadn't been working since as early as v0.2.0. Since
what it tried to cover is already gone for such a long time, I think it's
better to write new ones if needed then to keep them around.

And since these tests are gone, the helper methods for just them are also gone.

0eedf0e4a0
2024-03-25 11:06:39 +00:00
Jean Boussier
219d7cc1aa lib/bundled_gems.rb: dynamically ignore Kernel.require decorators
Followup: https://github.com/ruby/ruby/pull/10347

This avoid directly referencing bootsnap and zeitwerk, and also
handle other gems that may decorate `require`.
2024-03-25 18:17:09 +09:00
Hiroshi SHIBATA
675dcf9153
Partly Revert "Show the chilled status of a String [ci skip]"
This reverts commit e720a6b485.
2024-03-25 15:04:56 +09:00
Nobuyoshi Nakada
e720a6b485
Show the chilled status of a String [ci skip] 2024-03-25 14:33:20 +09:00
Hiroshi SHIBATA
6b1691ebe8 Remove rubylibdir from bootsnap 2024-03-25 14:33:03 +09:00
Xavier Noria
d6e9367edb Skip Bootsnap and Zeitwerk in bundled gems warning 2024-03-25 14:33:03 +09:00
Nobuyoshi Nakada
5e4b4d6674 [rubygems/rubygems] Remove typo name
It is more 2 years since #5109, probably enough time to warn.

1e9433e77f
2024-03-24 15:27:00 +00:00
tomoya ishida
74593613ea [ruby/reline] Disable dialog proc if TERM=dumb
(https://github.com/ruby/reline/pull/663)

4928e06a24
2024-03-24 13:04:33 +00:00
tomoya ishida
b0eda83ee0 [ruby/reline] Add mode_string to prompt calculation dependencies
(https://github.com/ruby/reline/pull/658)

* Add mode_string to prompt calculation dependencies

* Update vi show-mode-in-prompt test

a0cee06ec5
2024-03-24 10:47:22 +00:00
tomoya ishida
3adaba0e81 [ruby/reline] Do not send color reset sequence when GeneralIO is
used
(https://github.com/ruby/reline/pull/661)

3719702808
2024-03-23 23:00:21 +00:00
David Rodriguez
8ef923dc35 [rubygems/rubygems] Respect global umask when writing regular files
fd5cb7396f
2024-03-22 13:15:15 +00:00
David Rodriguez
7b3ef370f8 [rubygems/rubygems] Fix incorrect bundle update --bundler message
146de56353
2024-03-22 13:14:42 +00:00
Artur
d85c24058d [ruby/irb] Remove misleading documentation
(https://github.com/ruby/irb/pull/906)

https://github.com/ruby/irb/issues/904

89bca01bba
2024-03-22 11:34:51 +00:00
Hiroshi SHIBATA
c5ac18bbf4 [ruby/rdoc] Bump up 6.6.3.1
ffbf8ae089
2024-03-21 04:38:21 +00:00
Hiroshi SHIBATA
385c31e770 [ruby/rdoc] Fix NoMethodError for start_with
e21dfccb4a
2024-03-21 04:18:26 +00:00
Hiroshi SHIBATA
ee1ad009f3 [ruby/rdoc] Bump up 6.6.3
d98baf4917
2024-03-21 04:04:40 +00:00
Nobuyoshi Nakada
3d353afeb0 [ruby/rdoc] Filter marshaled objets
da7a0c7553
2024-03-21 04:04:40 +00:00
tomoya ishida
aa2cdaa263 [ruby/reline] Change rendered_screen.lines to non-nil
(https://github.com/ruby/reline/pull/650)

9685db55f1
2024-03-20 01:39:12 +00:00
Koichi ITO
0a10702747 [ruby/prism] Fix a diagnostic incompatibility
This PR fixes a diagnostic incompatibility when using no anonymous keyword rest parameter:

```ruby
foo(**)
```

Note, although the actual update applies only to the `foo(**)` case, for reference,
`foo(*)` and `foo(&) are also mentioned below.

## Ruby (Expected)

```console
$ ruby -cve 'foo(*)'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
-e:1: no anonymous rest parameter
-e: compile error (SyntaxError)

$ ruby -cve 'foo(**)'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
-e:1: no anonymous keyword rest parameter
-e: compile error (SyntaxError)

$ ruby -cve 'foo(&)'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
-e:1: no anonymous block parameter
-e: compile error (SyntaxError)
```

## Prism (Actual)

Before:

```console
$ bundle exec ruby -Ilib -rprism -wve 'p Prism.parse("foo(*)").errors'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
[#<Prism::ParseError @type=:argument_no_forwarding_star @message="unexpected `*` when the parent method is not forwarding"
@location=#<Prism::Location @start_offset=4 @length=1 start_line=1> @level=:fatal>]

$ bundle exec ruby -Ilib -rprism -wve 'p Prism.parse("foo(**)").errors'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
[#<Prism::ParseError @type=:expect_expression_after_splat_hash @message="expected an expression after `**` in a hash"
@location=#<Prism::Location @start_offset=4 @length=2 start_line=1> @level=:fatal>]

$ bundle exec ruby -Ilib -rprism -wve 'p Prism.parse("foo(&)").errors'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
[#<Prism::ParseError @type=:argument_no_forwarding_amp @message="unexpected `&` when the parent method is not forwarding"
@location=#<Prism::Location @start_offset=4 @length=1 start_line=1> @level=:fatal>]
```

After:

```console
$ bundle exec ruby -Ilib -rprism -wve 'p Prism.parse("foo(*)").errors'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
[#<Prism::ParseError @type=:argument_no_forwarding_star @message="unexpected `*` when the parent method is not forwarding"
@location=#<Prism::Location @start_offset=4 @length=1 start_line=1> @level=:fatal>]

$ bundle exec ruby -Ilib -rprism -wve 'p Prism.parse("foo(**)").errors'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
[#<Prism::ParseError @type=:argument_no_forwarding_star_star @message="unexpected `**` when the parent method is not forwarding"
@location=#<Prism::Location @start_offset=4 @length=2 start_line=1> @level=:fatal>]

$ bundle exec ruby -Ilib -rprism -wve 'p Prism.parse("foo(&)").errors'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
[#<Prism::ParseError @type=:argument_no_forwarding_amp @message="unexpected `&` when the parent method is not forwarding"
@location=#<Prism::Location @start_offset=4 @length=1 start_line=1> @level=:fatal>]
```

633c9d9fd4
2024-03-19 18:14:58 +00:00
Koichi ITO
72a613bc6a [ruby/prism] Fix a diagnostic incompatibility for Prism::Translation::Parser
This PR fixes a diagnostic incompatibility for `Prism::Translation::Parser` when using constant argument:

```ruby
def foo(A)
end
```

## Parser gem (Expected)

Displays `formal argument cannot be a constant (Parser::SyntaxError)`:

```console
$ bundle exec ruby -Ilib -rparser/ruby33 -ve 'p Parser::Ruby33.parse("def foo(A) end")'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
(string):1:9: error: formal argument cannot be a constant
(string):1: def foo(A) end
(string):1:         ^
/Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-3.3.0.5/lib/parser/diagnostic/engine.rb:72:
in `process': formal argument cannot be a constant (Parser::SyntaxError)
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-3.3.0.5/lib/parser/base.rb:274:in `diagnostic'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-3.3.0.5/lib/parser/ruby33.rb:12177:in `_reduce_663'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/racc-1.7.3/lib/racc/parser.rb:267:in `_racc_do_parse_c'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/racc-1.7.3/lib/racc/parser.rb:267:in `do_parse'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-3.3.0.5/lib/parser/base.rb:190:in `parse'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-3.3.0.5/lib/parser/base.rb:33:in `parse'
        from -e:1:in `<main>'
```

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

Previously, the error messages displayed by the Parser gem were different.

Before:

```console
$ bundle exec ruby -Ilib -rprism -rprism/translation/parser33 -ve 'Prism::Translation::Parser33.parse("def foo(A) end")'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
(string):1:9: error:
(string):1: def foo(A) end
(string):1:         ^
/Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-3.3.0.5/lib/parser/diagnostic/engine.rb:72:
in `process': Parser::SyntaxError (Parser::SyntaxError)
        from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:218:in `block in unwrap'
        from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:216:in `each'
        from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:216:in `unwrap'
        from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:49:in `parse'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-3.3.0.5/lib/parser/base.rb:33:in `parse'
        from -e:1:in `<main>'
```

After:

```console
$ bundle exec ruby -Ilib -rprism -rprism/translation/parser33 -ve 'Prism::Translation::Parser33.parse("def foo(A) end")'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
(string):1:9: error: formal argument cannot be a constant
(string):1: def foo(A) end
(string):1:         ^
/Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-3.3.0.5/lib/parser/diagnostic/engine.rb:72:
in `process': formal argument cannot be a constant (Parser::SyntaxError)
        from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:218:in `block in unwrap'
        from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:216:in `each'
        from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:216:in `unwrap'
        from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:49:in `parse'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-3.3.0.5/lib/parser/base.rb:33:in `parse'
        from -e:1:in `<main>'
```

4f2af88520
2024-03-19 18:13:57 +00:00
tomoya ishida
d7bc6f0eff [ruby/reline] Reline 0.5.0.pre
(https://github.com/ruby/reline/pull/614)

* Re-architecture LineEditor's internal state and rendering

* Fix test related to LineEditor re-architecture

* Bump to 0.5.0.pre.1

* Hide cursor only when updating screen. Frequent hide&show makes cursor flickering.

* Simplify rerender call from reline.rb

* Simplify handle_cleared

It only need to clear screen. line_editor.rerender will be called later.

* Add description of updating pasting_state inserts continuous_insertion_buffer

* Use meaningful block parameter

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

* Fix use of `@cursor_y`

Fix bug updating `@cursor_y`. Do not use `@cursor_y` while updating dialog because it is not current cursor position but cursor position at last rendered time.

* Remove useless instance_variable_set in test

These instance variables are already removed from LineEditor

* Always initialize instance variables to avoid ruby 2.7 warning, remove unused instance variable

* Call update_dialogs from reline.rb before first render

* Combine state representing rendered screen information into `@rendered_screen`

* Rename editor_cursor_ to wrapped_cursor

It represents cursor position of word wrapped whole content

* Remove unused code, tweak, add comment

---------

3fa376217d

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-03-19 14:17:26 +00:00
Étienne Barrié
12be40ae6b Implement chilled strings
[Feature #20205]

As a path toward enabling frozen string literals by default in the future,
this commit introduce "chilled strings". From a user perspective chilled
strings pretend to be frozen, but on the first attempt to mutate them,
they lose their frozen status and emit a warning rather than to raise a
`FrozenError`.

Implementation wise, `rb_compile_option_struct.frozen_string_literal` is
no longer a boolean but a tri-state of `enabled/disabled/unset`.

When code is compiled with frozen string literals neither explictly enabled
or disabled, string literals are compiled with a new `putchilledstring`
instruction. This instruction is identical to `putstring` except it marks
the String with the `STR_CHILLED (FL_USER3)` and `FL_FREEZE` flags.

Chilled strings have the `FL_FREEZE` flag as to minimize the need to check
for chilled strings across the codebase, and to improve compatibility with
C extensions.

Notes:
  - `String#freeze`: clears the chilled flag.
  - `String#-@`: acts as if the string was mutable.
  - `String#+@`: acts as if the string was mutable.
  - `String#clone`: copies the chilled flag.

Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2024-03-19 09:26:49 +01:00
Hiroshi SHIBATA
0985e58790 [ruby/resolv] Bump up 0.4.0
44ae1e8531
2024-03-19 02:16:51 +00:00
Hiroshi SHIBATA
ef0e08f327
Don't replace doc url for vendored files 2024-03-19 10:54:52 +09:00
Yuki Nishijima
6c1e8029d0 [ruby/did_you_mean] Do not use #inspect to avoid unexpected performance degradation
closes https://github.com/ruby/did_you_mean/pull/100

bd11eefd6c
2024-03-19 01:27:32 +00:00
Koichi ITO
7a1a572428 [ruby/prism] Use require_relative in the Prism codebase
If there are many searches in the `$LOAD_PATH` in the user environment,
require will perform unnecessary searches that are not needed.
In contrast, `require_relative` is efficient because it uses a relative path.

438ccc67bd
2024-03-18 16:12:49 +00:00