Sidekiq::Cron::Job throw me uninitialized constant Rufus::Scheduler::CronLine error

1.8k views Asked by At

I am using Ruby on Rails 5.2.0 to develop a system and I need to run a job every 2 minute. I'm using sidekiq for background processing and sidekiq-cron for scheduling jobs.

I execute the following line in rails console:

job=Sidekiq::Cron::Job.new( name: 'TestWorker_Job', cron: '*/2 * * * *', klass: 'PriceWorker')

And this is the answer

=> #<Sidekiq::Cron::Job:0x000055b6d54707e8
@active_job=false,
@active_job_queue_name_delimiter=nil,
@active_job_queue_name_prefix=nil,
@args=[],
@cron="*/2 * * * *",
@fetch_missing_args=true,
@klass="PriceWorker",
@last_enqueue_time=nil,
@message={"retry"=>false, "queue"=>"default", "class"=>"PriceWorker",   "args"=>[]},
@name="TestWorker_Job",
@queue="default",
@queue_name_with_prefix="default",
@status="enabled">

But it throws me an error:

job.errors
=> ["'cron' -> */2 * * * *: uninitialized constant Rufus::Scheduler::CronLine"]

There is no valid job. I don't know what i am doing wrong. Sidekiq-cron github page do the same thing.

1

There are 1 answers

3
Esben Damgaard On

sidekiq-cron is not targeting the correct version of rufus-scheduler. To make it work again, add this to your Gemfile:

gem 'rufus-scheduler', '~> 3.4.0'

Then run $ bundle install rufus-scheduler.