Commit graph

14675 commits

Author SHA1 Message Date
David Rodríguez
419d3221fb [rubygems/rubygems] Fix gem uninstall <name>:<version> failing on shadowed default gems
29357a5dd6
2024-08-21 12:07:10 +00:00
David Rodríguez
54b6025887 [rubygems/rubygems] Regeneration previous git application caches that didn't include bare repos
417319ecb1
2024-08-21 12:06:28 +00:00
Hiroshi SHIBATA
71c14c8889 Don't show script name when bundle exec and call ruby script directly. 2024-08-21 16:48:35 +09:00
Hiroshi SHIBATA
c97dc7739e Skip to show script name with using ruby -r option 2024-08-21 16:48:35 +09:00
Hiroshi SHIBATA
5fedf1c3ac Show correct script name with sub-feature case 2024-08-21 16:48:35 +09:00
Hiroshi SHIBATA
b41d79962a Reapply "[ruby/uri] Warn compatibility methods in RFC3986_PARSER"
This reverts commit 3da7e440e9.
2024-08-21 14:52:29 +09:00
Hiroshi SHIBATA
592b90328a
Generate parsers of RDoc with Racc 1.8.1 2024-08-21 13:30:01 +09:00
Michael Chui
014708ad5a [ruby/logger] Guarantee level_override exists
Some Ruby apps subclass Logger without running the superclass
constructor, which means that `@level_override` isn't initialized
properly. This can be fixed in some cases, but the gem should maintain
backwards compatibility.

3246f38328
2024-08-21 01:10:56 +00:00
Peter Zhu
1d68a735a2 [ruby/tempfile] Don't unlink in finalizer when already unlinked
f677941ea2
2024-08-20 18:37:53 +00:00
Peter Zhu
a68331e703 [ruby/tempfile] Add FinalizerManager to manage finalizers
As @jeremyevans pointed out for commit eb2d8b1:

> Each Tempfile instance has a separate File instance and file descriptor:
>
>   t = Tempfile.new
>   t.to_i # => 6
>   t.dup.to_i => 7

FinalizerManager will keep track of the open File objects for the
particular file and will only unlink the file when all of the File objects
have been closed.

753ab16642
2024-08-20 18:07:42 +00:00
Peter Zhu
41b427a264 [ruby/tempfile] Ensure finalizer order in Tempfile
The Closer and Remover finalizers are defined on different objects in
Tempfile. The Closer is defined on the Tempfile object while the Remover
is defined on the finalizer_obj. This means that there is no guarantee
of the finalizer order.

On Windows, we must close the file before removing it because we cannot
remove an open file. But since the order is not guaranteed, the GC may
run the Remover finalizer first, which will fail with an Errno::EACCES
(Permission denied @ apply2files).

This commit changes it so that both the Closer and Remover finalizers
are defined on the finalizer_obj, which guarantees the order that it is
ran.

eb2d8b1175
2024-08-20 13:28:36 +00:00
Hiroshi SHIBATA
72d016e97b [ruby/reline] typofix
d44fbf9f7b
2024-08-20 11:03:13 +00:00
David Rodríguez
786d000652 [ruby/rdoc] Avoid potentially loading the same extension from different versions of the same gem
Avoids warnings like

```
/path/to/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rbs-3.4.0/lib/rdoc/discover.rb:10: warning: method redefined; discarding old scan
/path/to/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/lib/rdoc/discover.rb:10: warning: previous definition of scan was here
```

