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
Fix bug for nested require_dependencies #2193
Fix bug for nested require_dependencies #2193
Conversation
5a17cef
to
221aee5
Compare
41bb30f
to
b5186fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code change looks good, but I'm not familiar with the reloader component.
I'd like @ujifgc to review this for checking the validity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me.
Incomplete rollback at load `Padrino.root("fixtures/dependencies/nested/l.rb")` first time. by padrino#2193 The real problem is not to require the rollbacked files again. This happens because rollback does not delete file path in `Reloader.MTIME`.
Incomplete rollback at load `Padrino.root("fixtures/dependencies/nested/l.rb")` first time. by #2193 The real problem is not to require the rollbacked files again. This happens because rollback does not delete file path in `Reloader.MTIME`.
added tests(case) #2199 |
Looks good to me! |
There are problems with nested
require_dependencies
.Minimal example that reproduces this bug is: padrino-nested-require.tar.gz
This is how I got this bug:
Here is how this bug occurs:
toplevel.rb
callsrequire_dependencies
to loadlib/a_lib.rb
,lib/dependent_lib.rb
,an_app/app.rb
lib/a_lib.rb
fails because it depends onlib/dependent_lib.rb
lib/dependent_lib.rb
are loaded with no error because it does not depend on any other files.require_dependencies
tries to loadan_app/app.rb
, which may call nestedrequire_dependencies
.require_dependencies
loadsan_app/models/model_with_no_dep_on_lib.rb
with no error.require_dependencies
tries to loadan_app/models/model_that_depends_on_lib.rb
, but it fails becausemodel_that_depends_on_lib.rb
depends onlib/a_lib.rb
.require_dependencies
gives up to load files, raisingNameError - uninitialized constant ALib
require_dependencies
catches this exception and it assumes that entire process of loadingan_app/app.rb
fails, althoughmodel_with_no_dep_on_lib.rb
was loaded and commited successfully.require_dependencies
rollbacks every constants that is created before preparingan_app/app.rb
an_app/models/model_with_no_dep_on_lib.rb
are removed, even though they are commited and not to be loaded in next nestedrequire_dependencies
.Modify
Gemfile
in the example above as follows:Then execute
bundle exec ruby toplevel.rb
again. No error may happen.