-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release 1.5.0 breaks rails app boot with eager-loading #183
Comments
I am getting similar |
|
@flash-gordon I added a link to a PR that demonstrates how adding |
I figured it out. This would fix it: diff --git lib/dry/struct.rb lib/dry/struct.rb
index a6d4de6..aac1261 100644
--- lib/dry/struct.rb
+++ lib/dry/struct.rb
@@ -99,12 +99,16 @@ module Dry
loader.push_dir(root)
loader.ignore(
"#{root}/dry-struct.rb",
- "#{root}/dry/struct/{class_interface,errors,extensions,printer,value,version}.rb"
+ "#{root}/dry/struct/{class_interface,errors,printer,value,version}.rb"
)
end
end
end
+ register_extension(:pretty_print) do
+ require "dry/struct/extensions/pretty_print"
+ end
+
loader.setup
include ::Dry::Equalizer(:__attributes__, inspect: false, immutable: true)
@@ -220,6 +224,5 @@ module Dry
end
end
-require "dry/struct/extensions"
require "dry/struct/printer"
require "dry/struct/value"
diff --git lib/dry/struct/extensions.rb lib/dry/struct/extensions.rb
deleted file mode 100644
index 7584e67..0000000
--- lib/dry/struct/extensions.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-Dry::Struct.register_extension(:pretty_print) do
- require "dry/struct/extensions/pretty_print"
-end
diff --git lib/dry/struct/extensions/pretty_print.rb lib/dry/struct/extensions/pretty_print.rb
index 262a5a9..49b21df 100644
--- lib/dry/struct/extensions/pretty_print.rb
+++ lib/dry/struct/extensions/pretty_print.rb
@@ -4,19 +4,25 @@ require "pp"
module Dry
class Struct
- def pretty_print(pp)
- klass = self.class
- pp.group(1, "#<#{klass.name || klass.inspect}", ">") do
- pp.seplist(@attributes.keys, proc { pp.text "," }) do |column_name|
- column_value = @attributes[column_name]
- pp.breakable " "
- pp.group(1) do
- pp.text column_name.to_s
- pp.text "="
- pp.pp column_value
+ module Extensions
+ module PrettyPrint
+ def pretty_print(pp)
+ klass = self.class
+ pp.group(1, "#<#{klass.name || klass.inspect}", ">") do
+ pp.seplist(@attributes.keys, proc { pp.text "," }) do |column_name|
+ column_value = @attributes[column_name]
+ pp.breakable " "
+ pp.group(1) do
+ pp.text column_name.to_s
+ pp.text "="
+ pp.pp column_value
+ end
+ end
end
end
end
end
+
+ include(Extensions::PrettyPrint)
end
end 😬 @flash-gordon thoughts? |
Actually, here's a PR #184 Notice that it leads to dry-core but it's just because its deprecations module defines |
@solnic Thanks, I've added a commit to a sample up to use your branch, and everything works there. |
@timon this is now fixed in 1.5.1. Sorry for the trouble and thanks for the helpful reproduction repo 🙂 |
@timon oops I missed it, just clicker at the repo. Thanks for the repro, it always helps |
Describe the bug
We have noticed the following failure in dependabot PR that bumps version of
dry-struct
to 1.5.0:To Reproduce
A minimalistic rails app that exhibits this behavior is available at timon/dry-failures#1
Please note that
CI
should be present at env to enforce eager loading of rails app in atest
environmentdry-core
seems to work fineExpected behavior
Updating to
dry-struct
should not break eager loading of rails apps, neither in CI nor inproduction
modeMy environment
ubuntu-latest
in github runnerThe text was updated successfully, but these errors were encountered: