maxrossello / redmine_extended_watchers

Grant additional issue and project view permissions to watcher users
GNU General Public License v3.0
44 stars 20 forks source link

Error "Cannot define multiple 'included' blocks for a Concern" #45

Closed RolfWojtech closed 1 year ago

RolfWojtech commented 1 year ago

Thanks for creating this lovely plugin. As I reported in the closed ticket, I see the following error when I add redmine_extended_watchers.

OS Debian 11 x64 rails 6.1.7 ruby 2.7.4p191 redmine 5.0.4 Branch 5.0-extended_watchers (equal to release 5.0.2)

On Debian 11 with the gems installed globally via bundle install, I get this error as long as your redmine_extended_watchers is included in the plugin directry: user@redminebox:/srv/somedir/redmine$ bundle exec rake redmine:plugins:migrate RAILS_ENV=production rake aborted! ActiveSupport::Concern::MultipleIncludedBlocks: Cannot define multiple 'included' blocks for a Concern /var/lib/gems/2.7.0/gems/activesupport-6.1.7/lib/active_support/concern.rb:160:inincluded' /srv/somedir/redmine_extended_watchers/lib/extended_watchers_issue_patch.rb:170:in ' /srv/somedir/redmine_extended_watchers/lib/extended_watchers_issue_patch.rb:166:in module:ExtendedWatchersIssuePatch' /srv/somedir/redmine_extended_watchers/lib/extended_watchers_issue_patch.rb:28:in <top (required)>' /srv/somedir/redmine/plugins/redmine_extended_watchers/init.rb:22:in require_relative' /srv/somedir/redmine/plugins/redmine_extended_watchers/init.rb:22:in <top (required)>' /srv/somedir/redmine/lib/redmine/plugin_loader.rb:31:in load' /srv/somedir/redmine/lib/redmine/plugin_loader.rb:31:in run_initializer' /srv/somedir/redmine/lib/redmine/plugin_loader.rb:108:in each' /srv/somedir/redmine/lib/redmine/plugin_loader.rb:108:in block in load' /var/lib/gems/2.7.0/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:427:in instance_exec' /var/lib/gems/2.7.0/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:427:in block in make_lambda' /var/lib/gems/2.7.0/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:198:in block (2 levels) in halting' /var/lib/gems/2.7.0/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:604:in block (2 levels) in default_terminator' /var/lib/gems/2.7.0/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:603:in catch' /var/lib/gems/2.7.0/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:603:in block in default_terminator' /var/lib/gems/2.7.0/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:199:in block in halting' /var/lib/gems/2.7.0/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:512:in block in invoke_before' /var/lib/gems/2.7.0/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:512:in each' /var/lib/gems/2.7.0/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:512:in invoke_before' /var/lib/gems/2.7.0/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:105:in run_callbacks' /var/lib/gems/2.7.0/gems/activesupport-6.1.7/lib/active_support/reloader.rb:88:in prepare!' /var/lib/gems/2.7.0/gems/railties-6.1.7/lib/rails/application/finisher.rb:124:in block in module:Finisher' /var/lib/gems/2.7.0/gems/railties-6.1.7/lib/rails/initializable.rb:32:in instance_exec' /var/lib/gems/2.7.0/gems/railties-6.1.7/lib/rails/initializable.rb:32:in run' /var/lib/gems/2.7.0/gems/railties-6.1.7/lib/rails/initializable.rb:61:in block in run_initializers' /var/lib/gems/2.7.0/gems/railties-6.1.7/lib/rails/initializable.rb:60:in run_initializers' /var/lib/gems/2.7.0/gems/railties-6.1.7/lib/rails/application.rb:391:in initialize!' /srv/somedir/redmine/config/environment.rb:16:in <top (required)>' /var/lib/gems/2.7.0/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in require' /var/lib/gems/2.7.0/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in require' /var/lib/gems/2.7.0/gems/activesupport-6.1.7/lib/active_support/dependencies.rb:332:in block in require' /var/lib/gems/2.7.0/gems/activesupport-6.1.7/lib/active_support/dependencies.rb:299:in load_dependency' /var/lib/gems/2.7.0/gems/activesupport-6.1.7/lib/active_support/dependencies.rb:332:in require' /var/lib/gems/2.7.0/gems/railties-6.1.7/lib/rails/application.rb:367:in require_environment!' /var/lib/gems/2.7.0/gems/railties-6.1.7/lib/rails/application.rb:533:in block in run_tasks_blocks' /var/lib/gems/2.7.0/gems/rake-13.0.6/exe/rake:27:in <top (required)>' Tasks: TOP => redmine:plugins:migrate => environment (See full trace by running task with --trace) ` RAILS_ENV=production bundle exec bin/rails runner 'p Rails.autoloaders.zeitwerk_enabled?' results in basically the same error.

After I unlink redmine_extended_watchers from the plugins directory, the same command RAILS_ENV=production bundle exec bin/rails runner 'p Rails.autoloaders.zeitwerk_enabled?' returns "true"

maxrossello commented 1 year ago

Have you tried to bundle update?

RolfWojtech commented 1 year ago

I just tried to reproduce it on a fresh installation using the instructions from https://kifarunix.com/install-redmine-with-mariadb-on-debian-10-buster/ (roughly) with only redmine_extended_watchers and that does work. So it must be something specific to my installation (other plugins are installed there). I will look into it further and report my findings.

maxrossello commented 1 year ago

Great, thank you

RolfWojtech commented 1 year ago

I removed all other plugins and the issue remains. So it must have something to do with the gems on the two systems (or something else I have not yet accounted for). Not sure when I will have time for further research, but I wanted to give you this semi-update anyways and I will report if I can narrow it down further.

maxrossello commented 1 year ago

Some people say that the issue may be caused by using require_relative in init.rb, which is needed because of redmine/lib/plugin_loader.rb not adding the plugin paths to the zeitwerk autoloader in a proper way.

So it is possible that in 5.0.5 the issue might be mitigated thanks to this fix and removing the require_relative's.

RolfWojtech commented 1 year ago

I picked this up again now that 5.0.5 is out. While 5.0.5 made no difference, I figured out the issue: In my installation, I symlink the plugins into the redmine/plugins folder in order to make it easier to change or remove them. When I moved the plugin directly into the plugins folder, it worked.

I have also reproduced this on a new minimal install of just 5.0.4 with just redmine_extended_watchers as a symlinked plugin, that also fails.

Since using symlinks is not exactly standard use, we can probably close here.