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

Get many warning "loading in progress, circular require considered harmful" when run test. #27

Open
zw963 opened this issue Aug 12, 2021 · 1 comment

Comments

@zw963
Copy link

zw963 commented Aug 12, 2021

Following is output messages when i run rake to run my test, but the test is passing.

home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/cliver-0.3.2/lib/core_ext/file.rb:15: warning: method redefined; discarding old absolute_path?
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34: warning: /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34: warning: loading in progress, circular require considered harmful - /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/opal-sprockets-1.0.1/lib/opal/sprockets.rb
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:6:in  `<main>'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:6:in  `select'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:21:in  `block in <main>'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:21:in  `require'
        from /home/zw963/Stocks/marketbet_crawler/test/services/latest_institutions_test.rb:1:in  `<top (required)>'
        from /home/zw963/Stocks/marketbet_crawler/test/services/latest_institutions_test.rb:1:in  `require'
        from /home/zw963/Stocks/marketbet_crawler/test/test_helper.rb:13:in  `<top (required)>'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/builder.rb:66:in  `parse_file'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/builder.rb:105:in  `load_file'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/builder.rb:116:in  `new_from_string'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/builder.rb:116:in  `eval'
        from config.ru:1:in  `block in <main>'
        from config.ru:1:in  `require_relative'
        from /home/zw963/Stocks/marketbet_crawler/config/environment.rb:3:in  `<top (required)>'
        from /home/zw963/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/bundler.rb:174:in  `require'
        from /home/zw963/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/bundler/runtime.rb:50:in  `require'
        from /home/zw963/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/bundler/runtime.rb:50:in  `each'
        from /home/zw963/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/bundler/runtime.rb:61:in  `block in require'
        from /home/zw963/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/bundler/runtime.rb:61:in  `each'
        from /home/zw963/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/bundler/runtime.rb:66:in  `block (2 levels) in require'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in  `require'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in  `require'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/opal-sprockets-1.0.1/lib/opal-sprockets.rb:1:in  `<top (required)>'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in  `require'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in  `require'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/opal-sprockets-1.0.1/lib/opal/sprockets.rb:4:in  `<top (required)>'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/opal-sprockets-1.0.1/lib/opal/sprockets.rb:5:in  `<module:Opal>'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/opal-sprockets-1.0.1/lib/opal/sprockets.rb:11:in  `<module:Sprockets>'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in  `require'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in  `require'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/opal-sprockets-1.0.1/lib/opal/sprockets/environment.rb:2:in  `<top (required)>'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in  `require'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in  `require'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/opal-sprockets-1.0.1/lib/opal/sprockets/processor.rb:6:in  `<top (required)>'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in  `require'
        from /home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in  `require'

/home/zw963/Stocks/marketbet_crawler/config/application.rb:9: warning: method redefined; discarding old call
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:37: warning: previous definition of call was here

You can check my source code here

https://github.com/zw963/marketbet_crawler/tree/test_opal_sprockets

for run test, you must set following ENVS:

export TEST_DATABASE_URL="sqlite://db/files/marketbet_crawler_test.db"
export APP_SESSION_SECRET="909f017cc94c96f8a1aff843d95920485376f4c997143cc3c39ca945c883ec88e310a2177a69b8b714d22af1b5fd7864833568b6bf93fc3bc811bcf6e112"

Thank you.

@fxn
Copy link

fxn commented Nov 1, 2021

This was reported in the Zeitwerk issue tracker too, so I looked into it.

You see "zeitwerk" in the logs because all require calls pass through this thin wrapper if the library is loaded.

It is a regular circular require warning (this project does not use Zeitwerk). I see for example that lib/opal/sprockets.rb loads lib/opal/sprockets/processor.rb (here), and while that is happening, lib/opal/sprockets/processor.rb tries to load lib/opal/sprockets.rb (here).

One way to address that would be to forbid client code from loading the processor directly, you have to load opal/sprockets no matter what (that way, the processor can assume the namespace is defined). If that is not possible... well, you need to figure that out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants