floraison / fugit

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

Version 1.10.0 not compatible with ruby 2.2.6 #93

Closed aunghtain closed 4 months ago

aunghtain commented 4 months ago

Issue description

The latest version (1.10.0) with ruby 2.2.6 gives the following error.

/usr/share/rvm/gems/ruby-2.2.6/gems/fugit-1.10.0/lib/fugit.rb:16:in require': /usr/share/rvm/gems/ruby-2.2.6/gems/fugit-1.10.0/lib/fugit/cron.rb:323: syntax error, unexpected tIDENTIFIER, expecting '<' or ';' or '\n' (SyntaxError) class CronIterator include ::Enumerable ^ from /usr/share/rvm/gems/ruby-2.2.6/gems/fugit-1.10.0/lib/fugit.rb:16:in<top (required)>'

How to reproduce

I'm using it in rails with rufus-scheduler 3.6.0. After bundle install, I try to start rails console

rails c

I got the above error.

Error and error backtrace (if any)

/usr/share/rvm/gems/ruby-2.2.6/gems/fugit-1.10.0/lib/fugit.rb:16:in `require': /usr/share/rvm/gems/ruby-2.2.6/gems/fugit-1.10.0/lib/fugit/cron.rb:323: syntax error, unexpected tIDENTIFIER, expecting '<' or ';' or '\n' (SyntaxError)
    class CronIterator include ::Enumerable
                              ^
        from /usr/share/rvm/gems/ruby-2.2.6/gems/fugit-1.10.0/lib/fugit.rb:16:in `<top (required)>'

Expected behaviour

Rails starts console without any issues.

Context

Please replace the content of this section with the output of the following commands:

Linux XXXX 5.15.0-1051 #59~20.04.1-Ubuntu SMP Tue Oct 17 16:45:08 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
ruby 2.2.6p396 (2016-11-15 revision 56800) [x86_64-linux]
[:env_tz, nil]
(secs:1709141883.3072312,utc~:"2024-02-28 17:38:03.30723118782043457",ltz~:"PST")
(etz:nil,tnz:"PST",tziv:"0.3.62",tzidv:nil,rv:"2.2.6",rp:"x86_64-linux",win:false,rorv:nil,astz:nil,eov:"1.2.7",eotnz:#<TZInfo::DataTimezone: America/Los_Angeles>,eotnfz:"-0800",eotlzn:"America/Los_Angeles",eotnfZ:"PST",debian:"America/Los_Angeles",centos:nil,osx:"America/Los_Angeles")
/usr/share/rvm/rubies/ruby-2.2.6/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': /usr/share/rvm/gems/ruby-2.2.6/gems/fugit-1.10.0/lib/fugit/cron.rb:323: syntax error, unexpected tIDENTIFIER, expecting '<' or ';' or '\n' (SyntaxError)
    class CronIterator include ::Enumerable
                              ^
        from /usr/share/rvm/rubies/ruby-2.2.6/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /usr/share/rvm/gems/ruby-2.2.6/gems/fugit-1.10.0/lib/fugit.rb:16:in `<top (required)>'
        from /usr/share/rvm/rubies/ruby-2.2.6/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:130:in `require'
        from /usr/share/rvm/rubies/ruby-2.2.6/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
        from /usr/share/rvm/rubies/ruby-2.2.6/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:35:in `require'
[:now, 2024-02-28 09:38:03 -0800, :zone, "PST"]

Additional context

If I downgrade to 1.9.0, it works fine.

jmettraux commented 4 months ago

https://github.com/floraison/fugit/actions/runs/8087806417/job/22100554384#step:3:30 argh

jmettraux commented 4 months ago

https://github.com/floraison/fugit/actions/runs/8087932820/job/22100915876 no 2.2.6, but no luck with 2.2.10 :-(

jmettraux commented 4 months ago

@aunghtain Hello and thanks for the detailed report!

I have trouble finding a Ruby 2.2.x or 2.2.6 to test directly, neither on GitHub Actions, neither for my development station (some kind of compile error). Could you please test this include Enumerable version on your Ruby 2.2.6 and tell me if that fixes it?

When we are successful, I will release a fugit 1.10.1.

aunghtain commented 4 months ago

It still gives me the same error.

/usr/share/rvm/gems/ruby-2.2.6/bundler/gems/fugit-4c12b6120f20/lib/fugit.rb:16:in `require': /usr/share/rvm/gems/ruby-2.2.6/bundler/gems/fugit-4c12b6120f20/lib/fugit/cron.rb:323: syntax error, unexpected tIDENTIFIER, expecting '<' or ';' or '\n' (SyntaxError)
    class CronIterator include Enumerable
                              ^

But if I move the include to a new line, it works fine.

    class CronIterator
      include Enumerable

Also, this works.

    class CronIterator
      include ::Enumerable
jmettraux commented 4 months ago

Well done! I will change and release 1.10.1. Thanks a lot!

jmettraux commented 4 months ago

1.10.1 released https://rubygems.org/gems/fugit/versions/1.10.1

Please tell me if it works for you.

Thanks!

aunghtain commented 4 months ago

1.10.1 works! Thank you so much @jmettraux

jmettraux commented 4 months ago

@aunghtain You're welcome! Well done!