Commit graph

14659 commits

Author SHA1 Message Date
Alexis Bernard
7ae4b858b3 [ruby/rdoc] Display class ancestors in the sidebar #1183
50dda13426
2024-11-04 17:34:27 +00:00
David Rodríguez
e7518a7859 Validate user input encoding
If the user has the encoding of her system messed up, she may end up
sending us incorrectly encoding input, causing "invalid byte sequence in
UTF-8" errors at random places.

These errors can be forced on a system without encoding issues with
something like:

```
$ gem install$(echo -e "\xFF") foo
/Users/deivid/.asdf/installs/ruby/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/config_file.rb:534:in `block in set_config_file_name': invalid byte sequence in UTF-8 (ArgumentError)
	from /Users/deivid/.asdf/installs/ruby/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/config_file.rb:530:in `each'
	from /Users/deivid/.asdf/installs/ruby/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/config_file.rb:530:in `set_config_file_name'
	from /Users/deivid/.asdf/installs/ruby/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/config_file.rb:177:in `initialize'
	from /Users/deivid/.asdf/installs/ruby/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/gem_runner.rb:71:in `new'
	from /Users/deivid/.asdf/installs/ruby/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/gem_runner.rb:71:in `do_configuration'
	from /Users/deivid/.asdf/installs/ruby/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/gem_runner.rb:33:in `run'
	from /Users/deivid/.asdf/installs/ruby/3.2.1/bin/gem:10:in `<main>'
```

This commit makes RubyGems print a better error in this case:

```
$ ruby -Ilib bin/gem install$(echo -e "\xFF") foo
/Users/deivid/Code/rubygems/rubygems/lib/rubygems/gem_runner.rb:75:in `validate_encoding': invalid argument: 'install�' has invalid encoding (Gem::OptionParser::InvalidArgument)
	from /Users/deivid/Code/rubygems/rubygems/lib/rubygems/gem_runner.rb:31:in `run'
	from bin/gem:10:in `<main>'
