Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ eval_gemfile "Gemfile.devtools"
gemspec

# Remove verson constraint once latter versions release their -java packages
gem "bootsnap", "= 1.4.9"
gem "bootsnap", "= 1.16.0"
gem "dotenv"
gem "dry-types"
gem "dry-events"
gem "dry-monitor"
gem "zeitwerk"

8 changes: 3 additions & 5 deletions lib/dry/system/plugins/bootsnap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
module Plugins
module Bootsnap
DEFAULT_OPTIONS = {
load_path_cache: true,
disable_trace: true,
load_path_cache: false,
Copy link
Author

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'


compile_cache_iseq: true,
compile_cache_yaml: true,

Check failure on line 10 in lib/dry/system/plugins/bootsnap.rb

View workflow job for this annotation

GitHub Actions / Style

Style/TrailingCommaInHashLiteral: Avoid comma after the last item of a hash.
autoload_paths_cache: false
}.freeze
flash-gordon marked this conversation as resolved.
Show resolved Hide resolved

# @api private
Expand All @@ -32,12 +30,12 @@
def setup_bootsnap
return unless bootsnap_available?

::Bootsnap.setup(config.bootsnap.merge(cache_dir: root.join("tmp/cache").to_s))
::Bootsnap.setup(**config.bootsnap.merge(cache_dir: root.join("tmp/cache").to_s))
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"
end
end
end
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion spec/integration/container/plugins/bootsnap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
end

describe ".require_from_root" do
xit "loads file" do
it "loads file" do
system.require_from_root("lib/test/models")

expect(Object.const_defined?("Test::Models")).to be(true)
Expand Down
Loading