whenever icon indicating copy to clipboard operation
whenever copied to clipboard

Ruby 3.2 autocompletion in console

Open hirogeek opened this issue 2 years ago • 9 comments

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

hirogeek avatar Jan 04 '23 10:01 hirogeek

what is the code that make it crash?

buncis avatar Jan 26 '23 17:01 buncis

After re-try it's seems, at lest, crash when I write dot after non existente var. So launch console, type : test.to_s

hirogeek avatar Jan 26 '23 17:01 hirogeek

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 image

buncis avatar Jan 27 '23 06:01 buncis

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

YashaVinter avatar Feb 04 '23 17:02 YashaVinter

I ran into this issue as well. Love Whenever, but this definitely annoying 😞

nuclearghost avatar Feb 14 '23 16:02 nuclearghost

@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

  1. Have gem "whenever" in gemfile (so that it's required).
  2. rails c
  3. Try typing Time.now. and it'll crash as soon as you put the dot after now.

Stracktrace screenshots

image image

DavidAmyot avatar Feb 20 '23 18:02 DavidAmyot

use "require: false"

gem 'whenever', require: false

截圖-2023-02-21-17 30 55

guanting112 avatar Feb 21 '23 09:02 guanting112

Please take a look at #830

crevete avatar Feb 21 '23 20:02 crevete

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.

dvodvo avatar Mar 15 '23 07:03 dvodvo