dry-rb / dry-rails

The official dry-rb railtie
https://dry-rb.org/gems/dry-rails
MIT License
270 stars 27 forks source link

`fetch': key not found: :path (KeyError) #51

Closed joshmfrankel closed 2 years ago

joshmfrankel commented 2 years ago

Describe the bug

Running Rails tests or server produces the following error fetch': key not found: :path (KeyError).

I'm using dry-rails but the issue seems to stem from lib/dry/system.rb:23 (dry-system)

Backtrace

> bundle exec rails test
/usr/local/bundle/gems/dry-system-0.23.0/lib/dry/system.rb:23:in `fetch': key not found: :path (KeyError)
    from /usr/local/bundle/gems/dry-system-0.23.0/lib/dry/system.rb:23:in `register_provider'
    from /usr/local/bundle/gems/dry-rails-0.4.0/lib/dry/rails/components.rb:5:in `<top (required)>'
    from /usr/local/bundle/gems/dry-rails-0.4.0/lib/dry/rails.rb:5:in `require'
    from /usr/local/bundle/gems/dry-rails-0.4.0/lib/dry/rails.rb:5:in `<top (required)>'
    from /usr/local/bundle/gems/dry-rails-0.4.0/lib/dry-rails.rb:3:in `require'
    from /usr/local/bundle/gems/dry-rails-0.4.0/lib/dry-rails.rb:3:in `<top (required)>'
    from /usr/local/bundle/gems/bundler-2.3.5/lib/bundler/runtime.rb:60:in `require'
    from /usr/local/bundle/gems/bundler-2.3.5/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
    from /usr/local/bundle/gems/bundler-2.3.5/lib/bundler/runtime.rb:55:in `each'
    from /usr/local/bundle/gems/bundler-2.3.5/lib/bundler/runtime.rb:55:in `block in require'
    from /usr/local/bundle/gems/bundler-2.3.5/lib/bundler/runtime.rb:44:in `each'
    from /usr/local/bundle/gems/bundler-2.3.5/lib/bundler/runtime.rb:44:in `require'
    from /usr/local/bundle/gems/bundler-2.3.5/lib/bundler.rb:176:in `require'
    from /app/config/application.rb:7:in `<top (required)>'
    from /app/config/environment.rb:2:in `require_relative'
    from /app/config/environment.rb:2:in `<top (required)>'
    from /app/test/test_helper.rb:12:in `require_relative'
    from /app/test/test_helper.rb:12:in `<top (required)>'
    from /app/test/controllers/api/v1/some_controller_test.rb:2:in `require'
    from /app/test/controllers/api/v1/some_controller_test.rb:2:in `<top (required)>'
    from /usr/local/bundle/gems/railties-7.0.1/lib/rails/test_unit/runner.rb:47:in `require'
    from /usr/local/bundle/gems/railties-7.0.1/lib/rails/test_unit/runner.rb:47:in `block in load_tests'
    from /usr/local/bundle/gems/railties-7.0.1/lib/rails/test_unit/runner.rb:47:in `each'
    from /usr/local/bundle/gems/railties-7.0.1/lib/rails/test_unit/runner.rb:47:in `load_tests'
    from /usr/local/bundle/gems/railties-7.0.1/lib/rails/test_unit/runner.rb:40:in `run'
    from /usr/local/bundle/gems/railties-7.0.1/lib/rails/commands/test/test_command.rb:33:in `perform'
    from /usr/local/bundle/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
    from /usr/local/bundle/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
    from /usr/local/bundle/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
    from /usr/local/bundle/gems/railties-7.0.1/lib/rails/command/base.rb:87:in `perform'
    from /usr/local/bundle/gems/railties-7.0.1/lib/rails/command.rb:48:in `invoke'
    from /usr/local/bundle/gems/railties-7.0.1/lib/rails/commands.rb:18:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'
ERROR: 1

To Reproduce

I'm using a super basic docker + rails repo and am able to recreate issue once I add gem 'dry-rails' to the Gemfile. Rails server and testing stops working. See Repo here: https://github.com/joshmfrankel/rails-7-docker

Expected behavior

Expect tests and server to execute and dry-system to properly build

My environment

timriley commented 2 years ago

dry-system 0.23 had a lot of big changes. I'd recommend you pin to 0.22 within your app for now, it thank you for raising this issue here for us to fix.

joshmfrankel commented 2 years ago

@timriley Thank you for the speedy and efficient response. That solved it for me 💯. We've at least got a workaround now

gem "dry-rails", "~> 0.3"
gem "dry-system", "<= 0.22"
solnic commented 2 years ago

I'm gonna fix it and push a new release tomorrowish

timriley commented 2 years ago

@solnic i promise to drop breaking dry-rails soon ;)

solnic commented 2 years ago

@timriley haha yeah, one day we'll have cross-repo automated test suites, one day

solnic commented 2 years ago

This is a bit more involved, I started upgrading the whole thing in #52

solnic commented 2 years ago

OK I released 0.5.0

timriley commented 2 years ago

Thank you @solnic! 🙏🏼