```
2024-11-04 10:18:55 +00:00
David Rodríguez
9ce1b5e11f [rubygems/rubygems] Fix commands with 2 MFA requests when webauthn is enabled
If a command requires two MFA authenticated requests, and webauthn is
enabled, then first one will succeed but the second one will fail
because it tries to reuse the OTP code from the first request and that
does not work.

This happens when you have not yet logged in to rubygems.org, or when
you have an API key with invalid scopes for the current operation. In
that case, we need:

* An API request to get a token or change scopes for the one that you
  have.
* Another API request to perform the actual operation.

Instead of trying to reuse the token, make sure it's cleared so we are
asked to authenticate again. We only do this when webauthn is enabled
because reusing TOPT tokens otherwise is allowed and I don't want to
break that.

669e343935
2024-11-04 10:04:58 +00:00
David Rodríguez
7fba517d50 [rubygems/rubygems] OTP is already added by rubygems_api_request
15930fe126
2024-11-04 10:04:57 +00:00
David Rodríguez
50dbe19b68 [rubygems/rubygems] Fix incompatible encodings error
d478ec403f
2024-11-04 10:04:40 +00:00
Hiroshi SHIBATA
314b556cc5 [ruby/fileutils] Bump up v1.7.3
c138e67613
2024-11-01 05:04:32 +00:00
Jean Boussier
7daa1083c9 [ruby/json] Move State#configure back into C
While less nice, this open the door to eluding the State object
allocation when possible.

5c0d428d4c
2024-11-01 13:04:24 +09:00
Sarah Sehr
80fd846353 [rubygems/rubygems] Add useful error message for plugin load
If a plugin has previously been installed, but the path is no longer
valid, `rake setup` will fail with an unexpected error due to the file
not existing.

Instead, we want to present the user with what the issue is and how to
resolve the problem.

0c6ad3ecbb
2024-10-31 17:10:31 +00:00
Stan Lo
53df2a3c54 [ruby/rdoc] Use thicker fonts with high contrast to improve
readability
(https://github.com/ruby/rdoc/pull/1197)

7fb0e509ec
2024-10-31 10:05:19 +00:00
Guilherme Carreiro
c3fea18094 [rubygems/rubygems] Update --ext=rust to support compiling the native extension from source
9b0ec807c7
2024-10-30 23:09:12 +00:00
David Rodríguez
5da1cc6c9c [rubygems/rubygems] Rely on PATH if Ruby is not installed in the same directory as the binstub
ab7d65cc18

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2024-10-30 19:38:08 +00:00
David Rodríguez
116d6cbc83 [rubygems/rubygems] Simplify enable-load-relative prolog script creation
f2ed507afe
2024-10-30 19:38:07 +00:00
David Rodríguez
1e1a37220b [rubygems/rubygems] Fix gem update --system leaving old default bundler executables around
4b81add54c
2024-10-30 14:22:08 +00:00
David Rodríguez
ec0d0449dd [rubygems/rubygems] Remove confusing documentation
The first paragraph is misleading because command line flags that set
configuration are deprecated.

The second one is unnecessary because configuration precedence is
explained before the different configurations.

6cc64964ff
2024-10-30 14:20:52 +00:00
Jerome Dalbert
caa6bcc91f [rubygems/rubygems] Indent github workflow steps for generated gems
a1784e2efa
2024-10-30 14:06:58 +00:00
Jean Boussier
b094ee3f23
Handle all formatting configs potentially being nil.
Fix: https://github.com/ruby/json/issues/653

I don't think this was really fully supported in the past, but
it kinda worked with some of the implementations.
2024-10-29 13:25:01 +09:00
David Rodríguez
5fa491b405 Normalize lockfile platforms 2024-10-26 18:44:15 +09:00
Nobuyoshi Nakada
10e0ebc7c2 [ruby/rdoc] Remove details markers in HTML documents
`summary {list-style: none;}` still does not work in Safari 18.

c6a0a6a0d5
2024-10-25 07:12:07 +00:00
tomoya ishida
979e447d7e [ruby/reline] nonprinting_start and nonprinting_end should be
removed
(https://github.com/ruby/reline/pull/771)

e36441652a
2024-10-24 16:36:39 +00:00
Wu
78378cae66 append completion_append_character only when continous completion is … (#764)
* append completion_append_character only when continous completion is not possible

* refactoring

* remove debug puts
2024-10-24 14:12:41 +00:00
Ellen Marie Dash
5549dd2c12 [rubygems/rubygems] [SpecFetcher] Change < to <= like it should be.
3d5135e69b
2024-10-24 00:55:30 +00:00
Guilherme Carreiro
0b3d518e81 [ruby/error_highlight] Rename the ErrorHighlight::DefaultFormatter setting to max_snippet_width for clarity
e13cbd4335
2024-10-24 00:29:20 +00:00
Stan Lo
60c0c324b2 [ruby/rdoc] Red-based darkfish color scheme
(https://github.com/ruby/rdoc/pull/1191)

* Cleanup rdoc.css

* Use red as the highlight color

* Use the same red as ruby-lang.org

* Make main section links stand out more

* Remove scrollbar styling

f69dc470ac
2024-10-23 22:36:27 +00:00
Ellen Marie Dash
60d8435418 [rubygems/rubygems] [SpecFetcher] Avoid unneeded string allocation.
1024505d8e
2024-10-23 20:03:15 +00:00
Ellen Marie Dash
ab7c800ea8 [rubygems/rubygems] [SpecFetcher] Bail before calling available_specs()
0719921af4
2024-10-23 20:03:15 +00:00
Ellen Marie Dash
0f5941a5dd [rubygems/rubygems] Replace .map{...}.compact with .filter_map {...}
18c4ea7d00
2024-10-23 20:03:15 +00:00
Ellen Marie Dash
65fd8606a9 [rubygems/rubygems] Add another bail-early condition to suggest_gems_from_name(), with test.
7bb7c0ac2d
2024-10-23 20:03:14 +00:00
Ellen Marie Dash
ff749d9956 [rubygems/rubygems] Optimize when suggest_gems_from_name finds an exact match.
6c67298584
2024-10-23 20:03:14 +00:00
Ellen Marie Dash
fe66eee1a0 [rubygems/rubygems] Document suggest_gems_from_name()
8f9983cc21
2024-10-23 20:03:13 +00:00
Ellen Marie Dash
35f0b7c83f [rubygems/rubygems] [suggest_gems_from_name] Bail early if the value is guaranteed to be rejected.
56262a9384
2024-10-23 20:03:13 +00:00
David Rodríguez
438d36eb4b [rubygems/rubygems] Print a proper error when there's a previous empty installation path with bad permissions
07e7f0bf5e
2024-10-23 11:16:53 +00:00
David Rodríguez
f2380081df [rubygems/rubygems] Improve Bundler errors when trying to install to a protected folder in macOS
### Before

```
$ GEM_HOME=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/ bundle
Fetching gem metadata from https://rubygems.org/.
Source rubygems repository https://rubygems.org/ or installed locally is ignoring #<Bundler::StubSpecification name=sqlite3 version=1.3.13 platform=ruby> because it is missing extensions
Source rubygems repository https://rubygems.org/ or installed locally is ignoring #<Bundler::StubSpecification name=nokogiri version=1.13.8 platform=ruby> because it is missing extensions
Source rubygems repository https://rubygems.org/ or installed locally is ignoring #<Bundler::StubSpecification name=libxml-ruby version=3.2.1 platform=ruby> because it is missing extensions
Resolving dependencies...
Fetching ruby2_keywords 0.0.5

