ruby/lib/rubygems
David Rodríguez c0688c21fe [rubygems/rubygems] Raise a simpler error when RubyGems fails to activate a dependency
If you force uninstall a dependency but leave other gems depending on
it, those gems will fail to be activated.

In that case, RubyGems prints a rather complicated error:

```
$ rails --version
/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1413:in 'block in Gem::Specification#activate_dependencies': Could not find 'activesupport' (= 8.0.1) among 478 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/deivid/.local/share/gem/ruby/3.4.0:/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0' at: /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/specifications/railties-8.0.1.gemspec, execute `gem env` for more information
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1399:in 'Array#each'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1399:in 'Gem::Specification#activate_dependencies'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1381:in 'Gem::Specification#activate'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:283:in 'block in Gem.activate_bin_path'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Thread::Mutex#synchronize'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Gem.activate_bin_path'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/bin/rails:25:in '<main>'
/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/dependency.rb:303:in 'Gem::Dependency#to_specs': Could not find 'activesupport' (= 8.0.1) - did find: [activesupport-7.1.3,activesupport-7.0.8.7] (Gem::MissingSpecVersionError)
Checked in 'GEM_PATH=/Users/deivid/.local/share/gem/ruby/3.4.0:/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0' , execute `gem env` for more information
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1411:in 'block in Gem::Specification#activate_dependencies'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1399:in 'Array#each'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1399:in 'Gem::Specification#activate_dependencies'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1381:in 'Gem::Specification#activate'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:283:in 'block in Gem.activate_bin_path'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Thread::Mutex#synchronize'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Gem.activate_bin_path'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/bin/rails:25:in '<main>'
```

With this commit, the error becomes a bit simpler to parse:

```
$ rails --version
/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1421:in 'block in Gem::Specification#activate_dependencies': Could not find 'activesupport' (= 8.0.1) among 478 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/deivid/.local/share/gem/ruby/3.4.0:/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0' at: /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/specifications/railties-8.0.1.gemspec, execute `gem env` for more information
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1407:in 'Array#each'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1407:in 'Gem::Specification#activate_dependencies'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1389:in 'Gem::Specification#activate'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:283:in 'block in Gem.activate_bin_path'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Thread::Mutex#synchronize'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Gem.activate_bin_path'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/bin/rails:25:in '<main>'
```

And also, we reduce exception based control flow in our code.

