gregschmit / recurring_select

A gem for adding selectors for setting recurring events.
MIT License
335 stars 238 forks source link

Rails 5 Upgrade Error: Unable to load application: FrozenError: can't modify frozen Array #124

Open jennykortina opened 6 years ago

jennykortina commented 6 years ago

Just upgraded to rails 5 and am getting Unable to load application: FrozenError: can't modify frozen Array

17:51:56 web.1    | [1358] * Preloading application
17:51:59 web.1    | [1358] ! Unable to load application: FrozenError: can't modify frozen Array
17:51:59 web.1    | /Users/jennykortina/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.1/lib/action_dispatch/middleware/stack.rb:97:in `push': can't modify frozen Array (FrozenError)
17:51:59 web.1    |     from /Users/jennykortina/.rvm/gems/ruby-2.5.1/gems/actionpack-5.2.1/lib/action_dispatch/middleware/stack.rb:97:in `use'
17:51:59 web.1    |     from /Users/jennykortina/.rvm/gems/ruby-2.5.1/gems/recurring_select-2.1.0/lib/recurring_select/engine.rb:12:in `block in <class:Engine>'
17:51:59 web.1    |     from /Users/jennykortina/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/initializable.rb:32:in `instance_exec'
17:51:59 web.1    |     from /Users/jennykortina/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/initializable.rb:32:in `run'
17:51:59 web.1    |     from /Users/jennykortina/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/initializable.rb:61:in `block in run_initializers'
17:51:59 web.1    |     from /Users/jennykortina/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'
17:51:59 web.1    |     from /Users/jennykortina/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
17:51:59 web.1    |     from /Users/jennykortina/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'
17:51:59 web.1    |     from /Users/jennykortina/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'
17:51:59 web.1    |     from /Users/jennykortina/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:347:in `each'
17:51:59 web.1    |     from /Users/jennykortina/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:347:in `call'
17:51:59 web.1    |     from /Users/jennykortina/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'
17:51:59 web.1    |     from /Users/jennykortina/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'
17:51:59 web.1    |     from /Users/jennykortina/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'
17:51:59 web.1    |     from /Users/jennykortina/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/initializable.rb:60:in `run_initializers'
17:51:59 web.1    |     from /Users/jennykortina/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/application.rb:361:in `initialize!'
17:51:59 web.1    |     from /Users/jennykortina/Developer/sesher/config/environment.rb:5:in `<top (required)>'
17:51:59 web.1    |     from config.ru:3:in `require'
17:51:59 web.1    |     from config.ru:3:in `block in <main>'
17:51:59 web.1    |     from /Users/jennykortina/.rvm/gems/ruby-2.5.1/gems/rack-2.0.5/lib/rack/builder.rb:55:in `instance_eval'
17:51:59 web.1    |     from /Users/jennykortina/.rvm/gems/ruby-2.5.1/gems/rack-2.0.5/lib/rack/builder.rb:55:in `initialize'
17:51:59 web.1    |     from config.ru:in `new'
17:51:59 web.1    |     from config.ru:in `<main>'

When I try to start the server. If I remove the recurring_select gem the server starts.

screen shot 2018-09-02 at 5 55 26 pm

Here's all the places I am referencing recurring_select

screen shot 2018-09-02 at 6 43 52 pm
sahild commented 6 years ago

I have tried a fix for it in my pull request: https://github.com/GetJobber/recurring_select/pull/115 You can use my forked branch till the time it gets accepted by adding this to your gemfile: gem 'recurring_select', git: 'https://github.com/sahild/recurring_select.git', branch: 'master'

This issue was caused by this https://github.com/rails/rails/pull/5911 which basically Do not allow editing middleware stack after it has been built

Backward compatibility of a lot of gems is compromised. By fix is loosely based on how sass-rails gem was fixed https://github.com/rails/sass-rails/pull/386/files

jennykortina commented 6 years ago

The gem now loads, but when I try to call it in a view I get:

NoMethodError - undefined methodselect_recurring' for ...`

Trying to call it like so:

<%= f.select_recurring :recurring_rule, [], :allow_blank => true %>

jennykortina commented 6 years ago

The issue was @sahild wasn't on the most update to version of the gem. I have a fork here:

https://github.com/jennykortina/recurring_select -> master

That runs on rails 5.2

ZakaryH commented 6 years ago

Hi we're looking into this issue, but haven't been able to reproduce it with a fresh Rails 5.2.0 or 5.2.1 app using recurring_select.

Would you be able to provide an example project that is experiencing this issue?

jennykortina commented 6 years ago

@ZakaryH it's a private repo so no I can't provide an example. But I'm surprised you can get rails to start with the gem as is. As @sahild said b/c the gem is editing the middleware it shuts the server down