Fix optional dependency error classification - #168
Merged
id774 merged 1 commit intoSep 6, 2026
Conversation
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H8NygEHhT3zGMnBmQF2F6Q
id774
deleted the
claude/automaticruby-optional-dependency-error-xsav6f
branch
September 6, 2026 06:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Automatic.require_optionalnow classifies aLoadErroras a missing optional dependency only when itspathmatches the exact feature it was asked to require, converting that case to the newAutomatic::OptionalDependencyError(aLoadErrorsubtype).LoadErrorraised from inside that feature's own load (a different, unrelated missing file) is re-raised unconverted, as the original exception.Automatic::CLI#run_recipeand the subcommand dispatch path now rescueAutomatic::OptionalDependencyErrorspecifically instead ofLoadErrorin general, so an unrelatedLoadErrorpropagates instead of being reported as the one-line operator diagnostic.AutomaticSpec.plugin_available?(spec/spec_helper.rb) now rescues onlyAutomatic::OptionalDependencyErrorto skip a plugin spec; any otherLoadErrorfrom a plugin's own load now fails the spec instead of being silently skipped.Reason
Previously,
Automatic.require_optionalcaught everyLoadErrorraised while requiring a feature, including one raised from a nestedrequiredeep inside that feature's own load path. That collapsed two different failures into one message: "the optional gem is not installed." This meant a genuinely broken plugin, dependency, or installation could be misreported as an operator-fixable missing-gem situation by the CLI, and could be silently skipped (false green) by the plugin spec helper, rather than surfacing as a real failure.Compatibility
Automatic.require_optional's argument interface (feature,needed_by:,gem_name:) is unchanged.needed_by,gem installguidance, source-checkout bundle guidance, original load failure) is unchanged.Automatic::OptionalDependencyErroris aLoadErrorsubtype, so any existing caller rescuingLoadErrorstill catches it.VERSION, or public CLI interface change.Tests
bundle exec rspec spec/lib/automatic_spec.rb— 17 examples, 0 failures.bundle exec rspec spec/lib/automatic/cli_spec.rb— 25 examples, 0 failures.bundle exec rspec spec/lib/automatic_spec_helper_spec.rb(new regression spec forAutomaticSpec.plugin_available?) — 3 examples, 0 failures.bundle exec rake spec— 373 examples, 0 failures.gem build automatic.gemspec— succeeded.bundle exec ruby -Ilib -e "require 'automatic'"— succeeded.bundle exec bin/automatic --versionand--help— succeeded.Version History
Recorded as one independent release item under the existing unreleased
v26.09section ofdoc/VERSIONS:VERSIONremains26.09; no version bump.🤖 Generated with Claude Code
https://claude.ai/code/session_01H8NygEHhT3zGMnBmQF2F6Q
Generated by Claude Code