7e48c49f2d
2025-02-03 10:05:34 +09:00
..
commands [rubygems/rubygems] Add credentials file path to "gem env". 2025-01-09 18:13:57 +00:00
core_ext [rubygems/rubygems] Update required_ruby_version to 3.1 2024-10-04 20:01:51 +00:00
ext [rubygems/rubygems] Enable Performance/MapCompact cop 2024-11-26 15:11:05 +09:00
gemcutter_utilities [rubygems/rubygems] Rename credential email to identifier in WebAuthn poller 2024-05-03 10:54:27 +00:00
package [rubygems/rubygems] Fix incompatible encodings error 2024-11-04 10:04:40 +00:00
request
request_set [rubygems/rubygems] [DOC] Fix missing single quote 2024-12-02 16:06:44 +00:00
resolver [rubygems/rubygems] Stop storing executable names in ivars 2024-12-05 19:00:44 +00:00
safe_marshal Merge RubyGems-3.6.2 and Bundler-2.6.2 2024-12-24 07:21:10 +09:00
security
source [rubygems/rubygems] Apply suggestions from code review 2024-12-05 19:00:44 +00:00
ssl_certs
util [rubygems/rubygems] Update SPDX license list as of 2024-12-30 2025-01-06 07:19:23 +00:00
vendor Ignore vendor folder for documentation just once 2025-01-28 15:37:55 +09:00
available_set.rb
basic_specification.rb [rubygems/rubygems] Prevent some test suite warnings about missing extensions 2024-10-14 19:43:39 +00:00
bundler_version_finder.rb [rubygems/rubygems] Make "bundler? update --bundler" behave identically 2024-06-20 00:12:31 +00:00
ci_detector.rb
command.rb [rubygems/rubygems] Rename wrapper files for vendored libraries with 'vendored_' prefix 2024-02-26 22:04:04 +00:00
command_manager.rb [rubygems/rubygems] Fix plugin command loading 2024-10-09 05:26:27 +00:00
compatibility.rb
config_file.rb [rubygems/rubygems] fix s3 source configuration issue 2024-07-11 02:27:46 +00:00
defaults.rb [rubygems/rubygems] Keep Gem.install_extension_in_lib for compatibility 2024-02-20 05:33:16 +00:00
dependency.rb [rubygems/rubygems] Fix specs with missing extensions getting activated 2024-10-10 14:51:32 +00:00
dependency_installer.rb
dependency_list.rb [rubygems/rubygems] Rename wrapper files for vendored libraries with 'vendored_' prefix 2024-02-26 22:04:04 +00:00
deprecate.rb [rubygems/rubygems] Fix circular require warning 2024-04-29 09:04:33 +00:00
doctor.rb
errors.rb [rubygems/rubygems] Make sure MissingSpecVersionError#to_s prints exception message 2024-10-02 14:34:55 +09:00
exceptions.rb [rubygems/rubygems] Deprecate constant that has been unused for a long time 2024-09-06 18:44:37 +00:00
ext.rb
gem_runner.rb Validate user input encoding 2024-11-04 10:18:55 +00:00
gemcutter_utilities.rb [rubygems/rubygems] Fix commands with 2 MFA requests when webauthn is enabled 2024-11-04 10:04:58 +00:00
gemspec_helpers.rb [rubygems/rubygems] [gemspec_helpers] Fix Rubocop warning. 2024-03-29 08:03:41 +00:00
install_default_message.rb
install_message.rb
install_update_options.rb [rubygems/rubygems] Add --target-rbconfig option to gem install and gem update commands 2024-06-18 00:59:35 +00:00
installer.rb [rubygems/rubygems] Rely on PATH if Ruby is not installed in the same directory as the binstub 2024-10-30 19:38:08 +00:00
installer_uninstaller_utils.rb
local_remote_options.rb
name_tuple.rb
openssl.rb
package.rb [rubygems/rubygems] Remove Gem::Specification#mark_version 2024-05-03 15:12:55 +00:00
package_task.rb
path_support.rb
platform.rb [rubygems/rubygems] Restrict generic arm to only match 32-bit arm 2024-07-05 09:02:52 +00:00
psych_tree.rb [rubygems/rubygems] Use Hash#compact 2024-02-21 06:39:37 +00:00
query_utils.rb [rubygems/rubygems] Fix gem info tagging some non default gems as default 2024-12-16 18:09:54 +00:00
rdoc.rb Merge RubyGems-3.6.2 and Bundler-2.6.2 2024-12-24 07:21:10 +09:00
remote_fetcher.rb [rubygems/rubygems] Removed unused stringio 2024-09-04 08:57:17 +00:00
request.rb [rubygems/rubygems] Rename wrapper files for vendored libraries with 'vendored_' prefix 2024-02-26 22:04:04 +00:00
request_set.rb [rubygems/rubygems] Rename wrapper files for vendored libraries with 'vendored_' prefix 2024-02-26 22:04:04 +00:00
requirement.rb Merge RubyGems-3.6.2 and Bundler-2.6.2 2024-12-24 07:21:10 +09:00
resolver.rb [rubygems/rubygems] Enable Performance/MapCompact cop 2024-11-26 15:11:05 +09:00
s3_uri_signer.rb [rubygems/rubygems] Rename wrapper files for vendored libraries with 'vendored_' prefix 2024-02-26 22:04:04 +00:00
safe_marshal.rb
safe_yaml.rb [rubygems/rubygems] Commit missing new method 2024-02-21 17:45:00 +00:00
security.rb [rubygems/rubygems] Use https instead of http 2024-02-21 03:30:22 +00:00
security_option.rb
shellwords.rb
source.rb [rubygems/rubygems] Remove unnecessary "./" when appending string to uri 2024-09-06 18:44:38 +00:00
source_list.rb
spec_fetcher.rb [rubygems/rubygems] [SpecFetcher] If candidates include {name}-ruby or ruby-{name}, recommend those. 2024-11-26 22:04:26 +00:00
specification.rb [rubygems/rubygems] Raise a simpler error when RubyGems fails to activate a dependency 2025-02-03 10:05:34 +09:00
specification_policy.rb [rubygems/rubygems] Fix spelling, it's "cannot" rather than "can not" 2024-09-17 20:09:07 +00:00
specification_record.rb [rubygems/rubygems] Fix duplicated specs when they have been previously activated 2024-10-14 14:51:20 +00:00
stub_specification.rb [rubygems/rubygems] Fix gem pristine etc resetting gem twice sometimes 2024-10-10 14:54:04 +00:00
target_rbconfig.rb [rubygems/rubygems] Add --target-rbconfig option to gem install and gem update commands 2024-06-18 00:59:35 +00:00
text.rb
uninstaller.rb Merge RubyGems-3.6.2 and Bundler-2.6.2 2024-12-24 07:21:10 +09:00
unknown_command_spell_checker.rb
update_suggestion.rb
uri.rb [rubygems/rubygems] URI::DEFAULT_PARSER.escape is obsoleted. We should use URI::RFC2396_PARSER.escape explicitly 2024-11-14 07:44:01 +00:00
uri_formatter.rb
user_interaction.rb
util.rb
validator.rb
vendored_molinillo.rb
vendored_net_http.rb [rubygems/rubygems] Skip to load vendored libraries if it's already loaded 2024-02-26 22:04:08 +00:00
vendored_optparse.rb [rubygems/rubygems] Rename wrapper files for vendored libraries with 'vendored_' prefix 2024-02-26 22:04:04 +00:00
vendored_securerandom.rb Bump vendored securerandom to 0.4.0 2024-12-13 11:24:08 +09:00
vendored_timeout.rb [rubygems/rubygems] Skip to load vendored libraries if it's already loaded 2024-02-26 22:04:08 +00:00
vendored_tsort.rb [rubygems/rubygems] Rename wrapper files for vendored libraries with 'vendored_' prefix 2024-02-26 22:04:04 +00:00
version.rb Merge RubyGems-3.6.2 and Bundler-2.6.2 2024-12-24 07:21:10 +09:00
version_option.rb
yaml_serializer.rb [rubygems/rubygems] Fix line comment issue for map 2024-07-19 03:03:16 +00:00