Skip to content

Unable to precompile assets when updating to 3.0.0.beta #3534

@codealchemy

Description

@codealchemy

Describe the bug

Attempting to run bundle exec rake assets:precompile raises an exception

Reproduction steps

Update gem in a project using :sprockets, attempt to precompile

Expected behavior

Assets to be compiled as before

Additional context

  • rails version: 6.0.5
  • rails_admin version: 3.0.0.beta
  • rails_admin npm package version: N/A
  • full stack trace (if there's an exception)

(reduced this down to the essential bit of the error as we have internal middlewares in addition to those from Rails)

FrozenError:
  can't modify frozen Array: [... middleware classes ]
/project_dir/vendor/bundle/ruby/2.7.0/gems/actionpack-6.0.5/lib/action_dispatch/middleware/stack.rb:126:in `push'
/project_dir/vendor/bundle/ruby/2.7.0/gems/actionpack-6.0.5/lib/action_dispatch/middleware/stack.rb:126:in `use'
/project_dir/vendor/bundle/ruby/2.7.0/gems/<internal gem>:in `block in <class:Engine>'
/project_dir/vendor/bundle/ruby/2.7.0/gems/railties-6.0.5/lib/rails/initializable.rb:32:in `instance_exec'
/project_dir/vendor/bundle/ruby/2.7.0/gems/railties-6.0.5/lib/rails/initializable.rb:32:in `run'
/project_dir/vendor/bundle/ruby/2.7.0/gems/railties-6.0.5/lib/rails/initializable.rb:61:in `block in run_initializers'
/project_dir/vendor/bundle/ruby/2.7.0/gems/railties-6.0.5/lib/rails/initializable.rb:60:in `run_initializers'
/project_dir/vendor/bundle/ruby/2.7.0/gems/railties-6.0.5/lib/rails/application.rb:363:in `initialize!'

This appears to be related to changes to initialization from e59a935

Workaround

Keep only the precompile initializer during precompilation

# application.rb

if ENV.fetch('PRECOMPILE', false)
  RailsAdmin::Engine.initializers.keep_if { |i| i.name == 'RailsAdmin precompile hook' }
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions