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

Require 'active_support' at first #931

Conversation

mgi166
Copy link

@mgi166 mgi166 commented Jul 15, 2016

Summary

Require active_support, at first.

Problem

Outside the rails framework, failed to load delayed_job in spite of supporting active_support > 5.0.0.
like this.

% irb
irb(main):001:0> require 'bundler/setup'
=> true
irb(main):002:0> require './lib/delayed_job'
NoMethodError: undefined method `instance' for ActiveSupport::Deprecation:Class
Did you mean?  instance_of?
        from /Users/argerich/dev/delayed_job/vendor/bundle/gems/activesupport-5.0.0/lib/active_support/deprecation/proxy_wrappers.rb:124:in `initialize'
        from /Users/argerich/dev/delayed_job/vendor/bundle/gems/activesupport-5.0.0/lib/active_support/deprecation/proxy_wrappers.rb:10:in `new'
        from /Users/argerich/dev/delayed_job/vendor/bundle/gems/activesupport-5.0.0/lib/active_support/deprecation/proxy_wrappers.rb:10:in `new'
        from /Users/argerich/dev/delayed_job/vendor/bundle/gems/activesupport-5.0.0/lib/active_support/core_ext/load_error.rb:30:in `<top (required)>'
        from /Users/argerich/dev/delayed_job/vendor/bundle/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:12:in `require'
        from /Users/argerich/dev/delayed_job/vendor/bundle/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:12:in `<top (required)>'
        from /Users/argerich/dev/delayed_job/lib/delayed/worker.rb:2:in `require'
        from /Users/argerich/dev/delayed_job/lib/delayed/worker.rb:2:in `<top (required)>'
        from /Users/argerich/dev/delayed_job/lib/delayed_job.rb:17:in `require'
        from /Users/argerich/dev/delayed_job/lib/delayed_job.rb:17:in `<top (required)>'
        from (irb):2:in `require'
        from (irb):2
        from /Users/argerich/.rbenv/versions/2.3.1/bin/irb:11:in `<main>'

I think that it is bad to failed to load top level delayed_job file.

The cause is that you failed to load only active_support/dependencies without require top level file active_support.
I think that you use stand alone active_support, must require the top level file like this require 'active_support' according to http:https://guides.rubyonrails.org/active_support_core_extensions.html#stand-alone-active-support

In particular, occur this problem when Rails application > 5.0.0 deploies by capistrano with bugsnag/capistrano.
Because capistrano normally doesn't load rails environments, so doesn't load top level file active_support.

$ cap vm deploy --trace
cap aborted!
NoMethodError: undefined method `instance' for ActiveSupport::Deprecation:Class
Did you mean?  instance_of?
/Users/argerich/work/sample-app/vendor/bundle/gems/activesupport-5.0.0/lib/active_support/deprecation/proxy_wrappers.rb:124:in `initialize'
/Users/argerich/work/sample-app/vendor/bundle/gems/activesupport-5.0.0/lib/active_support/deprecation/proxy_wrappers.rb:10:in `new'
/Users/argerich/work/sample-app/vendor/bundle/gems/activesupport-5.0.0/lib/active_support/deprecation/proxy_wrappers.rb:10:in `new'
/Users/argerich/work/sample-app/vendor/bundle/gems/activesupport-5.0.0/lib/active_support/core_ext/load_error.rb:30:in `<top (required)>'
/Users/argerich/work/sample-app/vendor/bundle/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:12:in `require'
/Users/argerich/work/sample-app/vendor/bundle/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:12:in `<top (required)>'
/Users/argerich/work/sample-app/vendor/bundle/gems/delayed_job-4.1.2/lib/delayed/worker.rb:2:in `require'
/Users/argerich/work/sample-app/vendor/bundle/gems/delayed_job-4.1.2/lib/delayed/worker.rb:2:in `<top (required)>'
/Users/argerich/work/sample-app/vendor/bundle/gems/delayed_job-4.1.2/lib/delayed_job.rb:17:in `require'
/Users/argerich/work/sample-app/vendor/bundle/gems/delayed_job-4.1.2/lib/delayed_job.rb:17:in `<top (required)>'
/Users/argerich/work/sample-app/vendor/bundle/gems/bugsnag-4.2.1/lib/bugsnag/delayed_job.rb:1:in `require'
/Users/argerich/work/sample-app/vendor/bundle/gems/bugsnag-4.2.1/lib/bugsnag/delayed_job.rb:1:in `<top (required)>'
/Users/argerich/work/sample-app/vendor/bundle/gems/bugsnag-4.2.1/lib/bugsnag.rb:134:in `require'
/Users/argerich/work/sample-app/vendor/bundle/gems/bugsnag-4.2.1/lib/bugsnag.rb:134:in `block in <top (required)>'
/Users/argerich/work/sample-app/vendor/bundle/gems/bugsnag-4.2.1/lib/bugsnag.rb:132:in `each'
/Users/argerich/work/sample-app/vendor/bundle/gems/bugsnag-4.2.1/lib/bugsnag.rb:132:in `<top (required)>'
/Users/argerich/work/sample-app/vendor/bundle/gems/bugsnag-4.2.1/lib/bugsnag/capistrano.rb:1:in `require'
/Users/argerich/work/sample-app/vendor/bundle/gems/bugsnag-4.2.1/lib/bugsnag/capistrano.rb:1:in `<top (required)>'
/Users/argerich/work/sample-app/Capfile:33:in `require'
/Users/argerich/work/sample-app/Capfile:33:in `<top (required)>'
/Users/argerich/work/sample-app/vendor/bundle/gems/rake-11.2.2/lib/rake/rake_module.rb:28:in `load'
/Users/argerich/work/sample-app/vendor/bundle/gems/rake-11.2.2/lib/rake/rake_module.rb:28:in `load_rakefile'
/Users/argerich/work/sample-app/vendor/bundle/gems/rake-11.2.2/lib/rake/application.rb:686:in `raw_load_rakefile'
/Users/argerich/work/sample-app/vendor/bundle/gems/rake-11.2.2/lib/rake/application.rb:96:in `block in load_rakefile'
/Users/argerich/work/sample-app/vendor/bundle/gems/rake-11.2.2/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/argerich/work/sample-app/vendor/bundle/gems/rake-11.2.2/lib/rake/application.rb:95:in `load_rakefile'
/Users/argerich/work/sample-app/vendor/bundle/gems/rake-11.2.2/lib/rake/application.rb:79:in `block in run'
/Users/argerich/work/sample-app/vendor/bundle/gems/rake-11.2.2/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/argerich/work/sample-app/vendor/bundle/gems/rake-11.2.2/lib/rake/application.rb:77:in `run'
/Users/argerich/work/sample-app/vendor/bundle/gems/capistrano-3.5.0/lib/capistrano/application.rb:14:in `run'
/Users/argerich/work/sample-app/vendor/bundle/gems/capistrano-3.5.0/bin/cap:3:in `<top (required)>'
/Users/argerich/work/sample-app/vendor/bundle/bin/cap:17:in `load'
/Users/argerich/work/sample-app/vendor/bundle/bin/cap:17:in `<main>'

Because `delayed/*` files have dependencies of `active_support/*`.
You must require top level file in outside the rails framework.
@coveralls
Copy link

coveralls commented Jul 15, 2016

Coverage Status

Coverage increased (+0.008%) to 91.135% when pulling 1760747 on mgi166:require-active-support-at-load-delayed-job into e3772d4 on collectiveidea:master.

@coveralls
Copy link

coveralls commented Jul 15, 2016

Coverage Status

Coverage increased (+0.008%) to 91.135% when pulling bbd84b0 on mgi166:require-active-support-at-load-delayed-job into e3772d4 on collectiveidea:master.

@albus522
Copy link
Member

This looks like a bug in ActiveSupport not DJ.

https://github.com/rails/rails/blob/master/activesupport/lib/active_support/deprecation/proxy_wrappers.rb
should include a require for deprecation but it doesn't

@mgi166 mgi166 force-pushed the require-active-support-at-load-delayed-job branch from bbd84b0 to 1760747 Compare July 16, 2016 07:36
@mgi166
Copy link
Author

mgi166 commented Jul 16, 2016

This looks like a bug in ActiveSupport not DJ.

I think so too until before.
But according to this, I think that the approach is wrong.

joshuap added a commit to honeybadger-io/honeybadger-ruby that referenced this pull request Aug 22, 2016
See collectiveidea/delayed_job#931

This is the error this fixes:

  ~/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/deprecation/proxy_wrappers.rb:124:in `initialize': undefined method `instance' for ActiveSupport::Deprecation:Class (NoMethodError)
  Did you mean?  instance_of?
    from ~/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/deprecation/proxy_wrappers.rb:10:in `new'
    from ~/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/deprecation/proxy_wrappers.rb:10:in `new'
    from ~/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/core_ext/load_error.rb:30:in `<top (required)>'
    from ~/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:12:in `require'
    from ~/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:12:in `<top (required)>'
    from ~/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:2:in `require'

After delayed_job fixes the bug we can unlock the dependency.
delayed_job tests must then be locked (on Travis) to Ruby >= 2.2.2 to
support ActiveSupport >= 5.0.
@chrishough
Copy link

We are having this same problem on our application, and according to rails core it appears they are not going to adjust active support. Correct me if I am wrong here, but I think this has to be fixed here in delayed job @albus522. I have to back @mgi166 here.

Should delayed job users with this issue just defer to using @mgi166 PR instead of master?

@albus522 albus522 merged commit 75476ec into collectiveidea:master Mar 31, 2017
@mgi166
Copy link
Author

mgi166 commented Apr 1, 2017

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

4 participants