-
-
Notifications
You must be signed in to change notification settings - Fork 69
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 Bootsnap to work with Ruby 3.0 #264
base: main
Are you sure you want to change the base?
Conversation
lib/dry/system/plugins/bootsnap.rb
Outdated
end | ||
|
||
# @api private | ||
def bootsnap_available? | ||
RUBY_ENGINE == "ruby" && RUBY_VERSION >= "2.3.0" && RUBY_VERSION < "3.1.0" | ||
RUBY_ENGINE == "ruby" && RUBY_VERSION >= "3.0.0" && RUBY_VERSION < "3.1.0" |
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.
shouldn't the upper bound be removed? 🤔
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.
Oh sure, removed the < 3.1.0
condition
@RicardoTrindade something's broken in CI? Mind to take a look? |
8fb9f0d
to
50c3f39
Compare
@@ -5,11 +5,9 @@ module System | |||
module Plugins | |||
module Bootsnap | |||
DEFAULT_OPTIONS = { | |||
load_path_cache: true, | |||
disable_trace: true, | |||
load_path_cache: false, |
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.
had to change this from true to false to get CI passing once again. with the option as true, some specs would fail with the error below that I haven't been able to figure out what is causing it
11) Container / Imports / Exports exports configured as a list of keys importing container is lazy loading does not finalize either container
Failure/Error: raise ComponentNotLoadableError.new(component, e)
Dry::System::ComponentNotLoadableError:
Component 'exportable_component_a' is not loadable.
Looking for Test::ExportableComponentA.
Did you mean? ExternalComponents
raise ComponentNotLoadableError.new(component, e)
^^^^^
# ./lib/dry/system/loader.rb:71:in `rescue in constant'
# ./lib/dry/system/loader.rb:64:in `constant'
# ./lib/dry/system/loader.rb:49:in `call'
# ./lib/dry/system/component.rb:64:in `instance'
# ./lib/dry/system/container.rb:639:in `block in load_local_component'
# ./lib/dry/system/container.rb:493:in `resolve'
# ./lib/dry/system/container.rb:516:in `key?'
# ./lib/dry/system/importer.rb:109:in `block in build_merge_container'
# ./lib/dry/system/importer.rb:108:in `each'
# ./lib/dry/system/importer.rb:108:in `each_with_object'
# ./lib/dry/system/importer.rb:108:in `build_merge_container'
# ./lib/dry/system/importer.rb:86:in `import_keys'
# ./lib/dry/system/importer.rb:69:in `import'
# ./lib/dry/system/container.rb:648:in `load_imported_component'
# ./lib/dry/system/container.rb:626:in `load_component'
# ./lib/dry/system/container.rb:491:in `resolve'
# ./spec/integration/container/importing/exports_spec.rb:76:in `block (4 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# NameError:
# uninitialized constant Test::ExportableComponentA
#
# Object.const_get(input, false)
# ^^^^^^^^^^
# Did you mean? ExternalComponents
# ./lib/dry/system/loader.rb:67:in `constant'
50c3f39
to
a4d242c
Compare
Due to the changes in keyword arguments for Ruby 3.0 I believe the bootsnap integration stopped working.
This PR updates the
Bootsnap.setup
method call to use**
operator and get around the initialization issue.Since dry-system requires ruby 3.0 or higher I've updated the condition to check if bootsnap was available.
Also uncommented a test for bootsnap. I've added an empty file to get the test working but I'm open to other suggestions
Stacktrace from an example repo I created to show the issue
https://github.com/RicardoTrindade/Bootsnap-example