Skip to content

Fix optional dependency error classification - #168

Merged
id774 merged 1 commit into
masterfrom
claude/automaticruby-optional-dependency-error-xsav6f
Sep 6, 2026
Merged

Fix optional dependency error classification#168
id774 merged 1 commit into
masterfrom
claude/automaticruby-optional-dependency-error-xsav6f

Conversation

@id774

@id774 id774 commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Automatic.require_optional now classifies a LoadError as a missing optional dependency only when its path matches the exact feature it was asked to require, converting that case to the new Automatic::OptionalDependencyError (a LoadError subtype).
  • A LoadError raised from inside that feature's own load (a different, unrelated missing file) is re-raised unconverted, as the original exception.
  • Automatic::CLI#run_recipe and the subcommand dispatch path now rescue Automatic::OptionalDependencyError specifically instead of LoadError in general, so an unrelated LoadError propagates instead of being reported as the one-line operator diagnostic.
  • AutomaticSpec.plugin_available? (spec/spec_helper.rb) now rescues only Automatic::OptionalDependencyError to skip a plugin spec; any other LoadError from a plugin's own load now fails the spec instead of being silently skipped.

Reason

Previously, Automatic.require_optional caught every LoadError raised while requiring a feature, including one raised from a nested require deep 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.
  • The user-facing message for a genuinely missing optional dependency (gem name, needed_by, gem install guidance, source-checkout bundle guidance, original load failure) is unchanged.
  • Automatic::OptionalDependencyError is a LoadError subtype, so any existing caller rescuing LoadError still catches it.
  • No dependency, 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 for AutomaticSpec.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 --version and --help — succeeded.

Version History

Recorded as one independent release item under the existing unreleased v26.09 section of doc/VERSIONS:

Distinguish missing optional dependencies from unrelated load failures so CLI diagnostics and plugin-spec skips do not hide broken loads.

VERSION remains 26.09; no version bump.

🤖 Generated with Claude Code

https://claude.ai/code/session_01H8NygEHhT3zGMnBmQF2F6Q


Generated by Claude Code

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H8NygEHhT3zGMnBmQF2F6Q
@id774
id774 merged commit c1b08c1 into master Sep 6, 2026
8 checks passed
@id774
id774 deleted the claude/automaticruby-optional-dependency-error-xsav6f branch September 6, 2026 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants