Search code examples
ruby-on-railscapistranocapistrano3wheneverwhenever-capistrano

Deploying with capistrano 3 and whenever gem


I'm trying to deploy my app with whenever gem using capistrano 3.

I added: require "whenever/capistrano" to Capfile, and:

set :whenever_identifier, ->{ "#{fetch(:application)}_#{fetch(:stage)}" } to config/deploy.rb.

When I deploy it I get an error:

01 bundler: failed to load command: whenever (/home/deploy/www/laptophits/shared/bundle/ruby/2.2.0/bin/whenever)

NameError: undefined local variable or method `extract' for #<Whenever::JobList:0x00000002edf6c8>
      config/schedule.rb:9:in `block in initialize'

When I ssh to production machine and try to run whenever manually with: /home/deploy/www/laptophits/shared/bundle/ruby/2.2.0/bin/whenever

I get error:

/home/deploy/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems.rb:271:in `find_spec_for_exe': can't find gem whenever (>= 0.a) (Gem::GemNotFoundException)
        from /home/deploy/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems.rb:299:in `activate_bin_path'

Any idea how to fix it?


Solution

  • The key error is in

    NameError: undefined local variable or method `extract' for #<Whenever::JobList:0x00000002edf6c8>
      config/schedule.rb:9:in `block in initialize'
    

    There's likely a code bug on line 9 of config/schedule.rb. Probably using the method extract which doesn't exist on the object or in the context in which you are using it.