Skip to content
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

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

Open
jennykortina opened this issue Sep 3, 2018 · 5 comments

Comments

@jennykortina
Copy link

jennykortina commented Sep 3, 2018

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

@jennykortina jennykortina changed the title Unable to load application: FrozenError: can't modify frozen Array Rails 5 Upgrade Error: Unable to load application: FrozenError: can't modify frozen Array Sep 3, 2018
@sahild
Copy link

sahild commented Sep 14, 2018

I have tried a fix for it in my pull request: #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 rails/rails#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
Copy link
Author

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
Copy link
Author

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
Copy link
Contributor

ZakaryH commented Sep 17, 2018

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
Copy link
Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants