Skip to content

Conversation

@brunolarouche
Copy link
Contributor

Since version 1.4.3 (ruby/irb@v1.4.3...master), irb ruby gem (https://github.com/ruby/irb) is calling directly "respond_to?" method on all included code inside a project. That change makes all code included in a project having that method crashing if implementing it in a way not always returning a true or false, like described in the ruby doc: https://www.rubydoc.info/stdlib/core/Object:respond_to%3F

So, I just wanted to propose that simple change which would prevent that (and maybe) other situations, now always returning a value. I've not used the Ruby '&' in order to be retro-compatible with pre-2.3 ruby versions, in case.

@crevete
Copy link

crevete commented Dec 2, 2022

ping @benlangfeld

@neualiluj
Copy link

I am also affected by the issue @benlangfeld

@crevete
Copy link

crevete commented Dec 15, 2022

Hello @trungtran1512, do you have any idea about when this PR will be merged and when a new release will be cut? thanks

@trungtran1512
Copy link

Hello @crevete, I don't know about this but I tried under local it works fine.

@crevete
Copy link

crevete commented Feb 21, 2023

Hello @trungtran1512 who is the maintainer of this project? I guess @benlangfeld? Why he does never respond? Is this project dead? The code base is out-to-date...

@benlangfeld
Copy link
Collaborator

@crevete #618 (comment)

@tompng
Copy link

tompng commented Apr 5, 2023

I think it shuold be fixed as

- def self.respond_to?(name, include_private = false)
+ def respond_to?(name, include_private = false)


def self.respond_to?(name, include_private = false)
@set_variables.has_key?(name) || super
if @set_variables

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always be nil so this is effectively just super

@brunolarouche
Copy link
Contributor Author

I think it shuold be fixed as

- def self.respond_to?(name, include_private = false)
+ def respond_to?(name, include_private = false)

Makes sense, I've updated the PR, thanks!

groyoh added a commit to happydemics/whenever that referenced this pull request Oct 17, 2023
@taketo1113
Copy link
Collaborator

@brunolarouche I would like to merge this Pull Request. Could you rebase it when you have a moment?


Steps to reproduce

I confirmed that the following issue is resolved:

irb(main):001:0> require 'whenever'
=> true
irb(main):002:0> test
(irb):2:in `test': wrong number of arguments (given 0, expected 2..3) (ArgumentError)
	from (irb):2:in `<main>'
	from /Users/taketo/path/tmp/ruby/3.2.0/gems/irb-1.4.3/exe/irb:11:in `<top (required)>'
...

# input `test` & `[Tab]`
irb(main):003:0> testbundler: failed to load command: irb (/Users/taketo/path/tmp/ruby/3.2.0/bin/irb)
/Users/taketo/path/tmp/ruby/3.2.0/gems/whenever-1.0.0/lib/whenever/job_list.rb:41:in `respond_to?': undefined method `has_key?' for nil:NilClass (NoMethodError)

      @set_variables.has_key?(name) || super
                    ^^^^^^^^^
	from /Users/taketo/path/tmp/ruby/3.2.0/gems/irb-1.4.3/lib/irb/completion.rb:364:in `block in retrieve_completion_data'
...
  • ruby: 3.2.9
  • whenever: 1.0.0
  • irb: 1.4.3

@taketo1113 taketo1113 linked an issue Nov 18, 2025 that may be closed by this pull request
@taketo1113 taketo1113 changed the title job_list self.respond_to? responds to empty @set_variables job_list .respond_to? updated to an instance method Dec 4, 2025
@taketo1113 taketo1113 merged commit ff4e7e5 into javan:main Dec 4, 2025
58 checks passed
@taketo1113
Copy link
Collaborator

I have rebased and merged it.
This is scheduled to be fixed in the next release.

@brunolarouche
Copy link
Contributor Author

@brunolarouche I would like to merge this Pull Request. Could you rebase it when you have a moment?

Steps to reproduce

I confirmed that the following issue is resolved:

* Fix [Ruby 3.2 autocompletion in console #831](https://github.com/javan/whenever/issues/831)
irb(main):001:0> require 'whenever'
=> true
irb(main):002:0> test
(irb):2:in `test': wrong number of arguments (given 0, expected 2..3) (ArgumentError)
	from (irb):2:in `<main>'
	from /Users/taketo/path/tmp/ruby/3.2.0/gems/irb-1.4.3/exe/irb:11:in `<top (required)>'
...

# input `test` & `[Tab]`
irb(main):003:0> testbundler: failed to load command: irb (/Users/taketo/path/tmp/ruby/3.2.0/bin/irb)
/Users/taketo/path/tmp/ruby/3.2.0/gems/whenever-1.0.0/lib/whenever/job_list.rb:41:in `respond_to?': undefined method `has_key?' for nil:NilClass (NoMethodError)

      @set_variables.has_key?(name) || super
                    ^^^^^^^^^
	from /Users/taketo/path/tmp/ruby/3.2.0/gems/irb-1.4.3/lib/irb/completion.rb:364:in `block in retrieve_completion_data'
...
* ruby: 3.2.9

* whenever: 1.0.0

* irb: 1.4.3

Sorry, I saw the message too late. Thanks for the rebase!

@taketo1113
Copy link
Collaborator

The version 1.1.1 has been released.
https://github.com/javan/whenever/releases/tag/v1.1.1

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.

Ruby 3.2 autocompletion in console

8 participants