Commit graph

14659 commits

Author SHA1 Message Date
Peter Zhu
c00990869f [DOC] Fix code formatting for Tempfile.create 2024-07-23 14:25:15 -04:00
Jean Boussier
34adc07372 Document the reasoning behind the fix for [Bug #20641] 2024-07-22 18:07:18 +02:00
Jean Boussier
82aee1a946 bundled_gems.rb: Add a fast path
[Bug #20641] `Gem::BUNDLED_GEMS.warning?` adds a lot of extra
work on top of `require`. When the call end up atually loading code
the overhead is somewhat marginal.

However it's not uncommon for code to go some late `require` in some
paths, so it's expected that calling `require` with something already
required is somewhat fast, and `bundled_gems.rb` breaks this assumption.

To avoid this, we can have a fast path that in most case allow to
short-circuit all the heavy computations. If we extract the feature
basename and it doesn't match any of the bundled gems we care about
we can return very early.

With this change `require 'date'` is now only 1.33x slower on Ruby
3.3.3, than it was on Ruby 3.2.2, whereas before this change it
was at least 100x slower.
2024-07-22 10:33:07 +02:00
Randy Stauner
da49bee04b [ruby/uri] Restrict constant checks to current namespace to avoid conflicts with globals
7a64e0245f
2024-07-21 16:57:32 +00:00
alpha0x00
3222c67262 [rubygems/rubygems] Fix line comment issue for map
7ca06e139b
2024-07-19 03:03:16 +00:00
Hiroshi SHIBATA
8db2325a11 [ruby/uri] Also support URI::PATTERN with switch-back
823697edb4
2024-07-19 00:50:38 +00:00
Hiroshi SHIBATA
082335494b [ruby/uri] Added test for constant definition and remove URI::REGEXP when using RFC3986_PARSER
6f616d97fc
2024-07-19 00:50:37 +00:00
Hiroshi SHIBATA
2a56c1841d [ruby/uri] URI.extract needs to pass block
If given block to URI.extract, it returns nil.

984145c407
2024-07-19 00:50:37 +00:00
Hiroshi SHIBATA
6452cf5cb5 [ruby/uri] Added compatibility methods for RFC2396 parser
bbb8a40eae
2024-07-19 00:50:36 +00:00
Hiroshi SHIBATA
08e449d89b [ruby/uri] Added URI.parser= method for switch back to RFC2396_Parser
d7dc19ad3f
2024-07-19 00:50:35 +00:00
David Rodríguez
104dad3dd0 [rubygems/rubygems] Small tweak to avoid making the same mistake again
We checking completeness of a SpecSet, we should always ignore
dependencies not relevant for the current platform, since the resolver
and the lockfile ignore those too.

c4b0c6d84e
2024-07-18 18:08:37 +00:00
David Rodríguez
d62af8e513 [rubygems/rubygems] Fix another removal issue
I failed to ignore (again) specs only considered for resolution under
some platforms that are not the current one.

b72deec57e
2024-07-18 18:08:37 +00:00
David Rodríguez
c9d2343f5c [rubygems/rubygems] Fix incorrect standalone script when default gems with extensions are used
55649cd09b
2024-07-18 18:07:09 +00:00
David Rodríguez
86c99a8d14 [rubygems/rubygems] Fix gemspec require_paths type validation
It was not properly being detected as an Array attribute, and thus not
properly validated.

Fixing this allows us to remove a strange `rescue` clause in Bundler.

4121a32408
2024-07-18 09:25:17 +00:00
David Rodríguez
95728a8b42 [rubygems/rubygems] Warn non flattened require paths in old RubyGems versions too
b3cdccc6fb
2024-07-18 09:25:16 +00:00
Nobuyoshi Nakada
c032e2c225 [rubygems/rubygems] Use caller_locations instead of splitting caller
Also limit caller ranges

a274b1af78
2024-07-18 04:20:07 +00:00
Hartley McGuire
d0c17cbd09
Require space between hash/content in ATX heading (#1140)
While writing some Markdown documentation for Rails, I came across an
interesting case where trying to link to an instance method at the start
of a line would instead parse as an H1 heading:

```markdown
#response_body=
```

Expected:

```html
<a href=""><code>#response_body=</code></a>
```

Actual:

```html
<h1>response_body=</h1>
```

According to the CommonMark spec:

> At least one space or tab is required between the # characters and the
> heading’s contents, unless the heading is empty. Note that many
> implementations currently do not require the space. However, the space
> was required by the original ATX implementation, and it helps prevent
> things like the following from being parsed as headings:
>
> Example 64

So while some implementations do not follow this requirement, I believe
RDoc should because it makes it easy to write text similar to Example 64
(which was used in the new test) and it also enables automatically
linking to instance methods at the start of a line.
2024-07-18 09:40:01 +09:00
Stan Lo
239d54dfbc [ruby/rdoc] Improve rubocop setup
(https://github.com/ruby/rdoc/pull/1139)

* Rename rake rubocop to rake format_generated_files

* Add rubocop rules to ensure spaces are applied consistently

* Improve rubocop related CI workflows

27932d001c
2024-07-17 20:43:08 +00:00
David Rodríguez
3c3cce13c6 [rubygems/rubygems] Fix another case of bundle lock --add-platform doing nothing
0629e27dda
2024-07-17 11:14:53 +00:00
Stan Lo
4a4e1bf357 [ruby/irb] Group class methods under class << self
(https://github.com/ruby/irb/pull/981)

cdaa356df2
2024-07-16 15:58:15 +00:00
nicholas a. evans
e165d92d37
[ruby/rdoc] Drop reimplementation of Ripper lex state
(https://github.com/ruby/rdoc/pull/1118)

* Drop reimplementation of Ripper lex state

This code was for ruby 2.4 compatibility, but rdoc dropped support for
ruby 2.4 about three years ago, in f480b970c.  This code was almost half
of the lines of code in rdoc/parser/ripper_state_lex.

* Remove unused Ripper constants and const_defined?

This was mostly copied from the diff in @st0012's PR comment.  The
remaining constants have been updated to get their value directly from
Ripper.

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

* Use Ripper::EXPR_LABEL directly

Since this is only used from outside RipperStateLex, there's no longer
any benefit to using the indirect reference rather than just going
straight to Ripper.

---------

dd8c216263

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-07-16 07:22:11 +09:00
tomoya ishida
17a4c7cfcf [ruby/reline] Fix rendering bug of nomultiline prompt
(https://github.com/ruby/reline/pull/730)

Fix bug of `print('a'*10); Reline.readline('>')` wrong rendering

c0469a12b9
2024-07-12 12:21:26 +00:00
Kevin Newton
21b4c14971 [ruby/prism] (ruby_parser) Handle bare string in implicit concat
afc7c9344a
2024-07-11 19:46:50 +00:00
Kevin Newton
3c3be9c6b2 [ruby/prism] (ruby_parser) Match match3 nodes for regular expressions
47cb73ce69
2024-07-11 19:46:50 +00:00
Kevin Newton
4c696597b7 [ruby/prism] (ruby_parser) Reverse associativity of and and or nodes
073e8ba307
2024-07-11 19:46:49 +00:00
Kevin Newton
c1df15c3e6 [PRISM] Use node ids for error highlight 2024-07-11 14:25:54 -04:00
Kevin Newton
aa473489a2 [ruby/prism] Various cleanup for initializers and typechecks
86cf82794a
2024-07-11 14:25:54 -04:00
Kevin Newton
2bf9ae3fa1 [ruby/prism] Add node ids to nodes
bf16ade7f9
2024-07-11 14:25:54 -04:00
Kevin Newton
39dcfe26ee [ruby/prism] Move Node#type and Node::type documentation
08a71f6259
2024-07-11 14:25:54 -04:00
Kevin Newton
687be43c79 [ruby/prism] Expose flags on every node type
9f12a56fd6
2024-07-11 14:25:54 -04:00
Kevin Newton
ca48fb76fb [ruby/prism] Move location to second position for node initializers
4cc0eda4ca
2024-07-11 14:25:54 -04:00
Kevin Newton
678dd769e5 [ruby/prism] Reconfigure error tests
fb7e1ebb7f
2024-07-11 14:25:54 -04:00
Jeremy Evans
c698180e68 [ruby/logger] Add reraise_write_errors keyword argument to Logger and LogDevice
This allows the user to specify exception classes to treat as regular
exceptions instead of being swallowed.  Among other things, it is
useful for having Logger work with Timeout.

Fixes Ruby Bug 9115.

436a7d680f
2024-07-11 15:25:17 +00:00
João Pinheiro
72732af47e [ruby/open-uri] document max_redirects option
4a247e5ca1
2024-07-11 04:49:59 +00:00
João Pinheiro
e62a0126cd [ruby/open-uri] apply default max_redirects
5d29e626bc
2024-07-11 04:49:59 +00:00
Dmitriy Ivliev
6dc0086d20 [rubygems/rubygems] fix s3 source configuration issue
356726bd1a
2024-07-11 02:27:46 +00:00
Evgeni Golov
bc1b4235fb [ruby/net-http] implement talking SSL to the proxy too
https://bugs.ruby-lang.org/issues/16482

ae2d83f88b
2024-07-11 01:56:08 +00:00
fatkodima
70bdc0f777 [ruby/net-http] Add ability to configure default settings for new connections
fed3dcd0c2
2024-07-11 01:51:03 +00:00
MSP-Greg
d605fb54cf [ruby/net-http] net/http.rb - derive SSL_IVNAMES from SSL_ATTRIBUTES
7191bb923b
2024-07-11 01:10:08 +00:00
David Rodríguez
133fec4ce9 [rubygems/rubygems] Fix another strange error when running bundle add in frozen mode
If there's a lockfile, but it's out of sync with the Gemfile because a
dependency has been deleted, and frozen mode is set, Bundler will print
the following strange error:

```
$ bundle add rake
, but the lockfile can't be updated because frozen mode is set

You have deleted from the Gemfile:
* rake (~> 13.2)

Run `bundle install` elsewhere and add the updated Gemfile to version control.
```

This commit changes the error to:

```
Some dependencies were deleted from your gemfile, but the lockfile can't be updated because frozen mode is set

You have deleted from the Gemfile:
* rake (~> 13.2)

Run `bundle install` elsewhere and add the updated Gemfile to version control.
```

452da4048d
2024-07-10 08:04:07 +00:00
David Rodríguez
7e612b7414 [rubygems/rubygems] Fix strange error when running bundle add with frozen mode set
If Gemfile is empty and there's no lockfile (situation after `bundle init`), and
`frozen` is configured, running `bundle add` will result in an strange
error, like this:

```
$ bundle add rake
, but the lockfile can't be updated because frozen mode is set

You have deleted from the Gemfile:
* rake (~> 13.2)

Run `bundle install` elsewhere and add the updated Gemfile to version control.
```

This commit fixes the problem to instead print

152331a9dc
2024-07-10 08:04:07 +00:00
David Rodríguez
140d8318db [rubygems/rubygems] Fix generic platform gems getting incorrectly removed when locked for a specific platform
If they are already in the lockfile as the most specific variant for a
platform, we shouldn't change that unless explicitly unlocking.

a901660498
2024-07-09 16:34:09 +00:00
David Rodríguez
e6c7a309d0 [rubygems/rubygems] Refactor selecting specs from a SpecSet
bcbbff5149
2024-07-09 16:34:09 +00:00
David Rodríguez
dd05191bc3 [rubygems/rubygems] Resolve all platforms directly
Instead of having to do a complete pass after resolve.

To do this, we add to the ruby group all the platform specs with the
same dependencies as the ruby specs.

e50415f2a6
2024-07-09 16:34:08 +00:00
David Rodríguez
00acc70348 [rubygems/rubygems] Don't memoize sorted_spec_names
It's just for debugging and a simple method, so no need.

3230425a9a
2024-07-09 16:34:08 +00:00
David Rodríguez
086cde1651 [rubygems/rubygems] Instantiate Resolver::SpecGroup with explicit priority
e2c1bc1b6c
2024-07-09 16:34:07 +00:00
David Rodríguez
5fdfdc30f1 [rubygems/rubygems] Let resolver consider unique specs from the beginning
It results in more consistent error messages.

a4b34361cc
2024-07-09 16:34:07 +00:00
David Rodríguez
ae6a2d0641 [rubygems/rubygems] Fix wrong version is comment
This RubyGems feature is being released as 3.5.15, so we can stop
monkeypatching RubyGems once support for the previous version is
dropped.

36f146840d
2024-07-08 17:06:26 +00:00
David Rodríguez
39826f384a [rubygems/rubygems] Backport binstub race condition fix to Bundler
b07e46820d
2024-07-08 17:06:25 +00:00
David Rodríguez
e4825a5194 [rubygems/rubygems] Fix another race condition
We also need to protect prior removal of the binstub, otherwise it can
happen that:

* Process A removes prior binstub FOO.
* Process B removes prior binstub FOO (does nothing actually because Process A already removed it).
* Process A writes binstub FOO for gem BAR from the beginning of file.
* Process B writes binstub FOO for gem BAZ from the beginning of file.

Similarly as before, if binstub FOO for gem BAR is bigger that binstub
FOO for gem BAZ, garbage bytes will be left around at the end of the
file, corrupting the binstub.

The solution is to also protect removal of the previous binstub. To do
this, we use a file lock on an explicit `.lock` file.

d99a80e62d
2024-07-08 14:38:31 +09:00