simple_form: SystemStack Error when using config.wrappers in initializer (Rails 6.1 / Ruby 3)
Environment
- Ruby 3.0.0
- Rails 6.1.0
- Simple Form 5.0.3
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
- Starting Rails server or console with SimpleForm config including wrappers config causes a SystemStackError
- Starting Rails server or console with SimpleForm config NOT including wrappers config causes the application to hang on Rails.application.initialize
- Starting Rails server or console WITHOUT SimpleForm: no problems
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 <main>'`
Here’s config/initializers/simple_form.rb (with commented lines omitted)
SimpleForm.setup do |config|
config.wrappers :default,
class: :input,
hint_class: :field_with_hint,
error_class: :field_with_errors,
valid_class: :field_without_errors do |b|
b.use :html5
b.use :placeholder
b.optional :maxlength
b.optional :minlength
b.optional :pattern
b.optional :min_max
b.optional :readonly
b.use :label_input
b.use :hint, wrap_with: { tag: :span, class: :hint }
b.use :error, wrap_with: { tag: :span, class: :error }
end
config.default_wrapper = :default
config.boolean_style = :nested
config.button_class = 'btn'
config.error_notification_tag = :div
config.error_notification_class = 'error_notification'
config.browser_validations = false
config.boolean_label_class = 'checkbox'
end
Here’s my Gemfile:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'acts_as_list'
gem 'acts-as-taggable-on', git: 'https://github.com/morsedigital/acts-as-taggable-on'
gem 'after_party'
gem 'ancestry'
gem 'aws-sdk-s3'
gem 'axlsx', git: 'https://github.com/randym/axlsx.git', ref: 'c8ac844'
gem 'better_errors'
gem "binding_of_caller"
gem "browser", ">=2.5.1"
gem 'bullet', group: :development
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw], groups: [:development, :test]
gem 'capistrano'
gem 'capybara', '>= 2.15', groups: [:test]
gem 'caxlsx_rails'
gem 'codacy-coverage', require: false
gem 'coveralls', groups: [:test]
gem 'decent_exposure'
gem 'devise'
gem 'dotenv-rails', require: 'dotenv/rails-now'
gem 'elasticsearch-model'
gem 'elasticsearch-rails'
gem 'faker'
gem 'factory_bot_rails'
gem 'faraday_middleware-aws-sigv4'
gem 'friendly_id'
gem 'google_drive'
gem 'gretel'
gem 'guard-rspec', groups: [:test]
gem 'guard-rubocop', groups: [:test]
gem 'i18n-debug', groups: [:development, :test]
gem 'i18n-tasks', groups: [:development, :test]
gem "iconv"
gem 'image_processing', '~> 1.2'
gem 'instagram'
gem 'jbuilder', '~> 2.5'
gem 'kaminari'
gem 'listen', groups: [:development]
gem "letter_opener", :group => :development
gem 'mini_magick'
gem 'morse_active_record_helpers'
gem 'morse_spec_helpers', '>=4.0.0', groups: [:development]
gem 'mysql2'
gem 'newrelic_rpm'
gem 'overcommit', groups: [:development]
gem 'omniauth'
gem 'omniauth-facebook'
gem 'omniauth-instagram'
gem 'omniauth-google-oauth2', '~> 0.8.0'
gem 'percy-capybara', '~> 4.0.0'
gem 'pry-byebug'
gem 'puma', '~> 3.11'
gem 'rails', '>=6.1'
gem 'rails_real_favicon', groups: [:development]
gem 'ransack'
gem 'recaptcha', require: 'recaptcha/rails'
gem 'record_tag_helper'
gem 'rest-client'
gem 'rollbar'
gem "roo", "~> 2.8.0"
gem 'rspec-rails', groups: [:development, :test]
gem 'rubocop', groups: [:test]
gem 'ruby-graphviz'
gem 'rubyzip', '>= 1.2.1'
gem 'sass-rails', '~> 5.0'
gem 'searchkick'
gem 'serviceworker-rails'
gem 'shoulda-matchers', groups: [:test]
gem 'sidekiq'
gem 'simple_form'
gem 'simplecov', groups: [:test]
gem 'spring', groups: [:test]
gem 'spring-commands-rspec', groups: [:test]
gem 'turbolinks', '~> 5'
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'web-console', github: 'rails/web-console', groups: [:development]
gem 'webdrivers', '~>3.0'
gem 'webpacker'
gem 'webpush'
gem 'workflow-activerecord'
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!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 27 (21 by maintainers)
Commits related to this issue
- Prevent overwriting `Hash#except` method present in Ruby 3+ Ruby 3+ introduced `Hash#except` method natively [1], so we can skip I18n's custom implementation here if the method is already defined. Th... — committed to ruby-i18n/i18n by carlosantoniodasilva 3 years ago
- Prevent overwriting `Hash#except` method present in Ruby 3+ Ruby 3+ introduced `Hash#except` method natively [1], so we can skip I18n's custom implementation here if the method is already defined. Th... — committed to ruby-i18n/i18n by carlosantoniodasilva 3 years ago
@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!
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.
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.
@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. In the meantime, I hope master will work for you. Let me know if it gives you any troubles
@carlosantoniodasilva Greetings, any news for a version with suport to Ruby 3.0.0?
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:
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 < notifications@github.com> wrote:
–
Terry Shuttleworth
itsterry@gmail.com
Mobile: +44 (0) 77 68 91 81 93 Google Chat: itsterry@gmail.com Skype: itsterry LinkedIn: linkedin.com/in/itsterry WhatsApp: Nope.
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
Rails.application.initialize!. If I don’t find anything there, my next step is to take out all the other gems and see if that fixes it, which I think would indicate a conflict. Could be wrong, but it’s a plan of action…