Rykian / clockwork

A scheduler process to replace cron.
MIT License
544 stars 66 forks source link

Undefined method `deprecator' error when loading Rails 7.1 environment in clock.rb #86

Closed tboyko closed 1 year ago

tboyko commented 1 year ago

An error is raised when trying to run the clockwork binary (from gem version 2.0.0) with the Rails 7.1.1 environment.

My understanding is that this is due to a change between Rails 7.0.8 and 7.1.0, as detailed here.

lib/clock.rb

require 'config/boot'
require 'config/environment'

require 'clockwork'

module Clockwork
    every(10.minutes, 'Nacten.run_loop') { Macten.run_loop.delay }
end

Running clockwork lib/clock.rb results in:

/usr/local/bundle/gems/activesupport-7.1.1/lib/active_support/core_ext/array/conversions.rb:108:in `<class:Array>': undefined method `deprecator' for ActiveSupport:Module (NoMethodError)

  deprecate to_default_s: :to_s, deprecator: ActiveSupport.deprecator
                                                          ^^^^^^^^^^^
Did you mean?  deprecate_constant
    from /usr/local/bundle/gems/activesupport-7.1.1/lib/active_support/core_ext/array/conversions.rb:8:in `<top (required)>'
    from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from /usr/local/bundle/gems/activesupport-7.1.1/lib/active_support/duration.rb:3:in `<top (required)>'
    from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from /usr/local/bundle/gems/activesupport-7.1.1/lib/active_support/core_ext/time/calculations.rb:3:in `<top (required)>'
    from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from /usr/local/bundle/gems/activesupport-7.1.1/lib/active_support/core_ext/time.rb:4:in `<top (required)>'
    from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from /usr/local/bundle/gems/activesupport-7.1.1/lib/active_support/time.rb:12:in `<top (required)>'
    from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from /usr/local/bundle/gems/clockwork-2.0.4/lib/clockwork.rb:2:in `<top (required)>'
    from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from /usr/local/bundle/gems/clockwork-2.0.4/bin/clockwork:5:in `<top (required)>'
    from /usr/local/bundle/bin/clockwork:25:in `load'
    from /usr/local/bundle/bin/clockwork:25:in `<main>'
tboyko commented 1 year ago

Issue does not exist with latest version of library. Apologies for the false alarm.