rubocop failing with Rails 6 and Ruby 3

61 views Asked by At

I created a pristine new rails app (rails new myapp), using Rails 6.1.7.7 and Ruby 3.0.6p216. I’m on an Apple M2 Pro running Sonoma 14.2.

I installed rubocop and added it to the Gemfile.

rvm @global do gem install rubocop

Trying to execute rubocop either with or without bundle exec, I get errors. rubocop is in my path,

myapp % which rubocop
/Users/.../.rvm/gems/ruby-3.0.6/bin/rubocop

running rubocop gives me a recursion error (in a pristine rails app)

myapp % rubocop
/Users/.../.rvm/rubies/ruby-3.0.6/lib/ruby/3.0.0/psych/visitors/to_ruby.rb:128:in `visit_Psych_Nodes_Scalar': stack level too deep (SystemStackError)
    from /Users/.../.rvm/rubies/ruby-3.0.6/lib/ruby/3.0.0/psych/visitors/visitor.rb:30:in `visit’

also with bundle exec:

myapp % bundle exec rubocop
bundler: failed to load command: rubocop (/Users/.../.rvm/gems/ruby-3.0.6/bin/rubocop)
/Users/.../.rvm/rubies/ruby-3.0.6/lib/ruby/3.0.0/psych/visitors/to_ruby.rb:52:in `deserialize': stack level too deep (SystemStackError)
    from /Users/.../.rvm/rubies/ruby-3.0.6/lib/ruby/3.0.0/psych/visitors/to_ruby.rb:128:in `visit_Psych_Nodes_Scalar'

I tried getting rid of psych but it is considered a default.

myapp % gem uninstall psych
Gem psych-3.3.2 cannot be uninstalled because it is a default gem

Any ideas would be greatly appreciated. I spent a lot of time looking for a recursion problem in my code now to find out this error also occurs for a brand new rails app. I no longer think it is a code problem.

1

There are 1 answers

0
Edil Talantbekov On

https://github.com/rubocop/rubocop/issues/5118#issuecomment-346876567

I think this one should fix your problem. If you already have .rubocop.yml file then you should check for correctness and fix this yml file