Project

General

Profile

Actions

Defect #37394

open

uninitialized constant Redmine::WikiFormatting::CommonMark::HTML (NameError)

Added by Mischa The Evil almost 3 years ago. Updated 4 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Gems support
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

There appears to exist a loading issue, probably connected to the Zeitwerk loader, which has now been reported twice in the forums:
1. Error with redmine 5.0.2 on FreeBSD 13.1 amd64 :: Redmine...
2. Help: uninitialized constant Redmine::WikiFormatting::Com...

The exception raised in both the reports is "uninitialized constant Redmine::WikiFormatting::CommonMark::HTML (NameError)".
It gets triggered by source:/tags/5.0.2/lib/redmine/wiki_formatting/common_mark/external_links_filter.rb#L27.

I don't know if this can be reproduced and if so how, but I thought that given that it is the same exception in both the reports, it might be something that has to be investigated and fixed if necessary.


Files

37394.patch (730 Bytes) 37394.patch Go MAEDA, 2025-04-23 11:42
37394-v2.patch (52.1 KB) 37394-v2.patch Go MAEDA, 2025-04-27 10:03
Actions #1

Updated by Azamat Hackimov almost 3 years ago

I think problem is that in Gemfile common_mark group described as optional, but really it can't be disabled, so effectively you have to install all gems for common_mark group in order to launch Redmine 5.

Actions #2

Updated by Joachim Mathes over 1 year ago

I can confirm that behavior.

My local development environment works fine. But when I try to run Redmine in a bitnami/ruby container, it fails with a corresponding error regarding a plugin. Even when I remove all plugins Redmine fails with
/lib/redmine/wiki_formatting/markdown/formatter.rb:25:in `<module:Markdown>': uninitialized constant Redmine::WikiFormatting::Markdown::Redcarpet (NameError)                                              

despite
  • the same Redmine version 5.1.1
  • the same Ruby version 3.2.2
  • the same bundler version 2.4.19
  • the same run command bundle exec rails server --environment=development
  • the same Gemfile.lock and thus the same gem versions.
    • e.g. Rails 6.1.7.6

Any help is appreciated.

Edit (08.01.2024)

I found the error(s) and fixed them. But first of all I would like to share, that running

bundle exec rails zeitwerk:check

helped a lot to check if the error still exists.

Now let's have a look at the fixes
  1. Obviously uninitialized constant Redmine::WikiFormatting::Markdown::Redcarpet (NameError) is related to Markdown. But our Dockerfile excluded markdown:
    BUNDLE_WITHOUT=...:markdown:.... Thus, removing markdown from the exclude list fixed the error.
  2. But I still had another issue with a RedmineUP plugin: redmine_contacts
    NameError: uninitialized constant CalendarsHelper (NameError)
    
            Object.const_get(camel_cased_word)
                  ^^^^^^^^^^
    Did you mean?  CalendarsController
    /app/plugins/redmine_contacts/app/controllers/deals_controller.rb:50:in `<class:DealsController>'
      

    Well, that one could actually be fixed easily by updating from version 4.3.7 to version 4.3.8. What you must know is, that redmine_contacts is named redmine_crm on RedmineUp's download page.
Actions #3

Updated by Go MAEDA 8 days ago

  • File 37394.patch 37394.patch added
  • Category changed from Text formatting to Gems support
  • Target version set to 6.1.0

As already pointed out in this issue, Redmine fails to start if the commonmarker gem is not installed. Although the gem is currently marked as optional in the Gemfile, it is in fact required for Redmine to run properly. Therefore, labeling `commonmarker` as optional is misleading and inappropriate.

The reason it may have been marked as optional originally could be that Markdown support, based on the `redcarpet` gem, was introduced in Redmine 2.5.0 as experimental (#15520), and redcarpet did not work on JRuby. However, Redmine no longer supports JRuby.

Furthermore, since Redmine 5.1.0, the default text formatting has been changed to CommonMark Markdown (#34863), which depends on the `commonmarker` gem. Given this, treating `commonmarker` as optional is no longer suitable.

The attached patch updates the Gemfile to reflect that commonmarker is a required dependency.

Actions #4

Updated by Go MAEDA 4 days ago

I have updated the patch. This version removes all Object.const_defined?(:Commonmarker) checks because the CommonMarker gem is now mandatory.

Actions

Also available in: Atom PDF