Retrying download gem from https://rubygems.org/ due to error (2/4): Bundler::GenericSystemCallError There was an error accessing `/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/cache/ruby2_keywords-0.0.5.gem`.
The underlying system error is Errno::EPERM: Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/cache/ruby2_keywords-0.0.5.gem

Retrying download gem from https://rubygems.org/ due to error (3/4): Bundler::GenericSystemCallError There was an error accessing `/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/cache/ruby2_keywords-0.0.5.gem`.
The underlying system error is Errno::EPERM: Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/cache/ruby2_keywords-0.0.5.gem

Retrying download gem from https://rubygems.org/ due to error (4/4): Bundler::GenericSystemCallError There was an error accessing `/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/cache/ruby2_keywords-0.0.5.gem`.
The underlying system error is Errno::EPERM: Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/cache/ruby2_keywords-0.0.5.gem

Bundler::GenericSystemCallError: There was an error accessing `/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/cache/ruby2_keywords-0.0.5.gem`.
The underlying system error is Errno::EPERM: Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/cache/ruby2_keywords-0.0.5.gem
  /Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/shared_helpers.rb:119:in `rescue in filesystem_access'
  /Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/shared_helpers.rb:104:in `filesystem_access'
  /Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/rubygems_integration.rb:431:in `block in download_gem'
  /Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/retry.rb:40:in `run'
  /Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/retry.rb:30:in `attempt'
  /Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/rubygems_integration.rb:423:in `download_gem'
  /Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/source/rubygems.rb:479:in `download_gem'
  /Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/source/rubygems.rb:436:in `fetch_gem'
  /Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/source/rubygems.rb:420:in `fetch_gem_if_possible'
  /Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/source/rubygems.rb:162:in `install'
  /Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/installer/gem_installer.rb:55:in `install'
  /Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/installer/gem_installer.rb:17:in `install_from_spec'
  /Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/installer/parallel_installer.rb:133:in `do_install'
  /Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/installer/parallel_installer.rb:124:in `block in worker_pool'
  /Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/worker.rb:62:in `apply_func'
  /Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/worker.rb:57:in `block in process_queue'
  <internal:kernel>:187:in `loop'
  /Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/worker.rb:54:in `process_queue'
  /Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/worker.rb:90:in `block (2 levels) in create_threads'

An error occurred while installing ruby2_keywords (0.0.5), and Bundler cannot continue.

In Gemfile:
  ruby2_keywords
```

### After

```
$ GEM_HOME=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/ bundle
There was an error creating `/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/bundler.lock`.
The underlying system error is Errno::EPERM: Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/bundler.lock
```

345ec45f5a
2024-10-23 08:53:19 +00:00
David Rodríguez
055ed5f592 [rubygems/rubygems] Improve Bundler::GenericSystemCall error message
ccd7e084a8
2024-10-23 08:53:18 +00:00
David Rodríguez
cc29d737ef [rubygems/rubygems] Consistently use :create action when creating directories
It gives better errors.

