meta-tags icon indicating copy to clipboard operation
meta-tags copied to clipboard

Got error `ret: 2, hash modified during iteration` After upgrade ruby 2.7.0

Open kntmrkm opened this issue 5 years ago • 9 comments

An ActionView::Template::Error occurred in products#show:

  ret: 2, hash modified during iteration

in display_meta_tags method.

with meta-tags version 2.13.0.

kntmrkm avatar Dec 26 '19 04:12 kntmrkm

I just got this too after upgrading to Ruby 2.7.0. Here's my stack trace

File /app/vendor/bundle/ruby/2.7.0/gems/meta-tags-2.13.0/lib/meta_tags/renderer.rb line 167 in each_key
File /app/vendor/bundle/ruby/2.7.0/gems/meta-tags-2.13.0/lib/meta_tags/renderer.rb line 167 in render_hashes
File /app/vendor/bundle/ruby/2.7.0/gems/meta-tags-2.13.0/lib/meta_tags/renderer.rb line 34 in render
File /app/vendor/bundle/ruby/2.7.0/gems/meta-tags-2.13.0/lib/meta_tags/view_helper.rb line 181 in block in display_meta_tags
File /app/vendor/bundle/ruby/2.7.0/gems/meta-tags-2.13.0/lib/meta_tags/meta_tags_collection.rb line 53 in with_defaults
File /app/vendor/bundle/ruby/2.7.0/gems/meta-tags-2.13.0/lib/meta_tags/view_helper.rb line 181 in display_meta_tags

MSeneadza avatar Dec 27 '19 03:12 MSeneadza

Same here ! Anyone know how to solve it?

Thank you for this awesome gem

guillaumebriday avatar Jan 06 '20 10:01 guillaumebriday

Same error, mine happened in a different location:

/GEM_ROOT/gems/meta-tags-2.13.0/lib/meta_tags/renderer.rb:189
/GEM_ROOT/gems/meta-tags-2.13.0/lib/meta_tags/renderer.rb:189
/GEM_ROOT/gems/meta-tags-2.13.0/lib/meta_tags/renderer.rb:35
/GEM_ROOT/gems/meta-tags-2.13.0/lib/meta_tags/view_helper.rb:181
/GEM_ROOT/gems/meta-tags-2.13.0/lib/meta_tags/meta_tags_collection.rb:53
/GEM_ROOT/gems/meta-tags-2.13.0/lib/meta_tags/view_helper.rb:181

excid3 avatar Jan 08 '20 01:01 excid3

Does anyone have any ideas on how we could fix it ?

guillaumebriday avatar Jan 10 '20 09:01 guillaumebriday

I reported this issue to Ruby core team. They fixed it quickly, but we have to wait until the next version is released.

https://bugs.ruby-lang.org/issues/16503

JunichiIto avatar Jan 12 '20 23:01 JunichiIto

Thank you @JunichiIto

2.7 is a pain with errors and warnings tbh compared to 2.4, 2.5, 2.6...

guillaumebriday avatar Jan 12 '20 23:01 guillaumebriday

Does anyone know when the ruby team will cut a patch release?

hwhelchel avatar Feb 16 '20 13:02 hwhelchel

Ruby 2.7.1 has been released! 🎉

https://www.ruby-lang.org/en/news/2020/03/31/ruby-2-7-1-released/

The following code raises RuntimeError (ret: 2, hash modified during iteration) against 2.7.0 but runs infinitely against 2.7.1, so the problems should have been fixed.

loop{
  h = {a:1, b:2, c:3, d:4, e:5, f:6, g:7, h:8}
  h.each{|k,v| GC.start; h.delete(k)}
}

JunichiIto avatar Apr 01 '20 02:04 JunichiIto

It might have occured bcz you switched to another git branch with diff set of meta tags since error says during iteration. Restarting rails server worked out for me

Mayank-savaliya avatar Apr 27 '21 06:04 Mayank-savaliya

Closing issue, confirmed a Ruby bug in 2.7.0, addressed in 2.7.1+

  • https://bugs.ruby-lang.org/issues/16503
  • https://github.com/ruby/ruby/commit/8e8841f6bf58031a1fe5b0dbacb5a1fb442102df

Kudoes to @JunichiIto

kpumuk avatar Oct 17 '23 22:10 kpumuk