Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equality check warning in Ruby 2.2.2 #157

Closed
adhulipa opened this issue Jun 19, 2015 · 6 comments
Closed

Equality check warning in Ruby 2.2.2 #157

adhulipa opened this issue Jun 19, 2015 · 6 comments
Assignees

Comments

@adhulipa
Copy link

aditya@ubuntu:~/Projects/sharedrive$ rails s
/home/aditya/.rvm/gems/ruby-2.2.2/gems/activesupport-3.2.13/lib/active_support/values/time_zone.rb:270: warning: circular argument reference - now
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
(eval):1: warning: toplevel constant MwaccountService referenced by Suds::ServiceProxy::MwaccountService
(eval):1: warning: toplevel constant ProductMasterService referenced by Suds::ServiceProxy::ProductMasterService
/home/aditya/.rvm/gems/ruby-2.2.2/gems/rufus-scheduler-3.1.2/lib/rufus/scheduler.rb:612: warning: Comparable#== will no more rescue exceptions of #<=> in the next release.
/home/aditya/.rvm/gems/ruby-2.2.2/gems/rufus-scheduler-3.1.2/lib/rufus/scheduler.rb:612: warning: Return nil in #<=> if the comparison is inappropriate or avoid such comparison.
[2015-06-19 11:02:55] INFO  WEBrick 1.3.1
[2015-06-19 11:02:55] INFO  ruby 2.2.2 (2015-04-13) [x86_64-linux]
[2015-06-19 11:02:55] INFO  WEBrick::HTTPServer#start: pid=18653 port=3000


/home/aditya/.rvm/gems/ruby-2.2.2/gems/rufus-scheduler-3.1.2/lib/rufus/scheduler/jobs.rb:293: warning: Comparable#== will no more rescue exceptions of #<=> in the next release.
/home/aditya/.rvm/gems/ruby-2.2.2/gems/rufus-scheduler-3.1.2/lib/rufus/scheduler/jobs.rb:293: warning: Return nil in #<=> if the comparison is inappropriate or avoid such comparison.
..........
........
/home/aditya/.rvm/gems/ruby-2.2.2/gems/rufus-scheduler-3.1.2/lib/rufus/scheduler/jobs.rb:293: warning: Comparable#== will no more rescue exceptions of #<=> in the next release.
/home/aditya/.rvm/gems/ruby-2.2.2/gems/rufus-scheduler-3.1.2/lib/rufus/scheduler/jobs.rb:293: warning: Return nil in #<=> if the comparison is inappropriate or avoid such comparison.


.... (more output of scheduled tasks)....



^C[2015-06-19 11:03:11] INFO  going to shutdown ...
[2015-06-19 11:03:11] INFO  WEBrick::HTTPServer#start done.
Exiting
@adhulipa
Copy link
Author

There seems to be a similar issue here - https://github.com/RubyMoney/money/pull/470/files

@jmettraux jmettraux self-assigned this Jun 19, 2015
@jmettraux
Copy link
Owner

Hello,

thanks for reporting these warnings.

I have tried with

ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
Linux guerlain 3.2.0-4-amd64 #1 SMP Debian 3.2.68-1+deb7u1 x86_64 GNU/Linux

and

require 'rufus-scheduler'

s = Rufus::Scheduler.new

s.every '2s' do
  p Time.now.to_f
end

s.join

But I get no warning (yes, the lines you pinpointed above are interpreted).

When I turn on -w I get

/home/jmettraux/w/rufus-scheduler/lib/rufus/scheduler.rb:388: warning: assigned but unused variable - job_id
/home/jmettraux/w/rufus-scheduler/lib/rufus/scheduler.rb:444: warning: assigned but unused variable - j
/home/jmettraux/w/rufus-scheduler/lib/rufus/scheduler/jobs.rb:433: warning: method redefined; discarding old last_at=
/home/jmettraux/w/rufus-scheduler/lib/rufus/scheduler/cronline.rb:446: warning: method redefined; discarding old monthdays

Nothing related to Comparable or <=>.

If I look at the lines your warnings pinpointed above, they compare an instance of Time (or NilClass) with nil. Could it be that your project tweaks the Time class (or the NilClass)?

Are you able to reproduce those warnings with only my test script above and your Ruby 2.2.2 (what patch level and what OS btw)?

@adhulipa
Copy link
Author

Hi. Thanks for writing back.

I ran all of the above on Ubuntu 14.04 inside VMware workstation

The script I was trying this on was a simple rails app -- It was akin to a "hello world" program. Just a single controller that displays some text. I didn't include any Time modules etc. . .I first ran this on my terminal using ruby 1.9.3 and got the rufus-scheduler working as expected.... Then I switched over to ruby 2.2.2 on the same machine (using rvm -- by default i use ruby 2; i don't know why exactly my terminal in the first case above was using ruby 1.9.3 -- maybe I set it up for playing around and forgot about it..) Anyways, I google around a bit and found the above mentioned references. The RubyMoney module also has the exact same warning on ruby2. And since this warning was because of code within rufus itself, I thought it would be worth reporting here.

I can run your test case on Monday morning since all this is on my work computer and I can't access it right now.

I'm a student and I'm new to ruby & rails. If possible I'd like to help contribute to rufus. I appreciate any suggestions you have for me. Thanks!

EDIT: I will submit my code snippet on Monday as well. I forgot to include it with the issue above

@jmettraux
Copy link
Owner

OK, waiting for Monday.

Have a nice week-end!

@adhulipa
Copy link
Author

Hi,

I ran your test script. And it worked correctly.

image

However, it doesn't seem to work in the context of rails. Is this an issue with the rails version or something?

Thanks!

@jmettraux
Copy link
Owner

Hello,

OK, so closing the issue rufus-scheduler wise.

Next step for you is to try a simple Rails application (no extra gem, no rufus-scheduler) on that same Ruby 2.2.2. The issue can probably be reproduced with a simple

Time.now == nil

You'll probably hit one of those: https://github.com/rails/rails/search?q=Comparable&type=Issues&utf8=%E2%9C%93

Good luck, best regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants