Dry-validation/Dry-schema uninitialized constant Dry::Schema::PredicateRegistry

1.1k views Asked by At

I'm attempting to update the ruby version of an empty, stock API (which is forked to create new API) from Ruby 2.6.3 to Ruby 2.7.3 using TrailBlazer.

Currently, I'm having issues with the Dry gems, specifically Dry-Validation (1.8.0), Dry-Schema (1.9.1), and their Predicate Registry extension.

Every time I run bundle exec rspec , I get this error:

Failure/Error: require './initialize'

NameError:
  uninitialized constant Dry::Schema::PredicateRegistry

With this stack-trace:

# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/dry-schema-1.11.3/lib/dry/schema/config.rb:25:in `<class:Config>'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/dry-schema-1.11.3/lib/dry/schema/config.rb:14:in `<module:Schema>'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/dry-schema-1.11.3/lib/dry/schema/config.rb:8:in `<module:Dry>'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/dry-schema-1.11.3/lib/dry/schema/config.rb:7:in `<top (required)>'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/dry-validation-1.8.0/lib/dry/validation/config.rb:3:in `<top (required)>'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/dry-validation-1.8.0/lib/dry/validation/contract.rb:9:in `<top (required)>'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/dry-validation-1.8.0/lib/dry/validation.rb:4:in `<top (required)>'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/dry-validation-1.8.0/lib/dry-validation.rb:3:in `<top (required)>'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/reform-2.6.2/lib/reform/form/dry.rb:2:in `<top (required)>'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/bundler/gems/<OMITTED, COMPANY SPECIFIC GEM>/system/boot/reform.rb:6:in `block (2 levels) in <top (required)>'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/dry-system-0.27.2/lib/dry/system/provider.rb:231:in `public_send'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/dry-system-0.27.2/lib/dry/system/provider.rb:231:in `run_step'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/dry-system-0.27.2/lib/dry/system/provider.rb:167:in `start'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/dry-system-0.27.2/lib/dry/system/provider_registrar.rb:252:in `with_provider'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/dry-system-0.27.2/lib/dry/system/provider_registrar.rb:175:in `start'
# /Users/sthieme/.rvm/gems/ruby-2.7.3/gems/dry-system-0.27.2/lib/dry/system/container.rb:385:in `start'
# ./initialize.rb:5:in `<top (required)>'
# ./spec/spec_helper.rb:13:in `<top (required)>'

Gemfile:

# frozen_string_literal: true

source 'https://rubygems.org'

ruby '2.7.3'

group :production do
  gem 'dry-container', "~>0.7"
  gem 'dry-struct'
  gem 'dry-system'
  gem 'dry-validation', "1.8"
  gem 'dry-schema', "~>1.9", ">=1.9.1"
  gem 'grape-swagger'
  gem 'multi_json'
  gem 'mysql2'
  gem 'aws-sdk-s3'
  # gem 'ruby-oci8'
  <OMITTED, COMPANY-SPECIC GEM>
  gem 'trailblazer', '~>2.0.1'
  gem 'unicorn'
  gem 'activesupport', '~>5.1'
end

group :test, :development do
  gem 'bundler-audit'
  gem 'climate_control'
  gem 'codeclimate-test-reporter'
  gem 'database_cleaner'
  gem 'factory_bot', "~> 6.2.0"
  gem 'faker'
  gem 'pry'
  gem 'rack-test'
  gem 'rake'
  gem 'reek'
  gem 'rspec'
  gem 'rspec_junit_formatter'
  gem 'rspec_sequel_matchers', git: 'https://github.com/openhood/rspec_sequel_matchers.git', branch: 'master'
  gem 'rubocop', '~> 0.9'
  gem 'rubocop-junit_formatter'
  gem 'rubocop-performance'
  gem 'shoulda-matchers', '~>4.5.1'
  gem 'simplecov', require: false
  gem 'webmock'
end

Gemfile.lock:

GIT
  remote: https://github.com/openhood/rspec_sequel_matchers.git
  revision: c0cfbd0599d856970f7cbf9cdd55175110888306
  branch: master
  specs:
    rspec_sequel_matchers (0.5.0)
      sequel (>= 3.8.0)

