phpBB3-Import schlägt mit Zeitwerk::NameError bei aktueller Discourse-Version fehl

Ich versuche, ein phpBB3-Forum gemäß der offiziellen Migrationsanleitung zu importieren, aber das Import-Skript schlägt sofort mit einem Zeitwerk::NameError fehl.

Umgebung

  • Discourse-Version: v2026.2.0-latest-324 (habe auch stable/esr-Branch versucht)
  • Installation: Docker-basierter Import-Container
  • Zuvor: Erfolgreicher Import desselben phpBB-Forums Anfang Januar 2026 ohne Probleme

Der Fehler

/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/zeitwerk-2.7.3/lib/zeitwerk/loader/callbacks.rb:31:in 'Zeitwerk::Loader::Callbacks#on_file_autoloaded': expected file /var/www/discourse/lib/freedom_patches/safe_migrations.rb to define constant FreedomPatches::SafeMigrations, but didn't (Zeitwerk::NameError)
Klicken Sie hier, um die vollständige Fehlerspur zu erweitern
discourse@vps116136-import-from-app:/var/www/discourse/script/import_scripts$ bundle exec ruby phpbb3.rb /shared/import/settings.yml
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/zeitwerk-2.7.3/lib/zeitwerk/loader/callbacks.rb:31:in 'Zeitwerk::Loader::Callbacks#on_file_autoloaded': expected file /var/www/discourse/lib/freedom_patches/safe_migrations.rb to define constant FreedomPatches::SafeMigrations, but didn't (Zeitwerk::NameError)

      raise Zeitwerk::NameError.new(msg, cref.cname)
      ^^^^^
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/zeitwerk-2.7.3/lib/zeitwerk/core_ext/kernel.rb:27:in 'Kernel#require'
        from /var/www/discourse/config/initializers/002-freedom_patches.rb:11:in 'block (2 levels) in <main>'
        from /var/www/discourse/config/initializers/002-freedom_patches.rb:9:in 'Array#each'
        from /var/www/discourse/config/initializers/002-freedom_patches.rb:9:in 'block in <main>'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.4/lib/active_support/callbacks.rb:406:in 'BasicObject#instance_exec'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.4/lib/active_support/callbacks.rb:406:in 'block in ActiveSupport::Callbacks::CallTemplate::InstanceExec0#make_lambda'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.4/lib/active_support/callbacks.rb:178:in 'block in ActiveSupport::Callbacks::Filters::Before#call'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.4/lib/active_support/callbacks.rb:668:in 'block (2 levels) in ActiveSupport::Callbacks::CallbackChain#default_terminator'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.4/lib/active_support/callbacks.rb:667:in 'Kernel#catch'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.4/lib/active_support/callbacks.rb:667:in 'block in ActiveSupport::Callbacks::CallbackChain#default_terminator'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.4/lib/active_support/callbacks.rb:179:in 'ActiveSupport::Callbacks::Filters::Before#call'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.4/lib/active_support/callbacks.rb:559:in 'block in ActiveSupport::Callbacks::CallbackSequence#invoke_before'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.4/lib/active_support/callbacks.rb:559:in 'Array#each'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.4/lib/active_support/callbacks.rb:559:in 'ActiveSupport::Callbacks::CallbackSequence#invoke_before'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.4/lib/active_support/callbacks.rb:108:in 'ActiveSupport::Callbacks#run_callbacks'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.4/lib/active_support/reloader.rb:96:in 'ActiveSupport::Reloader.prepare!'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/railties-8.0.4/lib/rails/application/finisher.rb:73:in 'block in <module:Finisher>'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/railties-8.0.4/lib/rails/initializable.rb:32:in 'BasicObject#instance_exec'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/railties-8.0.4/lib/rails/initializable.rb:32:in 'Rails::Initializable::Initializer#run'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/railties-8.0.4/lib/rails/initializable.rb:61:in 'block in Rails::Initializable#run_initializers'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:231:in 'block in TSort.tsort_each'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:353:in 'block (2 levels) in TSort.each_strongly_connected_component'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:434:in 'TSort.each_strongly_connected_component_from'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:352:in 'block in TSort.each_strongly_connected_component'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:350:in 'Rails::Initializable::Collection#each'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:350:in 'Method#call'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:350:in 'TSort.each_strongly_connected_component'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:229:in 'TSort#tsort_each'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/railties-8.0.4/lib/rails/initializable.rb:60:in 'Rails::Initializable#run_initializers'
        from /var/www/discourse/vendor/bundle/ruby/3.4.0/gems/railties-8.0.4/lib/rails/application.rb:444:in 'Rails::Application#initialize!'
        from /var/www/discourse/config/environment.rb:7:in '<top (required)>'
        from /var/www/discourse/script/import_scripts/base.rb:16:in 'Kernel#require_relative'
        from /var/www/discourse/script/import_scripts/base.rb:16:in '<top (required)>'
        from /var/www/discourse/script/import_scripts/phpbb3/support/settings.rb:5:in 'Kernel#require_relative'
        from /var/www/discourse/script/import_scripts/phpbb3/support/settings.rb:5:in '<top (required)>'
        from phpbb3.rb:17:in 'Kernel#require_relative'
        from phpbb3.rb:17:in '<module:PhpBB3>'
        from phpbb3.rb:16:in '<module:ImportScripts>'
        from phpbb3.rb:15:in '<main>'

Was ich versucht habe

  1. Verschiedene Discourse-Versionen: Getestet mit latest, stable und esr-Branches – alle schlagen mit demselben Fehler fehl.
  2. Verschiedene Rails-Umgebungen: Habe RAILS_ENV=production und RAILS_ENV=development versucht.
  3. Frische Container-Builds: Import-Container mehrmals zerstört und neu erstellt.
  4. Bundle install: Abhängigkeiten mit bundle install aktualisiert.

Ursachenanalyse

Die Datei /var/www/discourse/lib/freedom_patches/safe_migrations.rb definiert die Konstante SafeMigrations nur, wenn RAILS_ENV != "production":

if ENV["RAILS_ENV"] != "production"
  require_dependency "migration/safe_migrate"
  Migration::SafeMigrate.patch_active_record!
end

Allerdings versucht der Initialisierer /var/www/discourse/config/initializers/002-freedom_patches.rb, diese Datei bedingungslos einzubinden, was im Produktionsmodus den Zeitwerk-Fehler verursacht.

Fragen

  1. Ist jemand anderem dieses Problem bei neueren Discourse-Versionen begegnet?
  2. Gibt es einen bekannten Workaround oder eine Korrektur?
  3. Welche Discourse-Version wird derzeit für phpBB-Importe empfohlen?

Die Tatsache, dass dies im Januar funktionierte, aber jetzt fehlschlägt, deutet auf eine kürzliche Breaking Change im Discourse-Kern hin, die Importe betrifft. Jede Hilfe wäre sehr willkommen!