bedae080ef
2024-10-23 08:53:18 +00:00
David Rodríguez
b843d4ee14 [rubygems/rubygems] Fix running bundler (with a final r) in a bundle exec context
ad95a1dfaa
2024-10-23 08:52:46 +00:00
David Rodríguez
4790ecc86f [rubygems/rubygems] Do what the comment says, it's simpler
0511d2c08d
2024-10-23 08:52:45 +00:00
David Rodríguez
ffd51926bf [rubygems/rubygems] Remove the need for some bundler monkeypatches
f530f8686d
2024-10-23 08:52:45 +00:00
Jerome Dalbert
ad85354452 Clarify bundler inline’s install parameter 2024-10-23 08:52:19 +00:00
Taketo Takashima
19747c1ca6 [ruby/ipaddr] Drop support for Ruby 2.3
4685fca13d
2024-10-23 04:07:30 +00:00
Guilherme Carreiro
e9ba6c2ea4 [ruby/error_highlight] Adjust truncation, add opt-out mechanism, rename methods, and prepare error highlighting to render on extremely small screens
c565340958
2024-10-23 00:58:50 +00:00
Guilherme Carreiro
e7c9dfb3e9 [ruby/error_highlight] Handle very long lines with errors in the middle of the line
0657bc1afa
2024-10-23 00:58:50 +00:00
Guilherme Carreiro
5aa8b9e3b5 [ruby/error_highlight] Handle very long lines
383490a4b4
2024-10-23 00:58:50 +00:00
David Rodríguez
b39b998a17 [rubygems/rubygems] Remove patches for old TruffleRuby versions
264c61eb8e
2024-10-22 20:32:56 +00:00
Wu
e288604eb3 [ruby/reline] Use IO's encoding instead of Encoding.default_external
(https://github.com/ruby/reline/pull/765)

* use IO's encoding

* refactoring

* remove unused encoding params

* (for retriggering CI) remove unused encoding params

f09772adab
2024-10-22 14:43:18 +00:00
KJ Tsanaktsidis
7d254e4a2e Perform an actual access check in Dir.tmpdir for writability
At the moment, this code is looking at the stat output to determine if a
temp directory can be written to. However, just because the stat bits
say that a directory is writable, does not make it so; and, likewise,
the operating system may in fact grant access to paths that the stat
bits and process UID say should be inaccessible.

These systems include:

* Posix ACL's
* Linux's capabilities like CAP_DAC_OVERRIDE
* Linux Security Modules like SELinux or AppArmor
* Syscall filters like Linux's seccomp
* Granular capability systems like FreeBSD's Capsicum
* OpenBSD's pledge and unveil
* Windows too has a rich ACL system for controlling filesystem access

The best thing to do is simply to try and access the path with
`File.writable?` and let the operating system tell us if the path can be
accessed.
2024-10-22 15:17:52 +11:00
Akinori MUSHA
b101ca598e [ruby/ipaddr] Bump the version to 1.2.7
b44d2a1173
2024-10-19 12:59:03 +00:00
Akinori MUSHA
bfc586b2be [ruby/ipaddr] Use string interpolation instead of format()
1f41cd7320
2024-10-19 12:56:27 +00:00
Tsutomu Katsube
f370a31578 [ruby/irb] Suppress "literal string will be frozen in the future"
warning
(https://github.com/ruby/irb/pull/1019)

* Suppress "literal string will be frozen in the future" warning

Before change:

```console
$ ruby -W -I lib -e 'require "irb"; IRB.setup(nil); IRB::Irb.new.build_statement("1 + 2")'
/Users/zzz/src/github.com/ruby/irb/lib/irb.rb:1135: warning: literal string will be frozen in the future
```

After change:

```console
$ ruby -W -I lib -e 'require "irb"; IRB.setup(nil); IRB::Irb.new.build_statement("1 + 2")'
```

* Making build_statement not modify the given argument

Because improves readability and code quality.

Co-authored-by: tomoya ishida <tomoyapenguin@gmail.com>

---------

3da04b9786

Co-authored-by: tomoya ishida <tomoyapenguin@gmail.com>
2024-10-18 17:15:25 +00:00
tomoya ishida
09ddfd4d1c [ruby/irb] Always use alternate sceen on alt-d
(https://github.com/ruby/irb/pull/988)

db0a923d62
2024-10-18 17:15:11 +00:00
Jerome Dalbert
fce5bbd6a7 [rubygems/rubygems] Add bundle add --quiet option
This option is similar to the `bundle install --quiet` option

3bd773d827
2024-10-18 16:19:31 +00:00