javan / whenever

Cron jobs in Ruby
MIT License
8.83k stars 726 forks source link

Fails generating crontab with currently empty crontab #611

Open JasonBarnabe opened 8 years ago

JasonBarnabe commented 8 years ago

With a blank crontab:

rails runner -e staging "Whenever::CommandLine.execute(:update=>true,:identifier=>'myapp',:set=>'environment=staging', :cut => 3)"
/home/web/.rvm/gems/ruby-2.2.3/gems/whenever-0.9.4/lib/whenever/command_line.rb:114:in `prepare': undefined method `join' for nil:NilClass (NoMethodError)
    from /home/web/.rvm/gems/ruby-2.2.3/gems/whenever-0.9.4/lib/whenever/command_line.rb:64:in `read_crontab'
    from /home/web/.rvm/gems/ruby-2.2.3/gems/whenever-0.9.4/lib/whenever/command_line.rb:92:in `updated_crontab'
    from /home/web/.rvm/gems/ruby-2.2.3/gems/whenever-0.9.4/lib/whenever/command_line.rb:35:in `run'
    from /home/web/.rvm/gems/ruby-2.2.3/gems/whenever-0.9.4/lib/whenever/command_line.rb:6:in `execute'
    from /home/web/.rvm/gems/ruby-2.2.3/gems/railties-4.0.13/lib/rails/commands/runner.rb:53:in `<top (required)>'
    from /home/web/.rvm/gems/ruby-2.2.3/gems/railties-4.0.13/lib/rails/commands/runner.rb:53:in `eval'
    from /home/web/.rvm/gems/ruby-2.2.3/gems/railties-4.0.13/lib/rails/commands/runner.rb:53:in `<top (required)>'
    from /home/web/.rvm/gems/ruby-2.2.3/gems/railties-4.0.13/lib/rails/commands.rb:84:in `require'
    from /home/web/.rvm/gems/ruby-2.2.3/gems/railties-4.0.13/lib/rails/commands.rb:84:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

Adding a few blank lines to the crontab makes it work.

benlangfeld commented 8 years ago

Do you have an easy way to reproduce this? On a fresh Ubuntu 14.04 server I cannot.

JasonBarnabe commented 8 years ago

Seems to be empty crontab + update: true + cut: n.

Tested on CentOS 7.2:

[web@lxap201 current]$ crontab -l
[web@lxap201 current]$ rails runner -e staging "Whenever::CommandLine.execute(cut: 3, update: true)"
/home/web/.rvm/gems/ruby-2.2.3/gems/whenever-0.9.4/lib/whenever/command_line.rb:114:in `prepare': undefined method `join' for nil:NilClass (NoMethodError)
    from /home/web/.rvm/gems/ruby-2.2.3/gems/whenever-0.9.4/lib/whenever/command_line.rb:64:in `read_crontab'
    from /home/web/.rvm/gems/ruby-2.2.3/gems/whenever-0.9.4/lib/whenever/command_line.rb:92:in `updated_crontab'
    from /home/web/.rvm/gems/ruby-2.2.3/gems/whenever-0.9.4/lib/whenever/command_line.rb:35:in `run'
    from /home/web/.rvm/gems/ruby-2.2.3/gems/whenever-0.9.4/lib/whenever/command_line.rb:6:in `execute'
    from /home/web/.rvm/gems/ruby-2.2.3/gems/railties-4.0.13/lib/rails/commands/runner.rb:53:in `<top (required)>'
    from /home/web/.rvm/gems/ruby-2.2.3/gems/railties-4.0.13/lib/rails/commands/runner.rb:53:in `eval'
    from /home/web/.rvm/gems/ruby-2.2.3/gems/railties-4.0.13/lib/rails/commands/runner.rb:53:in `<top (required)>'
    from /home/web/.rvm/gems/ruby-2.2.3/gems/railties-4.0.13/lib/rails/commands.rb:84:in `require'
    from /home/web/.rvm/gems/ruby-2.2.3/gems/railties-4.0.13/lib/rails/commands.rb:84:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'