Multisite:migrate broken since Rails 6.0.3 update

Hello!

I’m on revision 136a5456534c7e468b8052f865ce970a3bf375e9, where doing a multisite:migrate fails with

I, [2020-05-07T06:57:21.288947 #1]  INFO -- : > cd /var/www/discourse && sudo -Eu discourse bundle exec rake multisite:migrate
`/root` is not writable.
Bundler will use `/tmp/bundler20200507-300-1g5pu90300' as your home directory temporarily.
rake aborted!
NoMethodError: undefined method `call' for [:delete, RailsMultisite::Middleware]:Array
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3/lib/rails/configuration.rb:76:in `block in merge_into'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3/lib/rails/configuration.rb:75:in `each'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3/lib/rails/configuration.rb:75:in `merge_into'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3/lib/rails/engine.rb:512:in `block in app'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3/lib/rails/engine.rb:509:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3/lib/rails/engine.rb:509:in `app'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3/lib/rails/application/finisher.rb:97:in `block in <module:Finisher>'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3/lib/rails/initializable.rb:32:in `instance_exec'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3/lib/rails/initializable.rb:32:in `run'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3/lib/rails/initializable.rb:61:in `block in run_initializers'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3/lib/rails/initializable.rb:60:in `run_initializers'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3/lib/rails/application.rb:363:in `initialize!'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3/lib/rails/railtie.rb:190:in `public_send'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3/lib/rails/railtie.rb:190:in `method_missing'
/var/www/discourse/config/environment.rb:7:in `<top (required)>'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3/lib/active_support/dependencies.rb:324:in `block in require'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3/lib/active_support/dependencies.rb:291:in `load_dependency'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3/lib/active_support/dependencies.rb:324:in `require'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3/lib/rails/application.rb:339:in `require_environment!'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3/lib/rails/application.rb:523:in `block in run_tasks_blocks'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => multisite:migrate => db:load_config => environment
(See full trace by running task with --trace)
I, [2020-05-07T06:57:26.316379 #1]  INFO -- : 

It looks like this is related to middleware manipulation in config/initializers/200-first_middlewares.rb.

Rewinding to before 136a5456534c7e468b8052f865ce970a3bf375e9, the commit that bumps to Rails 6.0.3, allows multisite:migrate to work. I’ve also got a development instance in which I’ve replaced the session_operations with a .delete and .unshift on Rails.configuration.middleware, and it seems happy with the result.

(… modulo migration 20141216112341_resolve_duplicate_group_names failing, claiming a nonexistent column groups.automatic_membership_email_domains, but that goes away when retried.)

I’ve forgotten most all of what I used to know about Rails, so I might be entirely wrong here!

6 Likes

Yup, same issue here and I can confirm this is due to the changes in 200-first_middlewares.rb.
And from there on, my RoR knowledge is insufficient to understand what is going on :thinking:

2 Likes

Sorry about that, we’ve reverted the rails update for now: https://github.com/discourse/discourse/commit/2ff8b4f5d9dd72a55d7ebdc23a3758dd5ec4682d

9 Likes