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

Use Timeout.timeout instead of Object#timeout #262

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mishina2228
Copy link

@mishina2228 mishina2228 commented Jan 8, 2022

Fix #263.

This change suppresses the following warning on Ruby 2.7:

warning: Object#timeout is deprecated, use Timeout.timeout instead.

This change suppresses the following warning:

```
warning: Object#timeout is deprecated, use Timeout.timeout instead.
```
@mishina2228
Copy link
Author

mishina2228 commented Jan 9, 2022

Object#timeout is removed from Ruby 3.0 3.1, so god cannot be used with Ruby 3.0+ 3.1+.

$ irb
irb(main):001:0> RUBY_VERSION
=> "2.7.0"
irb(main):002:0> timeout(1) {}
(irb):2: warning: Object#timeout is deprecated, use Timeout.timeout instead.
=> nil
$ irb
irb(main):001:0> RUBY_VERSION
=> "3.1.2"
irb(main):002:0> timeout(1) {}
(irb):2:in `<main>': undefined method `timeout' for main:Object (NoMethodError)
        from /home/owner/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
        from /home/owner/.rbenv/versions/3.1.2/bin/irb:25:in `load'

Object#timeout is still available in ruby 3.0.2,
However, with timeout 0.2.0+, Object#timeout is removed.

$ gem list timeout

*** LOCAL GEMS ***

timeout (0.2.0, default: 0.1.1)
$ irb
irb(main):001:0> RUBY_VERSION
=> "3.0.2"
irb(main):002:0> timeout(1) {}
(irb):2:in `<main>': undefined method `timeout' for main:Object (NoMethodError)
        from /home/owner/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.3.5/exe/irb:11:in `<top (required)>'
        from /home/owner/.rbenv/versions/3.0.2/bin/irb:23:in `load'
        from /home/owner/.rbenv/versions/3.0.2/bin/irb:23:in `<main>'

@praveenkumarsinha
Copy link

o god... i have company here... i am facing that exact problem
image

@minimum2scp
Copy link

@mishina2228

Object#timeout is deprecated but still available in ruby 3.0.2
https://github.com/ruby/ruby/blob/v3_0_2/lib/timeout.rb#L124-L134

% docker run --rm -ti ruby:3.0.2 
irb(main):001:0> RUBY_VERSION
=> "3.0.2"
irb(main):002:0> timeout(1) {}
(irb):2: warning: Object#timeout is deprecated, use Timeout.timeout instead.
=> nil
irb(main):003:0> 

But if timeout gem is updated to 0.2.0 or later
by gem install timeout or bundler, Object#timeout is removed.
ruby/timeout@14d4212

% docker run --rm -ti ruby:3.0.2 /bin/bash
root@f74035cc99bc:/# gem install timeout
Fetching timeout-0.3.0.gem
Successfully installed timeout-0.3.0
1 gem installed
root@f74035cc99bc:/# irb
irb(main):001:0> RUBY_VERSION
=> "3.0.2"
irb(main):002:0> timeout(1) {}
(irb):2:in `<main>': undefined method `timeout' for main:Object (NoMethodError)
	from /usr/local/lib/ruby/gems/3.0.0/gems/irb-1.3.5/exe/irb:11:in `<top (required)>'
	from /usr/local/bin/irb:23:in `load'
	from /usr/local/bin/irb:23:in `<main>'
irb(main):003:0> 

@mishina2228 Did you update timeout gem?

Anyway, to run god with ruby 3.1+, this PR is necessary.

@mishina2228
Copy link
Author

mishina2228 commented Jul 7, 2022

@minimum2scp Ah, you're right! I was using timeout v0.2.0.

$ ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]
$ gem list timeout

*** LOCAL GEMS ***

timeout (0.2.0, default: 0.1.1)

Thanks for pointing out and explaining in detail!
I will edit comments... Done.

@zz9pzza
Copy link

zz9pzza commented Mar 16, 2024

+1 on needing this

@SeemabMehmood
Copy link

+1 as its a need now

@cr0mbly
Copy link

cr0mbly commented Apr 10, 2024

+1 as it's needed now

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

Successfully merging this pull request may close these issues.

god cannot be used with Ruby 3.1+
7 participants