ruby-on-railsruby-on-rails-7whenever

whenever gem crashes Rails console method autocompletion


Since I upgraded to Rails 7, when I type dot after variable name in my rails console, it often crashes with the error below.

/usr/local/bundle/gems/whenever-1.0.0/lib/whenever/job_list.rb:41:in `respond_to?': undefined method `has_key?' for nil:NilClass (NoMethodError)
                 when
      @set_variables.has_key?(name) || super
                    ^^^^^^^^^

I can see that it caused by whenever gem, but how to I fix this? The method autocomplete feature is so nice, but it crashes so easily such that the console is unusable.


Solution

  • That's a bug in the whenever code. For now, either don't require it in the Gemfile:

    gem 'whenever', require: false
    

    Either use a hack: https://gist.github.com/hirogeek/1c6d511a77ec3b15dea8a0db0a11fb1c