floraison / fugit

time tools (cron, parsing, durations, ...) for Ruby, rufus-scheduler, and flor
MIT License
355 stars 29 forks source link

undefined method `inject' for nil:NilClass #39

Closed rafarosa92 closed 4 years ago

rafarosa92 commented 4 years ago

Issue description

undefined method `inject' for nil:NilClass

How to reproduce

c = Fugit::Cron.parse('0 0 * *  sun')
Traceback (most recent call last):
        2: from (irb):10
        1: from (irb):11:in `rescue in irb_binding'
NoMethodError (undefined method `inject' for nil:NilClass)
jmettraux commented 4 years ago

Good day @rafarosa92

The code

require 'fugit'

c = Fugit::Cron.parse('0 0 * *  sun')

p c
p c.next_time.to_s

outputs

#<Fugit::Cron:0x0000044006aaa4c0 @original="0 0 * *  sun", @cron_s=nil, @seconds=[0], @minutes=[0], @hours=[0], @monthdays=nil, @months=nil, @weekdays=[[0]],
@zone=nil, @timezone=nil>
"2020-06-07 00:00:00 +0900"

The context is

$ uname -a
OpenBSD terebi 6.7 GENERIC.MP#1 amd64

$ ruby --version
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-openbsd6.6]

$ bundle list
Gems included by the bundle:
  * bundler (1.17.2)
  * chronic (0.10.2)
  * concurrent-ruby (1.1.6)
  * diff-lcs (1.3)
  * et-orbi (1.2.4)
  * fugit (1.3.6)
  * raabro (1.3.1)
  * rspec (3.9.0)
  * rspec-core (3.9.1)
  * rspec-expectations (3.9.1)
  * rspec-mocks (3.9.1)
  * rspec-support (3.9.2)
  * tzinfo (2.0.2)

So it works for me.

If you want me not to close this issue, you have to provide me a way to reproduce the problem.

Could you please indicate what OS you are using, what Ruby version you are using, and what fugit version you are using. Those things are requested by the issue template, but are missing from your issue report.

Thanks in advance.

rafarosa92 commented 4 years ago

$ uname - a

Linux pop-os 5.3.0-7648-generic #41~1586789791~19.10~9593806-Ubuntu SMP Mon Apr 13 17:50:40 UTC x86_64 x86_64 x86_64 GNU/Linux

$ruby --version ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]

$bundle list

Gems included by the bundle:

I´ll test on a docker with your settings...

jmettraux commented 4 years ago

Just tested on the same system but with fugit 1.3.5 as you do, and I can't see your error. It works as well.

jmettraux commented 4 years ago

@rafarosa92 Is the error backtrace in your initial report complete? It seems to obfuscate where the NullMethodError is actually occurring.

jmettraux commented 4 years ago

Just test on the same system with fugit 1.3.5 and ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-openbsd6.7] (close enough to yours). Still successful. Tried both with my program and with irb as you do.

I'm not using Docker, I'm using a plain Ruby "project" with its .ruby-version and its Gemfile, it's at https://gist.github.com/jmettraux/f657b8b17a05de95ba55d5d7345b9e36

I have to go to bed now. Let's hope you can pinpoint the problem. Please provide a backtrace pointing at fugit or a way for me to reproduce the issue (and then fix it).

Best regards.

rafarosa92 commented 4 years ago

Apparently the error is only within my project, because when I do the test by irb the methods work normally. I'll see what can be, we can close this topic.

Thanks for help!!

jmettraux commented 4 years ago

You're welcome. If you spot anything else related to fugit, please open a new issue.