Project

General

Profile

Actions

Defect #37249

closed

Missing rexml gem causes errors in PUT - Adding the gem manually everything works

Added by Bubi = almost 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Category:
Gems support
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Here the part of the log

App 19843 output: [599f0f62-257a-49a9-bf49-2d9cd67a9566] Started POST "/issues.xml?key=hidden" for hidden at 2022-06-14 14:47:42 +0000
App 19843 output: You don't have rexml installed in your application. Please add it to your Gemfile and run bundle install
App 19843 output: [599f0f62-257a-49a9-bf49-2d9cd67a9566] LoadError (cannot load such file -- rexml/document):
App 19843 output: [599f0f62-257a-49a9-bf49-2d9cd67a9566] zeitwerk (2.6.0) lib/zeitwerk/kernel.rb:35:in `require'

Related issues

Related to Redmine - Feature #34992: Ruby 3.0 supportClosedGo MAEDA

Actions
Related to Redmine - Patch #37258: Switch default backend of ActiveSupport::XmlMini from rexml to NokogiriClosedMarius BĂLTEANU

Actions
Actions #1

Updated by Holger Just almost 2 years ago

  • Status changed from New to Confirmed

rexml used to be a a requirement of Rails as it is used as the default backend of ActiveSupport::XmlMini. This backend is used e.g. when parsing XML payloads of API requests.

In Rails 6.1 the dependency to rexml was removed but the default backend specification still remains.

In Ruby <= 2.7, the rexml library was included in the Ruby standard library. As such, it was still present and available even when not directly required. Starting with Ruby 3.0 however, rexml was converted into a bundled gem. As such, it is necessary to define it as a dependency in bundler (either explicitly or transitive via other dependencies). Now, if Redmine is installed with its test group (which is the default), rexml is installed as transitive dependency to rubocop and is thus available.

However, if bundler is configured with

bundle config --without test

on Ruby >= 3.0, rexml is not installed and is hidden by bundler, even if it's present as a bundled gem in Ruby. This results in ActiveSupport::XmlMini trying to load rexml fir its default backkend and failing.

We have two ways to resolve this:

  1. we could add a strict rexml dependency to the Gemfile, effectively re-introducing the previous rails dependency:
    gem "rexml", require: false
  2. Alternatively, we could switch to a different backend. As Redmine already depends on nokogiri, we could thus switch the XmlMini backend to nokogiri in an initializer, e.g. config/initializers/30-redmine.rb:
    ActiveSupport::XmlMini.backend = 'Nokogiri'

    This likely has the added benefit of (much) faster XML parsing and generation.
Actions #2

Updated by Go MAEDA almost 2 years ago

Holger Just wrote:

  1. we could add a strict rexml dependency to the Gemfile, effectively re-introducing the previous rails dependency:
    [...]
  2. Alternatively, we could switch to a different backend. As Redmine already depends on nokogiri, we could thus switch the XmlMini backend to nokogiri in an initializer, e.g. config/initializers/30-redmine.rb:
    [...]
    This likely has the added benefit of (much) faster XML parsing and generation.

I would prefer the first approach. This is because the fix should be backported to 5.0-stable branch and delivered in 5.0.2, but I think switching a backend to Nokogiri is a somewhat big change for the maintenance release.

Actions #3

Updated by Go MAEDA almost 2 years ago

  • Target version set to 5.0.2
Actions #4

Updated by Go MAEDA almost 2 years ago

Actions #5

Updated by Holger Just almost 2 years ago

Go MAEDA wrote:

I would prefer the first approach. This is because the fix should be backported to 5.0-stable branch and delivered in 5.0.2, but I think switching a backend to Nokogiri is a somewhat big change for the maintenance release.

In that case, I would be in favor of adding the rexml gem as a dependency for Ruby >= 3.0 on 5.0-stable only, i.e. to add the following patch in 5.0-stable:

diff --git a/Gemfile b/Gemfile
index cf7a8d78fa..29d639b9a7 100644
--- a/Gemfile
+++ b/Gemfile
@@ -14,6 +14,7 @@ gem 'marcel'
 gem "mail", "~> 2.7.1" 
 gem 'csv', '~> 3.2.0'
 gem 'nokogiri', (Gem.ruby_version < Gem::Version.new('2.6.0') ? '~> 1.12.5' : '~> 1.13.4')
+gem "rexml", require: false if Gem.ruby_version >= Gem::Version.new('3.0')
 gem 'i18n', '~> 1.10.0'
 gem "rbpdf", "~> 1.20.0" 
 gem 'addressable'

For trunk, we should instead opt to set the XmlMini backend to "Nokogiri" and get rid of rexml entirely. This avoids the usage of multiple different XML engines and the associated potential security issues due to different update-policies here.

Actions #6

Updated by Marius BĂLTEANU almost 2 years ago

  • Status changed from Confirmed to Resolved
  • Assignee set to Marius BĂLTEANU
  • Resolution set to Fixed

Thanks for reporting and fixing the issue. I've fixed this in trunk and 5.0-stable by requiring the gem.

Holger, I'm going to open a new issue to handle Nokogiri backend for 5.1.0.

Actions #7

Updated by Marius BĂLTEANU almost 2 years ago

  • Precedes Patch #37258: Switch default backend of ActiveSupport::XmlMini from rexml to Nokogiri added
Actions #8

Updated by Marius BĂLTEANU almost 2 years ago

  • Precedes deleted (Patch #37258: Switch default backend of ActiveSupport::XmlMini from rexml to Nokogiri)
Actions #9

Updated by Marius BĂLTEANU almost 2 years ago

  • Related to Patch #37258: Switch default backend of ActiveSupport::XmlMini from rexml to Nokogiri added
Actions #10

Updated by Marius BĂLTEANU almost 2 years ago

  • Status changed from Resolved to Closed

I've opened #37258.

Actions #11

Updated by Marius BĂLTEANU almost 2 years ago

  • Category changed from REST API to Gems support
Actions

Also available in: Atom PDF