GIT
  remote: <OMITTED, COMPANY SPECIFIC GEM>
  revision: 697183381bfea3fb8fe1b69d1de54de961768ea3
  branch: sthieme-ruby-updates-test
  specs:
    <OMITTED, COMPANY SPECIFIC GEM>
      activesupport (~> 5.1)
      addressable (~> 2.5)
      aws-sdk-s3 (~> 1.8)
      bunny (~> 2.7)
      dotenv (~> 2.2)
      dry-configurable (~> 0.13)
      dry-matcher (~> 0.8)
      dry-system (~> 0.9)
      dry-validation (~> 1.8)
      elastic-apm (~> 2.1)
      erb-file_out (~> 0.1)
      faker (~> 1.8)
      faraday (~> 0.13)
      grape (~> 1.2)
      jwt (~> 2.2)
      mongo (~> 2.5)
      net-sftp (~> 2.1)
      net-ssh (~> 5.0.0.beta2)
      rack (~> 2.0.9)
      rack-cors (~> 1.0)
      rack-heartbeat (~> 1.1)
      rack-protection (~> 2.0)
      rubyzip (~> 1.2)
      secure_headers (~> 6.0)
      sequel (~> 5.4)
      slack-notifier (~> 2.3)
      trailblazer (~> 2.0)

