Defect #36892

Redmine does not start when installed --without markdown

Added by Holger Just 6 months ago. Updated 5 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Marius BALTEANU% Done:

0%

Category:Gems support
Target version:5.0.1
Resolution:Fixed Affected version:5.0.0

Description

When installing Redmine 5.0.0 with

bundle install --without markdown

it fails with the following stack trace:

A formatter class is required
~/redmine-5.0.0/lib/redmine/wiki_formatting.rb:45:in `register'
~/redmine-5.0.0/lib/redmine/preparation.rb:400:in `block in prepare'
~/redmine-5.0.0/lib/redmine/wiki_formatting.rb:31:in `map'
~/redmine-5.0.0/lib/redmine/preparation.rb:396:in `prepare'
~/redmine-5.0.0/config/initializers/30-redmine.rb:11:in `block in <top (required)>'
~/.gem/ruby/2.7.5/gems/activesupport-6.1.4.7/lib/active_support/callbacks.rb:427:in `instance_exec'
~/.gem/ruby/2.7.5/gems/activesupport-6.1.4.7/lib/active_support/callbacks.rb:427:in `block in make_lambda'
~/.gem/ruby/2.7.5/gems/activesupport-6.1.4.7/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
~/.gem/ruby/2.7.5/gems/activesupport-6.1.4.7/lib/active_support/callbacks.rb:604:in `block (2 levels) in default_terminator'
~/.gem/ruby/2.7.5/gems/activesupport-6.1.4.7/lib/active_support/callbacks.rb:603:in `catch'
~/.gem/ruby/2.7.5/gems/activesupport-6.1.4.7/lib/active_support/callbacks.rb:603:in `block in default_terminator'
~/.gem/ruby/2.7.5/gems/activesupport-6.1.4.7/lib/active_support/callbacks.rb:199:in `block in halting'
~/.gem/ruby/2.7.5/gems/activesupport-6.1.4.7/lib/active_support/callbacks.rb:512:in `block in invoke_before'
~/.gem/ruby/2.7.5/gems/activesupport-6.1.4.7/lib/active_support/callbacks.rb:512:in `each'
~/.gem/ruby/2.7.5/gems/activesupport-6.1.4.7/lib/active_support/callbacks.rb:512:in `invoke_before'
~/.gem/ruby/2.7.5/gems/activesupport-6.1.4.7/lib/active_support/callbacks.rb:105:in `run_callbacks'
~/.gem/ruby/2.7.5/gems/activesupport-6.1.4.7/lib/active_support/reloader.rb:88:in `prepare!'
~/.gem/ruby/2.7.5/gems/railties-6.1.4.7/lib/rails/application/finisher.rb:124:in `block in <module:Finisher>'
~/.gem/ruby/2.7.5/gems/railties-6.1.4.7/lib/rails/initializable.rb:32:in `instance_exec'
~/.gem/ruby/2.7.5/gems/railties-6.1.4.7/lib/rails/initializable.rb:32:in `run'
~/.gem/ruby/2.7.5/gems/railties-6.1.4.7/lib/rails/initializable.rb:61:in `block in run_initializers'
~/.gem/ruby/2.7.5/gems/railties-6.1.4.7/lib/rails/initializable.rb:60:in `run_initializers'
~/.gem/ruby/2.7.5/gems/railties-6.1.4.7/lib/rails/application.rb:391:in `initialize!'
~/redmine-5.0.0/config/environment.rb:16:in `<top (required)>'
~/.gem/ruby/2.7.5/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
~/.gem/ruby/2.7.5/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
~/.gem/ruby/2.7.5/gems/activesupport-6.1.4.7/lib/active_support/dependencies.rb:332:in `block in require'
~/.gem/ruby/2.7.5/gems/activesupport-6.1.4.7/lib/active_support/dependencies.rb:299:in `load_dependency'
~/.gem/ruby/2.7.5/gems/activesupport-6.1.4.7/lib/active_support/dependencies.rb:332:in `require'
~/.gem/ruby/2.7.5/gems/railties-6.1.4.7/lib/rails/application.rb:367:in `require_environment!'
~/.gem/ruby/2.7.5/gems/railties-6.1.4.7/lib/rails/application.rb:533:in `block in run_tasks_blocks'
~/.gem/ruby/2.7.5/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
~/.gem/ruby/2.7.5/bin/bundle:25:in `load'
~/.gem/ruby/2.7.5/bin/bundle:25:in `<main>'
Tasks: TOP => db:migrate => db:load_config => environment

Although the redcarpet gem is not a strict requirement with the commonmark gem, in Redmine it is currently required by the CommonMark formatter because Redmine::WikiFormatting::CommonMark::Formatter < Redmine::WikiFormatting::Markdown::Formatter. The file where the Markdown formatter is defined, namely lib/redmine/wiki_formatting/markdown/formatter.rb however defines a sub-class of a Redcloth class. This fails without Redcloth being available.

To solve this, we could either:

  • include redcloth in the common_mark group in the Gemfile
  • or extract the markdown parts into different files / modules so that the common_mark stuff can be loaded without Redcloth being present.

Associated revisions

Revision 21575
Added by Marius BALTEANU 5 months ago

Add redcarpet gem to common_mark group because the common_mark implementation requires it and Redmine won't start when it is installed without markdown group (#36892).

Revision 21576
Added by Marius BALTEANU 5 months ago

Merged r21575 to 5.0-stable (#36892).

History

#1 Updated by Marius BALTEANU 6 months ago

  • Status changed from New to Confirmed
  • Target version set to 5.0.1

#2 Updated by Marius BALTEANU 6 months ago

Holger Just wrote:

To solve this, we could either:

  • include redcloth in the common_mark group in the Gemfile
  • or extract the markdown parts into different files / modules so that the common_mark stuff can be loaded without Redcloth being present.

I think the second option sounds better.

#3 Updated by Marius BALTEANU 5 months ago

  • Assignee set to Marius BALTEANU

I took a look again on this and for 5.0.1 it's better to go with option 1 because it doesn't require to many code changes. I'm going to commit the following change:

root@0f0593a01efb:/work# git diff
diff --git a/Gemfile b/Gemfile
index 25134c106..64fbd4fc6 100644
--- a/Gemfile
+++ b/Gemfile
@@ -50,6 +50,9 @@ group :common_mark do
   gem "commonmarker", (Gem.ruby_version < Gem::Version.new('2.6.0') ? '0.21.0' : '0.23.1')
   gem "sanitize", "~> 6.0" 
   gem 'deckar01-task_list', '2.3.2'
+  # ToDo: Remove redcarpet dependency when common_mark is decoupled from markdown.
+  # See defect (#36892) for more details.
+  gem 'redcarpet', '~> 3.5.1'
 end

For version 5.1, I'll add a new tichet to implement the second option.

#4 Updated by Holger Just 5 months ago

I don't think it's a good idea to define the redcarpet gem two times (in the markdown and commonmark groups) as this will cause a warning from bundler and could result in errors later when the version is updated in only one place.

Instead, it should probably be extracted as e.g.

gem 'redcarpet', '~> 3.5.1', :groups => [:markdown, :common_mark]

#5 Updated by Marius BALTEANU 5 months ago

  • Resolution set to Fixed

Thanks Holger, I didn't see the warning.

I've committed now the change and I've created (#37119) to properly fix this.

#6 Updated by Marius BALTEANU 5 months ago

  • Status changed from Confirmed to Closed

Also available in: Atom PDF