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

"can't modify frozen Array" error during generation #3060

Closed
robwise opened this issue Aug 27, 2018 · 4 comments
Closed

"can't modify frozen Array" error during generation #3060

robwise opened this issue Aug 27, 2018 · 4 comments

Comments

@robwise
Copy link

robwise commented Aug 27, 2018

This is a pretty stock rails 5.2 app with Ruby 2.4.4 and rails_admin 1.4.1.

Downgrading to rails_admin 1.3 resolves the issue.

9/5/2018: It seems that you only need to downgrade to 1.4.0.

Full error message:

rails g rails_admin:install
/Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/stack.rb:76:in `insert': can't modify frozen Array (RuntimeError)
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/stack.rb:76:in `insert'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/webpacker-3.5.5/lib/webpacker/railtie.rb:51:in `block in <class:Engine>'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/railties-5.2.1/lib/rails/initializable.rb:32:in `instance_exec'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/railties-5.2.1/lib/rails/initializable.rb:32:in `run'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/railties-5.2.1/lib/rails/initializable.rb:61:in `block in run_initializers'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/2.4.0/tsort.rb:347:in `each'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/2.4.0/tsort.rb:347:in `call'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/railties-5.2.1/lib/rails/initializable.rb:60:in `run_initializers'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/railties-5.2.1/lib/rails/application.rb:361:in `initialize!'
	from /Users/rob/dev/link_legal/web_app/config/environment.rb:7:in `<main>'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:102:in `preload'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:153:in `serve'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `run'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>'
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'%
	from /Users/rob/.rbenv/versions/2.4.4/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from -e:1:in `<main>'

Gemfile:

# frozen_string_literal: true

source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "2.4.4"

# === Core Stack
gem "pg" # Use postgresql as the database for Active Record
gem "puma" # Use Puma as the app server
gem "rails"
gem "sass-rails" # Use SCSS for stylesheets
gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby] # Windows does not include zoneinfo files
# gem 'mini_racer', platforms: :ruby # See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'redis', '~> 4.0' # Use Redis adapter to run Action Cable in production

# === Rails Addons
gem "bootsnap", require: false # Reduces boot times through caching; required in config/boot.rb
gem "turbolinks" # https://github.com/turbolinks/turbolinks
gem "enumerize"
gem "rails_admin", "1.3" # bug regarding frozen array with 1.4
# gem 'mini_magick', '~> 4.8' # Use ActiveStorage variant

# === Asset Packaging and Serving
gem "uglifier" # Use Uglifier as compressor for JavaScript assets
gem "webpacker" # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker

# === Utilities
gem "awesome_print"

group :development, :test do
  gem "annotate"
  gem "byebug", platforms: %i[mri mingw x64_mingw] # Call 'byebug' anywhere in the code
  gem "rspec-rails"
  gem "rspec_junit_formatter" # See https://circleci.com/docs/test-metadata/#rspec
  gem "rubocop", require: false
  gem "rubocop-rspec"
  gem "faker"
  gem "factory_bot_rails"
end

group :development do
  gem "listen" # https://github.com/rails/spring
  gem "spring"
  gem "spring-watcher-listen"
  gem "web-console" # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
end

group :test do
  gem "capybara" # Adds support for Capybara system testing and selenium driver
  gem "chromedriver-helper"
  gem "selenium-webdriver" # Easy installation and use of chromedriver to run system tests with Chrome
  gem "shoulda-matchers"
end
@sandipsubedi
Copy link

Downgrading rails_admin to 1.4.0 worked for us.

@abepark01
Copy link

abepark01 commented Aug 30, 2018

I am experiencing the same issue; rails_admin 1.4.0 works okay, but not 1.4.1 in rails 5.2.1

ruby 2.5.1
rails 5.2.1
rails_admin 1.4.1
webpacker 3.5.5

rails g rails_admin:install
Traceback Traceback (most recent call last): 32: from bin/rails:4:in `' 31: from bin/rails:4:in `require' 30: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/commands.rb:18:in `' 29: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/command.rb:46:in `invoke' 28: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/command/base.rb:65:in `perform' 27: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch' 26: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command' 25: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run' 24: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/commands/generate/generate_command.rb:21:in `perform' 23: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/command/actions.rb:18:in `require_application_and_environment!' 22: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/application.rb:337:in `require_environment!' 21: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require' 20: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency' 19: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require' 18: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require' 17: from /Users/admin/spark-io/config/environment.rb:3:in `' 16: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/application.rb:361:in `initialize!' 15: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/initializable.rb:60:in `run_initializers' 14: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each' 13: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each' 12: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component' 11: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/2.5.0/tsort.rb:347:in `call' 10: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/2.5.0/tsort.rb:347:in `each' 9: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component' 8: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from' 7: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component' 6: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each' 5: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/initializable.rb:61:in `block in run_initializers' 4: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/initializable.rb:32:in `run' 3: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/initializable.rb:32:in `instance_exec' 2: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/webpacker-3.5.5/lib/webpacker/railtie.rb:51:in `block in ' 1: from /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/stack.rb:76:in `insert' /Users/admin/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/stack.rb:76:in `insert': can't modify frozen Array (FrozenError)

@gabrieletassoni
Copy link

Also on my side:

rails 5.2.1
rails_admin 1.4.1
serviceworker-rails 0.5.5

the problem was with serviceworker-rails, downgrading rails_admin to 1.4.0 solved the issue, but I now can't upgrade rails_admin until a solution is found.

@Jemisson
Copy link

Jemisson commented May 8, 2023

That problem still happens in:

Ruby 3.0.3
Rails 6.1.7
Webpacker 5.0

To solve it I ran:
rails g rails_admin:install

and solve it! \o/

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

5 participants