dry-rb / dry-logic

Predicate logic with rule composition
https://dry-rb.org/gems/dry-logic/
MIT License
179 stars 66 forks source link

Add empty Operations module to fix spurious loading issues #97

Closed robhanlon22 closed 2 years ago

robhanlon22 commented 2 years ago

Ran into this load error when trying to run tests in a bespoke CI environment:

LoadError:
  cannot load such file -- .../lib/dry/logic/operations
  # .../lib/dry/logic/operators.rb:7:in `require'
  # .../lib/dry/logic/operators.rb:7:in `and'

I believe that this has to do with Zeitwerk loading and the order that things get loaded. It's trying to load the operations file but it's not there. Adding this file with a module declaration fixes this issue, and seems most consistent with Ruby patterns (a file named the same as a directory that declares the directory's module).

flash-gordon commented 2 years ago

I'm pretty sure it's not a proper fix. I have very similar issues with specs in dry-system that reloaded zetwerk's context in tests. The solution was to fix the helper. Please check out that repo, the fix may be in a non-main branch (I'm on mobile atm).

flash-gordon commented 2 years ago

By the way, it took me some time to figure it out. I used debugging tips from zeitwerk repo (you can set a custom logger for zeitwerk operations).