GEM
  remote: https://rubygems.org/
  specs:
    activemodel (5.2.8.1)
      activesupport (= 5.2.8.1)
    activerecord (5.2.8.1)
      activemodel (= 5.2.8.1)
      activesupport (= 5.2.8.1)
      arel (>= 9.0)
    activesupport (5.2.8.1)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (>= 0.7, < 2)
      minitest (~> 5.1)
      tzinfo (~> 1.1)
    addressable (2.8.1)
      public_suffix (>= 2.0.2, < 6.0)
    amq-protocol (2.3.2)
    arel (9.0.0)
    ast (2.4.2)
    aws-eventstream (1.2.0)
    aws-partitions (1.683.0)
    aws-sdk-core (3.168.4)
      aws-eventstream (~> 1, >= 1.0.2)
      aws-partitions (~> 1, >= 1.651.0)
      aws-sigv4 (~> 1.5)
      jmespath (~> 1, >= 1.6.1)
    aws-sdk-kms (1.61.0)
      aws-sdk-core (~> 3, >= 3.165.0)
      aws-sigv4 (~> 1.1)
    aws-sdk-s3 (1.117.2)
      aws-sdk-core (~> 3, >= 3.165.0)
      aws-sdk-kms (~> 1)
      aws-sigv4 (~> 1.4)
    aws-sigv4 (1.5.2)
      aws-eventstream (~> 1, >= 1.0.2)
    bson (4.15.0)
    builder (3.2.4)
    bundler-audit (0.9.1)
      bundler (>= 1.2.0, < 3)
      thor (~> 1.0)
    bunny (2.20.1)
      amq-protocol (~> 2.3, >= 2.3.1)
      sorted_set (~> 1, >= 1.0.2)
    climate_control (1.2.0)
    codeclimate-test-reporter (1.0.7)
      simplecov
    coderay (1.1.3)
    concurrent-ruby (1.1.10)
    crack (0.4.5)
      rexml
    database_cleaner (2.0.1)
      database_cleaner-active_record (~> 2.0.0)
    database_cleaner-active_record (2.0.1)
      activerecord (>= 5.a)
      database_cleaner-core (~> 2.0.0)
    database_cleaner-core (2.0.1)
    declarative (0.0.20)
    diff-lcs (1.5.0)
    disposable (0.6.3)
      declarative (>= 0.0.9, < 1.0.0)
      representable (>= 3.1.1, < 4)
    docile (1.4.0)
    domain_name (0.5.20190701)
      unf (>= 0.0.5, < 1.0.0)
    dotenv (2.8.1)
    dry-auto_inject (0.9.0)
      dry-container (>= 0.3.4)
    dry-configurable (0.16.1)
      dry-core (~> 0.6)
      zeitwerk (~> 2.6)
    dry-container (0.11.0)
      concurrent-ruby (~> 1.0)
    dry-core (0.9.1)
      concurrent-ruby (~> 1.0)
      zeitwerk (~> 2.6)
    dry-inflector (0.3.0)
    dry-initializer (3.1.1)
    dry-logic (1.3.0)
      concurrent-ruby (~> 1.0)
      dry-core (~> 0.9, >= 0.9)
      zeitwerk (~> 2.6)
    dry-matcher (0.9.0)
      dry-core (~> 0.4, >= 0.4.8)
    dry-schema (1.11.3)
      concurrent-ruby (~> 1.0)
      dry-configurable (~> 0.16, >= 0.16)
      dry-core (~> 0.9, >= 0.9)
      dry-initializer (~> 3.0)
      dry-logic (~> 1.3)
      dry-types (~> 1.6)
      zeitwerk (~> 2.6)
    dry-struct (1.5.2)
      dry-core (~> 0.9, >= 0.9)
      dry-types (~> 1.6)
      ice_nine (~> 0.11)
      zeitwerk (~> 2.6)
    dry-system (0.27.2)
      dry-auto_inject (>= 0.4.0)
      dry-configurable (~> 0.16, >= 0.16.0)
      dry-container (~> 0.10, >= 0.10.0)
      dry-core (~> 0.9, >= 0.9.0)
      dry-inflector (~> 0.1, >= 0.1.2)
      zeitwerk (~> 2.6)
    dry-types (1.6.1)
      concurrent-ruby (~> 1.0)
      dry-container (~> 0.3)
      dry-core (~> 0.9, >= 0.9)
      dry-inflector (~> 0.1, >= 0.1.2)
      dry-logic (~> 1.3, >= 1.3)
      zeitwerk (~> 2.6)
    dry-validation (1.8.0)
      concurrent-ruby (~> 1.0)
      dry-container (~> 0.7, >= 0.7.1)
      dry-core (~> 0.5, >= 0.5)
      dry-initializer (~> 3.0)
      dry-schema (~> 1.9, >= 1.9.1)
    elastic-apm (2.12.0)
      concurrent-ruby (~> 1.0)
      http (>= 3.0)
    erb-file_out (0.1.2)
    factory_bot (6.2.1)
      activesupport (>= 5.0.0)
    faker (1.9.6)
      i18n (>= 0.7)
    faraday (0.17.6)
      multipart-post (>= 1.2, < 3)
    ffi (1.15.5)
    ffi-compiler (1.0.1)
      ffi (>= 1.0.0)
      rake
    grape (1.7.0)
      activesupport
      builder
      dry-types (>= 1.1)
      mustermann-grape (~> 1.0.0)
      rack (>= 1.3.0)
      rack-accept
    grape-swagger (1.5.0)
      grape (~> 1.3)
    hashdiff (1.0.1)
    http (5.1.1)
      addressable (~> 2.8)
      http-cookie (~> 1.0)
      http-form_data (~> 2.2)
      llhttp-ffi (~> 0.4.0)
    http-cookie (1.0.5)
      domain_name (~> 0.5)
    http-form_data (2.3.0)
    i18n (1.12.0)
      concurrent-ruby (~> 1.0)
    ice_nine (0.11.2)
    jmespath (1.6.2)
    jwt (2.6.0)
    kgio (2.11.4)
    kwalify (0.7.2)
    llhttp-ffi (0.4.0)
      ffi-compiler (~> 1.0)
      rake (~> 13.0)
    method_source (1.0.0)
    minitest (5.16.3)
    mongo (2.18.2)
      bson (>= 4.14.1, < 5.0.0)
    multi_json (1.15.0)
    multipart-post (2.2.3)
    mustermann (3.0.0)
      ruby2_keywords (~> 0.0.1)
    mustermann-grape (1.0.2)
      mustermann (>= 1.0.0)
    mysql2 (0.5.4)
    net-sftp (2.1.2)
      net-ssh (>= 2.6.5)
    net-ssh (5.0.2)
    parallel (1.22.1)
    parser (3.1.3.0)
      ast (~> 2.4.1)
    pipetree (0.1.1)
    pry (0.14.1)
      coderay (~> 1.1)
      method_source (~> 1.0)
    public_suffix (5.0.1)
    rack (2.0.9.1)
    rack-accept (0.4.5)
      rack (>= 0.4)
    rack-cors (1.1.1)
      rack (>= 2.0.0)
    rack-heartbeat (1.1.0)
      rack
    rack-protection (2.2.4)
      rack
    rack-test (2.0.2)
      rack (>= 1.3)
    rainbow (3.1.1)
    raindrops (0.20.0)
    rake (13.0.6)
    rbtree (0.4.6)
    reek (6.1.2)
      kwalify (~> 0.7.0)
      parser (~> 3.1.0)
      rainbow (>= 2.0, < 4.0)
    reform (2.6.2)
      disposable (>= 0.5.0, < 1.0.0)
      representable (>= 3.1.1, < 4)
      uber (< 0.2.0)
    regexp_parser (2.6.1)
    representable (3.2.0)
      declarative (< 0.1.0)
      trailblazer-option (>= 0.1.1, < 0.2.0)
      uber (< 0.2.0)
    rexml (3.2.5)
    rspec (3.12.0)
      rspec-core (~> 3.12.0)
      rspec-expectations (~> 3.12.0)
      rspec-mocks (~> 3.12.0)
    rspec-core (3.12.0)
      rspec-support (~> 3.12.0)
    rspec-expectations (3.12.1)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.12.0)
    rspec-mocks (3.12.1)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.12.0)
    rspec-support (3.12.0)
    rspec_junit_formatter (0.6.0)
      rspec-core (>= 2, < 4, != 2.12.0)
    rubocop (0.93.1)
      parallel (~> 1.10)
      parser (>= 2.7.1.5)
      rainbow (>= 2.2.2, < 4.0)
      regexp_parser (>= 1.8)
      rexml
      rubocop-ast (>= 0.6.0)
      ruby-progressbar (~> 1.7)
      unicode-display_width (>= 1.4.0, < 2.0)
    rubocop-ast (1.24.0)
      parser (>= 3.1.1.0)
    rubocop-junit_formatter (0.2)
      rubocop (~> 0.49)
    rubocop-performance (1.10.2)
      rubocop (>= 0.90.0, < 2.0)
      rubocop-ast (>= 0.4.0)
    ruby-progressbar (1.11.0)
    ruby2_keywords (0.0.5)
    rubyzip (1.3.0)
    secure_headers (6.5.0)
    sequel (5.63.0)
    set (1.0.3)
    shoulda-matchers (4.5.1)
      activesupport (>= 4.2.0)
    simplecov (0.21.2)
      docile (~> 1.1)
      simplecov-html (~> 0.11)
      simplecov_json_formatter (~> 0.1)
    simplecov-html (0.12.3)
    simplecov_json_formatter (0.1.4)
    slack-notifier (2.4.0)
    sorted_set (1.0.3)
      rbtree
      set (~> 1.0)
    thor (1.2.1)
    thread_safe (0.3.6)
    trailblazer (2.0.7)
      declarative
      reform (>= 2.2.0, < 3.0.0)
      trailblazer-operation (>= 0.0.12, < 0.1.0)
    trailblazer-operation (0.0.13)
      declarative
      pipetree (>= 0.1.1, < 0.2.0)
      uber
    trailblazer-option (0.1.2)
    tzinfo (1.2.10)
      thread_safe (~> 0.1)
    uber (0.1.0)
    unf (0.1.4)
      unf_ext
    unf_ext (0.0.8.2)
    unicode-display_width (1.8.0)
    unicorn (6.1.0)
      kgio (~> 2.6)
      raindrops (~> 0.7)
    webmock (3.18.1)
      addressable (>= 2.8.0)
      crack (>= 0.3.2)
      hashdiff (>= 0.4.0, < 2.0.0)
    zeitwerk (2.6.6)

PLATFORMS
  arm64-darwin-21

DEPENDENCIES
  activesupport (~> 5.1)
  aws-sdk-s3
  bundler-audit
  climate_control
  codeclimate-test-reporter
  database_cleaner
  dry-container (~> 0.7)
  dry-schema (~> 1.9, >= 1.9.1)
  dry-struct
  dry-system
  dry-validation (= 1.8)
  factory_bot (~> 6.2.0)
  faker
  grape-swagger
  multi_json
  mysql2
  pry
  rack-test
  rake
  reek
  rspec
  rspec_junit_formatter
  rspec_sequel_matchers!
  rubocop (~> 0.9)
  rubocop-junit_formatter
  rubocop-performance
  <OMITTED, COMPANY SPECIFIC GEM>
  shoulda-matchers (~> 4.5.1)
  simplecov
  trailblazer (~> 2.0.1)
  unicorn
  webmock

RUBY VERSION
   ruby 2.7.3p183

BUNDLED WITH
   2.3.26

It seems like the error is occurring from within the Dry-gem files when Dry-Validation attempts to require Dry-Schema, meaning I can't really edit that code. I can technically get into the Dry-gem files locally, but editing them will, of course, not carry over when deployed.

I've read up on dry-rb.org, making sure all of my dry-gems are compatible versions of each other and Validation and Schema are versions that can use the Predicate Registry extension.

I've attempted to load the predicate registry in a file I can edit, but if I use Dry-RB's Dry::Validation.load_extensions(:predicates_as_macros), I get this error:

Failure/Error: require './initialize'

NoMethodError:
  undefined method `load_extensions' for Dry::Validation:Module
  Did you mean?  load_dependency
0

There are 0 answers