whenever
whenever copied to clipboard
Ruby 3.2 autocompletion in console
I've update my rails 7 app with ruby 3.2. When I launch console and up arrow to search in my history some line crash with this error
whenever-1.0.0/lib/whenever/job_list.rb:41:in respond_to?': undefined method has_key?' for nil:NilClass (NoMethodError)
I've fix this with a dirty workaround initializer :
https://gist.github.com/hirogeek/1c6d511a77ec3b15dea8a0db0a11fb1c
what is the code that make it crash?
After re-try it's seems, at lest, crash when I write dot after non existente var. So launch console, type : test.to_s
I can't re-pro this
rails 7 ruby 3.2 install whenever with gem "whenever", require: false
do rails c
type non-existent/not declared variable
test. press tab for autocomplete then not throwing error in my case
$ rails c
Loading development environment (Rails 7.0.4)
irb(main):001:0> test.Array
(irb):1:in `test': wrong number of arguments (given 0, expected 2..3) (ArgumentError)
test.Array
^^^^
irb(main):002:0> abcd.BMPString
(irb):2:in `<main>': undefined local variable or method `abcd' for main:Object (NameError)
abcd.BMPString
^^^^
irb(main):003:0>
its the screenshot from vscode autocomplete

same problem, when I write in rails console MyModel.last.created_at
crashed when I was starting write created_at
adding this https://gist.github.com/hirogeek/1c6d511a77ec3b15dea8a0db0a11fb1c to initializers solved a problem, but console autocompletion started working slower
I ran into this issue as well. Love Whenever, but this definitely annoying 😞
@buncis Try with just gem "whenever" in your gemfile so that it's required to see the issue.
Same issue for me here, Rails 7.0.4.2 with ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-darwin22] and whenever 1.0.0.
The proposed workaround by @hirogeek works in the mean time, issue being that @set_variables is nil and trying to access has_key from it.
Steps to reproduce
- Have
gem "whenever"in gemfile (so that it's required). rails c- Try typing
Time.now.and it'll crash as soon as you put the dot afternow.
Stracktrace screenshots

use "require: false"
gem 'whenever', require: false

Please take a look at #830
I can confirm behaviour @DavidAmyot sees with an identical set-up, save for the fact that gemfile versions gem 'whenever', '~> 1.0'. This did not emerge under Ruby 3.1.2
If one is adamant about versioning gems, thus
gem 'whenever', '~> 1.0', require: false
will remove the described behaviour.