e47920d8f3
2024-08-19 11:48:42 +00:00
Marco Roth
7061359564 [rubygems/rubygems] Change new gem README template to have copyable code blocks
c805e9b558
2024-08-19 00:04:48 +00:00
Stan Lo
923e36ab21 [ruby/rdoc] Fix sidebar scroll again and add missing footer back
(https://github.com/ruby/rdoc/pull/1154)

* Add missing footers

In #1152 the footer partial was only added to the index.rhtml file.
This commit adds the footer partial to the other template files.

* Remove unnecessary middle divs in nav

* Simplify sidebar's overflow settings

Because sidebar needs to be scrollable, its overflow should default to auto.
Currently it's set to hidden and force individual elements to set overflow auto,
which overcomplicates things.

b8c2bcd8db
2024-08-15 13:33:00 +00:00
Kentaro Takeyama
2a933609e7 Delete unnecessary rubocop disable comment 2024-08-15 17:16:25 +09:00
tomoya ishida
002e785e77 [ruby/irb] Fix kill pager pid throwing Errno::ESRCH when pager
process already terminated
(https://github.com/ruby/irb/pull/989)

949f032e9b
2024-08-14 18:06:53 +00:00
Koichi ITO
88954a0e9a [ruby/prism] Tweak inspect representation of Prism::Location
This PR tweaks inspect representation of `Prism::Location`.

## Before

During debugging, the meaning of `@location=2147483648` was unclear:

```console
$ ruby -Ilib -rprism -e 'p Prism.lex("puts :hi").value.map(&:first)[1]'
#<Prism::Token:0x000000010cd74e40 @source=#<Prism::ASCIISource:0x000000010cb5f808 @source="puts :hi", @start_line=1, @offsets=[0]>,
@type=:SYMBOL_BEGIN, @value=":", @location=2147483648>
```

## After

This PR clarifies the contents of the location object, aligning with what I think user expects:

```console
$ ruby -Ilib -rprism -e 'p Prism.lex("puts :hi").value.map(&:first)[1]'
#<Prism::Token:0x000000010e174d50 @source=#<Prism::ASCIISource:0x000000010df5efe8 @source="puts :hi", @start_line=1, @offsets=[0]>,
@type=:SYMBOL_BEGIN, @value=":", @location=#<Prism::Location @start_offset=5 @length=1 start_line=1>>
```

Although it is uncertain whether Prism will accept this change in the inspect representation, it is submitted here as a suggestion.

e7421ce1c5
2024-08-14 16:28:43 +00:00
tomoya ishida
f2f177edb3 [ruby/irb] Improve easter_egg logo resolution
(https://github.com/ruby/irb/pull/987)

ab394db93f
2024-08-14 04:06:07 +00:00
Kasumi Hanazuki
094e53360d [ruby/resolv] Reuse open TCP connection
[RFC7766] Section 5 recommends stub resolvers to reuse open TCP
connections to a nameserver.

[RFC7766]: https://datatracker.ietf.org/doc/html/rfc7766

9bf1b08f5c
2024-08-13 21:09:08 +00:00
Igor Pstyga
4be9b72fbb [ruby/resolv] Fix TCP fallback with multiple nameservers
Under the following conditions the exception
`Resolv::DNS::Requester::RequestError: host/port don't match` is raised:
- Multiple nameservers are configured for Resolv::DNS
- A nameserver falls back from UDP to TCP
- TCP request hits Resolv::DNS timeout
- Resolv::DNS retries the next nameserver

More details here https://bugs.ruby-lang.org/issues/8285

7d524df80e

Co-authored-by: Julian Mehnle <julian@mehnle.net>
2024-08-13 21:09:08 +00:00
Alan Wu
525008cd78
Delete newarraykwsplat
The pushtoarraykwsplat instruction was designed to replace newarraykwsplat,
and we now meet the condition for deletion mentioned in
77c1233f79.
2024-08-13 20:56:35 +00:00
Stan Lo
908305a297 Sync rdoc 2024-08-13 09:10:15 -04:00
Stan Lo
64a7b87e1d
Sync rdoc to fix master doc's display issue (#11345)
Sync rdoc

This syncs changes made in https://github.com/ruby/rdoc/pull/1148, which
will fix https://docs.ruby-lang.org/en/master/'s display on certain screens.
2024-08-08 13:02:46 -07:00
Hiroshi SHIBATA
7e0910a82c
We should use uplevel:2 in another case.
Like the following scenario with bootsnap, that frames are same or smaller than frame_to_skip(=3).

---
"/Users/hsbt/.local/share/rbenv/versions/3.3-dev/lib/ruby/3.3.0/bundled_gems.rb:69:in `block (2 levels) in replace_require'"
"/Users/hsbt/.local/share/gem/gems/bootsnap-1.18.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'"
"test_warn_bootsnap.rb:11:in `<main>'"
---
2024-08-08 16:20:22 +09:00
Jean Boussier
7594a292b1
lib/bundled_gems.rb: more reliable caller detection
The `2` skipped frames went out of sync and now it should be `3`.

Rather than just update the offset, we can implement a way that
is adaptative as long as all require decorators are also called require.

Also we should compute the corresponding `uplevel` otherwise the
warning will still point decorators.

Co-authored-by: "Hiroshi SHIBATA" <hsbt@ruby-lang.org>
2024-08-08 15:50:26 +09:00
Hiroshi SHIBATA
fa443699af
Partly reverted 09638741ba
This change didn't work with Ruby 3.3.

We should revert this to test bundled_gems.rb with Ruby 3.3.
2024-08-08 13:24:27 +09:00
Hiroshi SHIBATA
3da7e440e9 Revert "[ruby/uri] Warn compatibility methods in RFC3986_PARSER"
This reverts commit c3becc3ba6.
2024-08-08 12:04:00 +08:00
Hiroshi SHIBATA
68ebd56a76 [ruby/uri] Use URI::RFC2396_PARSER explicitly in URI
898b889811
2024-08-08 02:09:27 +00:00
Hiroshi SHIBATA
c3becc3ba6 [ruby/uri] Warn compatibility methods in RFC3986_PARSER
9997c1acee
2024-08-08 02:09:27 +00:00
tompng
8d39939107 [ruby/rdoc] Use ascii chatacter in HTML file
40a6690010
2024-08-08 08:54:52 +09:00
Hiroshi SHIBATA
267da552a1 [ruby/uri] Fallback missing constants with RFC3986_PARSER
(https://github.com/ruby/uri/pull/113)

* Fallback missing constants with RFC3986_PARSER

* raise missing constant

* Update test/uri/test_common.rb

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

* Update lib/uri/common.rb

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

* Update lib/uri/common.rb

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

---------

c2fdec079a

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2024-08-06 09:09:52 +00:00
David Rodríguez
3005ed6816 [rubygems/rubygems] Don't remove existing platform gems when PLATFORMS section is badly indented
ec099ebf1e
2024-08-05 17:28:11 +00:00
David Rodríguez
540bcf5248 [rubygems/rubygems] Fix locked source not getting respected when bundle update <specific_gem> is run
eec6830c04
2024-08-05 17:27:11 +00:00
David Rodríguez
7d97dde2e2 [rubygems/rubygems] Move private reader to private section
651cf3ea7a
2024-08-05 17:27:10 +00:00
Josh Soref
9d86864a6d [ruby/uri] Add space after bad URI
9f2c7ed5f2
2024-08-05 08:15:56 +00:00
Hiroshi SHIBATA
a82976bc90 [ruby/uri] Use DEFAULT_PARSER at split, parse, join
28af4e155a
2024-08-05 08:00:14 +00:00
David Rodríguez
5258e8b1cd Make sure to always use the right warn 2024-08-05 12:16:49 +08:00
David Rodríguez
7285e76493
Fix truffleruby removing gems from lockfile
When resolving on truffleruby, and multiple platforms are included in
the lockfile, Bundler will not respect existing platforms, but always
force ruby variants. That means removal of existing version specific
variants, introducing lockfile churn between implementations.

To prevent this, we introduce the distinction between
`Dependency#force_ruby_platform`, only settable via Gemfile, and
`Dependency#default_force_ruby_platform`, which is always true on
truffleruby for certain dependency names. This way, when resolving
lockfile gems for other platforms on truffleruby, we keep platform
specific variants in the lockfile.

However, that introduces the problem that if only platform specific
variants are locked in the lockfile, Bundler won't be able to
materialize on truffleruby because the generic variant will be missing.
To fix this additional problem, we make sure the generic "ruby" platform
is always added when resolving on truffleruby.
2024-08-05 11:58:07 +09:00
fatkodima
a35d324862 [ruby/optparse] Fix parsing array arguments with :into option
19700e96d8
2024-08-05 02:28:12 +00:00
Stan Lo
cbc40bb130 Sync rdoc 2024-08-05 08:27:45 +08:00
tomoya ishida
16b0242808 [ruby/rdoc] Add new ruby parser that uses Prism
(https://github.com/ruby/rdoc/pull/1144)

* Add a new ruby parser RDoc::Parser::PrismRuby

* Add a new ruby parser testcase independent from parser's internal implementation

* unknown meta method

* Use MethodSignatureVisitor only to scan params, block_params and calls_super

* Add calls_super test

* Drop ruby 2.6. Prism requires ruby >= 2.7

* Remove duplicated documentation comment from prism_ruby.rb

* Add test for wrong argument passed to metaprogramming method

* Rename visit_call_[DSL_METHOD_NAME] to make it distinguishable from visit_[NODE_TYPE]_node

* Method receiver switch of true/false/nil to a case statement

* Extract common part of add_method(by def keyword) and add meta_comment method

* Reuse consecutive comments array when collecting comments

* Simplify DSL call_node handling

* Refactor extracting method visibility arguments

fde99f1be6
2024-07-31 20:50:00 +00:00
Stan Lo
27c22f822a [ruby/rdoc] Drop unnecessary file_name parameter from Parser.for
method.
(https://github.com/ruby/rdoc/pull/1135)

* Unify top_level creation in tests

* Remove unnecessary file_name param from Parser.for

It should be always the same as the top_level's absolute_name, so there's
no point of taking it as a separate parameter.

97c497dfbb
2024-07-31 14:36:41 +00:00
David Rodríguez
0dda30d9eb [rubygems/rubygems] Print a better debug message when lockfile does not include the current platform
afb7a6d754
2024-07-30 14:02:03 +00:00
David Rodríguez
cf6efd1bb7 [rubygems/rubygems] Simplify logic to add current platform a bit
e102516e27
2024-07-30 14:02:02 +00:00
David Rodríguez
1164b6a7ba [rubygems/rubygems] Fix gem list regression when a regular gem shadows a default one
Previously, if you have bundler installed both as a regular gem and a
default gem, the default gem would be displayed by `gem list`.

10a6b1736e
2024-07-30 14:01:43 +00:00
David Rodríguez
3d248b2eb3 [rubygems/rubygems] Always leave default gem executables around
775c35e197
2024-07-30 14:01:32 +00:00
Peter Zhu
86a762ce56 [ruby/reline] Fix memory leak in setupterm
(https://github.com/ruby/reline/pull/733)

The allocated Fiddle::Pointer never gets freed because it doesn't have a
free function defined for when it gets garbage collected. This commit
changes it to use the default free function.

0796dcd497
2024-07-29 15:07:53 +00:00
Burdette Lamar
63bdf2d725 [ruby/rdoc] [DOC] Mods about markup formats
(https://github.com/ruby/rdoc/pull/1143)

011de3f2fd
2024-07-29 13:16:18 +00:00
David Rodríguez
67e1ea0028 [rubygems/rubygems] Remove inconsistent whitespace from CLI flags
RuboCop sometimes accepts extra spaces for alignment, but in this case I
don't see any consistent alignment.

a8c767e14b
2024-07-26 12:16:56 +00:00