-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
SystemStack Error when using config.wrappers in initializer (Rails 6.1 / Ruby 3) #1724
Comments
Can you please try SimpleForm master branch? Other people have hit a different RuntimeError with Ruby 3: #1720, that was just fixed on master. Please check the Changelog for more info, and let me know how that worked, thanks. |
Hi @carlosantoniodasilva - that was an incredibly quick response: thank you! Just tried this on master branch. Same result, I'm afraid. SystemStackError with the config.wrappers block. Hangs without that block. Works without SimpleForm I'm going to dig into the Rails.application.initialize! process (again!) to see if I can figure out where exactly it's hanging I'm not sure if this provides any useful info, but the hang is one where the Rails process (pid) needs to be forcibly killed with a |
Alright, thanks for giving it a try and reporting back. I'll try setting up a new app from scratch with Rails 6.1 and Ruby 3, and see if I can find anything as well. |
A new app just generated with those Ruby/Rails specifications and SimpleForm master doesn't hang:
I'll try bundling with your config. FWIW a previous report of "hanging" with the install generator seemed to be caused by Spring: #1711, I couldn't repro that either. |
I know: it's weird. We have other Ruby 3.0.0 / Rails 6.1 projects that work wonderfully with SimpleForm. I'm going to keep digging into |
Sounds good, thanks. I'm trying to bundle that Gemfile but it's taking a while "Resolving dependencies..." too. Looking some more at the stacktrace, the first line:
I wonder if there's something with autoload going on there. Just for the sake of ruling it out, are you using classic or Zeitwerk with that app, and is it any different than the other apps you mentioned? I might not be able to look into this further today but I can check again tomorrow or later this week. |
Looks like zeitwerk, I think. Gemfile.lock says 2.4.2 |
Ok, but that might still be set to I was unable to bundle, "Resolving dependencies" seemed to get stuck. (even though it seemed like it was progressing, it took minutes without completing, not sure what's up.) |
Confirming: I stripped out all the gems except SimpleForm and put them back in one by one. Looks like we have issues whenever any one of the following gem versions is present: ancestry 3.2.1 Interestingly, if I leave out all of those gems AND include the config.wrappers block in the initializer, the SystemStackError disappears and the application runs If include any one of those gems AND the config.wrappers block, I get the SystemStackError All of the above are true when running SimpleForm from master or from gem version 5.0.3 I'm not sure if these details are of any use, but I'm providing them in case it sparks an idea I'm going to investigate how those gems load in to see if I can spot anything relevant / any similarities |
Thanks for confirming about the autoloader and sharing these details. I tried bundling just with those gems and a couple others (rails, simple_form, sqlite3, puma, sass-rails), and my test generated app still worked. Can you share the Gemfile & Gemfile.lock with the minimal subset of gems above that you were able to repro? And maybe you can try isolating that on a separate app with those gems, see if you can repro it there? |
Will do. I was actually thinking of rebuilding the whole project from a new
rails app, copying in the files I have in batches, so this may be the
start of that
I’ll report back
On Thu, 21 Jan 2021 at 23:44, Carlos Antonio da Silva < ***@***.***> wrote:
Thanks for confirming about the autoloader and sharing these details.
I tried bundling just with those gems and a couple others (rails,
simple_form, sqlite3, puma, sass-rails), and my test generated app still
worked.
Can you share the Gemfile & Gemfile.lock with the minimal subset of gems
above that you were able to repro? And maybe you can try isolating that on
a separate app with those gems, see if you can repro it there?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1724 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAXUS3TZVJUWFZ7ZGG5JQTS3C36JANCNFSM4WLBTMQQ>
.
--
…----------------------------------------------
Terry Shuttleworth
[email protected]
Mobile: +44 (0) 77 68 91 81 93
Google Chat: [email protected]
Skype: itsterry
LinkedIn: linkedin.com/in/itsterry
WhatsApp: Nope.
|
Just hit this while trying to deploy Ruby 3.0.0 with Rails 6.1.1 to production. Oddly enough, I don't hit the error locally or on staging. Will look into this as well and report back if I find anything. Here are the gems I share with @itsterry in case it helps triage some gem incompatibility:
|
@sergiopantoja thanks, interesting to know that it only happens in actual production env. (I'm assuming staging uses a different Rails env in this case? Are there any noticeable config differences between the two?) I tried running in production as well here with your Gemfile and didn't hit anything. 🤔 There must be something with the app config / load that we're missing and may be causing this. |
@carlosantoniodasilva Greetings, any news for a version with suport to Ruby 3.0.0? |
@LeonardoComar I have been holding off releasing master to see if this here was a bigger issue and/or if we could more consistently reproduce, but it doesn't seem to be the case, so I guess I can prepare a new release this week if I don't hear otherwise here in the next couple of days. Thanks! |
I also experience this error in dev and test environment (haven't tried production). In my case it is definitely caused by the presence of ancestry gem. Looks like no one mentioned this, but at least in my case the order of gems in |
@khustochka thanks for letting us know, that is good info. Any chance you can provide a small gist/app that reproduces it? Or at least the Gemfile/Gemfile.lock. I'm still unable to repro with these settings:
And my Gemfile lists
This is a new Rails app but it was created without some of the frameworks, maybe that matters too in order to repro. Also, FWIW, it seems |
Looks like it goes beyond just ancestry. The smallest Gemfile I was able to reproduce this on is as follows:
Here is a demo app. (I also disabled spring and bootsnap for cleaner experiment but they seem to not matter). But:
So some absolutely confusing interaction between zeitgeist, bundler (?) and a random set of other gems? |
Okay, thanks for that @khustochka, I was able to repro here with this limited gems in that order... really confusing, I'll see what I can find. |
Ruby 3+ introduced `Hash#except` method natively [1], so we can skip I18n's custom implementation here if the method is already defined. This follows the same Rails convention [2]. Note: This seems to be causing a `stack level too deep (SystemStackError)` with a specific set of Gemfiles under Ruby 3, reported to `SimpleForm` originally [3]. I haven't been able to fully narrow it down after some initial investigation, nor reproduce it without the given set of gems in the Gemfile reported, but it seems there's some interactions between those gems, and combined with the fact that Ancestry loads I18n early on to setup the load path [4], is possibly causing calls to `Hash#except` to hang or raise with the `stack level too deep` error, and after skipping the method re-declaration here it's not reproducible anymore. [1] https://bugs.ruby-lang.org/issues/15822 [2] https://github.com/rails/rails/blob/5f3ff60084ab5d5921ca3499814e4697f8350ee7/activesupport/lib/active_support/core_ext/hash/except.rb#L12-L14 [3] heartcombo/simple_form#1724 steps to reproduce issue: heartcombo/simple_form#1724 (comment) [4] https://github.com/stefankroes/ancestry/blob/71fe7042791f5943b5370240e4c6068dce73233d/lib/ancestry.rb#L9-L10
Some investigation progress here and a possible solution: The stack traces all seem to point to this builder line:
options.except call, as odd as it sounds.
I am able to load the console ( I know that Ruby 3 has added I went looking into the other gems and found out that Ancestry seems to be messing with the So I looked at I18n and noticed it is adding a refinement to Hash, which includes the I have a branch with that change to i18n here: https://github.com/ruby-i18n/i18n/tree/ca-except-ruby3, @khustochka would you (or anyone else here) be able to try that out in your app and let me know how it goes? If that works I'll work to get that into i18n itself. Thanks! |
@CarlosAlbertoSantos ancestry master is working with rails 6.0 and 6.1 for ruby 3.0 since I need to release a major change for ancestry, it will take a little while to get the next version out. |
@carlosantoniodasilva Thank you! My app works correctly when using that ca-except-ruby3 branch of i18n. |
Ruby 3+ introduced `Hash#except` method natively [1], so we can skip I18n's custom implementation here if the method is already defined. This follows the same Rails convention [2]. Note: This seems to be causing a `stack level too deep (SystemStackError)` with a specific set of Gemfiles under Ruby 3, reported to `SimpleForm` originally [3]. I haven't been able to fully narrow it down after some initial investigation, nor reproduce it without the given set of gems in the Gemfile reported, but it seems there's some interactions between those gems, and combined with the fact that Ancestry loads I18n early on to setup the load path [4], is possibly causing calls to `Hash#except` to hang or raise with the `stack level too deep` error, and after skipping the method re-declaration here it's not reproducible anymore. [1] https://bugs.ruby-lang.org/issues/15822 [2] https://github.com/rails/rails/blob/5f3ff60084ab5d5921ca3499814e4697f8350ee7/activesupport/lib/active_support/core_ext/hash/except.rb#L12-L14 [3] heartcombo/simple_form#1724 steps to reproduce issue: heartcombo/simple_form#1724 (comment) [4] https://github.com/stefankroes/ancestry/blob/71fe7042791f5943b5370240e4c6068dce73233d/lib/ancestry.rb#L9-L10
That's awesome @khustochka, thanks for testing and reporting back. I opened a PR from that branch ruby-i18n/i18n#557 to get the fix into I18n. I'll be releasing SF with Ruby 3 support at some point soon. |
I just released v5.1.0 which should work with Ruby 3 (aside from the issue above which is not SF specific). I'm gonna close this one for now, feel free to subscribe to the I18n issue to hear about updates there. Thanks all. |
FYI: I18n v1.8.9 was just released with the change I proposed to fix the hanging issue with Ruby 3, please give it a shot and report back there if you run into any trouble. |
@carlosantoniodasilva Just reporting in that all looks good now. Many, many thanks for your help with this one: hugely appreciated! |
@itsterry awesome, I'm really glad to hear that it worked! Thanks for reporting back. |
Environment
This is a project which works beautifully with Rails 6.0 / Ruby 2.7.2 - we're upgrading it but having two issue which I think may be related (could be wrong, of course!)
Current behavior
Here's the SystemStackError trace:
'`➜ fanco git:(ruby3) ✗ rails c /Users/terry/.rvm/gems/ruby-3.0.0/gems/simple_form-5.0.3/lib/simple_form/wrappers/builder.rb:51:in
use': stack level too deep (SystemStackError)from /Users/terry/sites/fanco/config/initializers/simple_form.rb:60:in
block (2 levels) in <top (required)>' from /Users/terry/.rvm/gems/ruby-3.0.0/gems/simple_form-5.0.3/lib/simple_form.rb:241:in
build'from /Users/terry/.rvm/gems/ruby-3.0.0/gems/simple_form-5.0.3/lib/simple_form.rb:231:in
wrappers' from /Users/terry/sites/fanco/config/initializers/simple_form.rb:16:in
block in <top (required)>'from /Users/terry/.rvm/gems/ruby-3.0.0/gems/simple_form-5.0.3/lib/simple_form.rb:289:in
setup' from /Users/terry/sites/fanco/config/initializers/simple_form.rb:10:in
<top (required)>'from /Users/terry/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:326:in
load' from /Users/terry/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:326:in
block in load'... 42 levels...
from /Users/terry/.rvm/gems/ruby-3.0.0/gems/railties-6.1.0/lib/rails/command.rb:50:in
invoke' from /Users/terry/.rvm/gems/ruby-3.0.0/gems/railties-6.1.0/lib/rails/commands.rb:18:in
<top (required)>'from bin/rails:4:in
require' from bin/rails:4:in
Here's
config/initializers/simple_form.rb
(with commented lines omitted)Here's my Gemfile:
Expected behavior
For everything to work with the SimpleForm loveliness that we use in all our projects (including other Ruby 3.0.0 / Rails 6.1 ones)
I've tried digging into the SimpleForm code to see if I can figure out what's making it loop (I think it's a loop), but not getting anywhere fast. any pointers would be appreciated!
The text was updated successfully, but these errors were encountered: