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

Ruby 3.2 autocompletion in console #831

Open
hirogeek opened this issue Jan 4, 2023 · 9 comments
Open

Ruby 3.2 autocompletion in console #831

hirogeek opened this issue Jan 4, 2023 · 9 comments

Comments

@hirogeek
Copy link

hirogeek commented Jan 4, 2023

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

@buncis
Copy link

buncis commented Jan 26, 2023

what is the code that make it crash?

@hirogeek
Copy link
Author

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

@buncis
Copy link

buncis commented Jan 27, 2023

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

@YashaVinter
Copy link

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

@nuclearghost
Copy link

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

@DavidAmyot
Copy link

DavidAmyot commented Feb 20, 2023

@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

@guanting112
Copy link

use "require: false"

gem 'whenever', require: false

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

@crevete
Copy link

crevete commented Feb 21, 2023

Please take a look at #830

@dvodvo
Copy link

dvodvo commented Mar 15, 2023

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.

mjgiarlo added a commit to sul-dlss/happy-heron that referenced this issue May 15, 2023
This commits works around a bug in the whenever gem that has begun crashing the Rails console when doing auto-complete under Ruby 3.2: javan/whenever#831
mjgiarlo added a commit to sul-dlss/happy-heron that referenced this issue May 15, 2023
This commits works around a bug in the whenever gem that has begun crashing the Rails console when doing auto-complete under Ruby 3.2: javan/whenever#831
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

8 participants