dragonfly icon indicating copy to clipboard operation
dragonfly copied to clipboard

warning: loading in progress, circular require considered harmful

Open brcarp opened this issue 5 years ago • 1 comments

gem 'dragonfly-s3_data_store'

$ grep dragonfly Gemfile
gem 'dragonfly-s3_data_store'
$ grep dragonfly Gemfile.lock
    dragonfly (1.1.4)
    dragonfly-s3_data_store (1.3.0)
      dragonfly (~> 1.0)
  dragonfly-s3_data_store
$ ruby -w -e 'require "dragonfly"'
/path/to/rubygems/core_ext/kernel_require.rb: warning: loading in progress, circular require considered harmful - /path/to/gems/dragonfly-1.1.4/lib/dragonfly.rb

Is this tied to dragonfly, this particular version, or some other dependency chain in the configuration? It would be helpful if others could comment as to its reproducibility.

brcarp avatar Jan 21 '20 21:01 brcarp

Reproducible when having only dragonfly (ruby -w thisscript.rb).

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'dragonfly', '1.3.0', require: false
end

require 'dragonfly'

This was introduced in dragonfly 1.0, reproducible in versions >= 1.0, not reproducible in <= 0.9.15.

For example, dragonfly.rb requires dragonfly/middleware: https://github.com/markevans/dragonfly/blob/82254ecc81250ac03b5cff070c074990e5774b75/lib/dragonfly.rb#L12

And dragonfly/middleware.rb requires dragonfly again: https://github.com/markevans/dragonfly/blob/82254ecc81250ac03b5cff070c074990e5774b75/lib/dragonfly/middleware.rb#L1

This happens for:

  • dragonfly -> dragonfly/app -> dragonfly/shell
  • dragonfly -> dragonfly/model -> dragonfly/model/class_methods
  • dragonfly -> dragonfly/middleware

kolen avatar Feb 27 '21 19:02 kolen