Project

General

Profile

Installation plugins to Redmine 5.0.0 get problem "... /zeitwerk/kernel.rb:35:in `require': cannot load such file.."

Added by HC lee over 2 years ago

Installation plugins to Redmine 5.0.0 to get "Failed" as the following list:

redmine_questions 1.0.2 Failed
redmineup_tags 2.0.11 Failed
redmine_agile 1.6.3 Done (1.6.2 Failed)
redmine_dmsf 2.4.11 Failed
redmine_resources 1.0.6 Failed
redmine_drawio 1.3.0 Failed
redmine_subproject_collapse 0.0.1 Failed
advanced_roadmap 0.12.0 Failed
local_avatars 0.1.1 Failed

common messages as below:

.....

1: from /var/lib/gems/2.7.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
/var/lib/gems/2.7.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require': cannot load such file -- dispatcher (LoadError)

......

Attached log for details: Redmine-InstallPluginsError_5.0.0.txt

Environment:
Redmine version 5.0.0.stable
Ruby version 2.7.0-p0 (2019-12-25) [x86_64-linux-gnu]
Rails version 6.1.4.7
Environment production
Database adapter Mysql2
Mailer queue ActiveJob::QueueAdapters::AsyncAdapter
Mailer delivery smtp
Redmine settings:
Redmine theme Default
SCM:
Git 2.25.1
Filesystem

Thank you.


Replies (9)

RE: Installation plugins to Redmine 5.0.0 get problem "... /zeitwerk/kernel.rb:35:in `require': cannot load such file.." - Added by Renaud GOSSE over 2 years ago

Hello
this is linked to the redmine up plugins.

Please see support with them. I was able to make a redmine 5 test with only the agile plugin from their store, I had to deactivate the others (they're working on updates).

RE: Installation plugins to Redmine 5.0.0 get problem "... /zeitwerk/kernel.rb:35:in `require': cannot load such file.." - Added by Vitaliy Vasilev over 2 years ago

Take a look at "/issues/36519" (for some reason direct link cause redmine Internal Error).

I could fix same problem by replacing require with manually created path.

# old
require 'module'

# new one
require File.expand_path('../lib/module', FILE)

Not a pretty solution, but working!

RE: Installation plugins to Redmine 5.0.0 get problem "... /zeitwerk/kernel.rb:35:in `require': cannot load such file.." - Added by fabrice salvaire over 2 years ago

I have a similar issue with another plugin, but I got this with your change :

! Unable to load application: NameError: uninitialized constant FILE
Did you mean?  File
.../redmine-5.0.0/plugins/redmine_wiki_backlinks/init.rb:3:in `<top (required)>': uninitialized constant FILE (NameError)

Looks like some symbols are undefined.

Note: I am not a Ruby dev.

RE: Installation plugins to Redmine 5.0.0 get problem "... /zeitwerk/kernel.rb:35:in `require': cannot load such file.." - Added by Fletcher Johnston over 2 years ago

The change has to be made in the init.rb file for the plugin.
Note that the markup is `__FILE__` (remove ticks; otherwise markdup picks them up)

RE: Installation plugins to Redmine 5.0.0 get problem "... /zeitwerk/kernel.rb:35:in `require': cannot load such file.." - Added by Fletcher Johnston over 2 years ago

A bit more detail here. I pulled the first two examples from the redmine_wysiwyg_editor plugin's GIT repo.
It seems that a lot of plugins used to do something like this:

require_dependency 'redmine_wysiwyg_editor'

However, because of the change to Rails 6 (I think) you now need to do something like this:

require File.expand_path('lib/redmine_wysiwyg_editor', __dir__)

OR

require File.dirname(__FILE__) + '/lib/issues_controller_patch.rb'

I have also found that the switch to zeitwerk has broken many plugins, and even after making the above changes in the init.rb file, other changes are necessary within the plugin modules and classes.

Lots of work re-writing/updating plugins in the next little while...

RE: Installation plugins to Redmine 5.0.0 get problem "... /zeitwerk/kernel.rb:35:in `require': cannot load such file.." - Added by Oded Arbel over 2 years ago

I'm also having this issue after upgrade to Redmine 5.

As far as I understand, this code in plugin_loader.rb (https://github.com/redmine/redmine/blob/master/lib/redmine/plugin_loader.rb#L128) is supposed to caused the plugin's lib directory to be added to the load path, but this does not seem to work anymore.

The workaround for all plugin authors to manually update the Ruby global load path doesn't seem untenable - I have > 20 plugins installed in my Redmine, for which I have an auto update system, and getting all other authors (some haven't touched that plugin's source code in years) is going to be a problem.

My current workaround is to add

$:.unshift "#{engine_cfg.paths.path}/lib"

in line 128 of plugin_loader.rb, but this is also an ugly hack.

RE: Installation plugins to Redmine 5.0.0 get problem "... /zeitwerk/kernel.rb:35:in `require': cannot load such file.." - Added by Dimitar (RedmineUP) about 2 years ago

Hi Mr. Lee,

This is Dimitar from the RedmineUP Support Team.

I see that you have some of our plugins on your list:

> redmine_questions        1.0.2    Failed
> redmineup_tags            2.0.11    Failed
> redmine_agile            1.6.3    Done    (1.6.2 Failed)
> redmine_resources        1.0.6    Failed

So, could you please contact our support team at ? And our support engineers will help you investigate the situation and solve the problems.

We look forward to hearing from you.

Best Regards,
Dimitar from the RedmineUP Support Team

HC lee wrote:

Installation plugins to Redmine 5.0.0 to get "Failed" as the following list:

redmine_questions 1.0.2 Failed
redmineup_tags 2.0.11 Failed
redmine_agile 1.6.3 Done (1.6.2 Failed)
redmine_dmsf 2.4.11 Failed
redmine_resources 1.0.6 Failed
redmine_drawio 1.3.0 Failed
redmine_subproject_collapse 0.0.1 Failed
advanced_roadmap 0.12.0 Failed
local_avatars 0.1.1 Failed

common messages as below:

.....

1: from /var/lib/gems/2.7.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
/var/lib/gems/2.7.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require': cannot load such file -- dispatcher (LoadError)

......

Attached log for details: Redmine-InstallPluginsError_5.0.0.txt

Environment:
Redmine version 5.0.0.stable
Ruby version 2.7.0-p0 (2019-12-25) [x86_64-linux-gnu]
Rails version 6.1.4.7
Environment production
Database adapter Mysql2
Mailer queue ActiveJob::QueueAdapters::AsyncAdapter
Mailer delivery smtp
Redmine settings:
Redmine theme Default
SCM:
Git 2.25.1
Filesystem

Thank you.

RE: Installation plugins to Redmine 5.0.0 get problem "... /zeitwerk/kernel.rb:35:in `require': cannot load such file.." - Added by OMP System DevOps over 1 year ago

Hi. Looks like Rails version specific. In redmine_dark plugin that our company use I found this:

def init_redmine_dark
  require_dependency Rails.root + "plugins/redmine_dark/lib/dark_application_hooks.rb" 
end

if Rails::VERSION::MAJOR >= 6
  Rails.application.config.after_initialize do
    init_redmine_dark
  end
elsif Rails::VERSION::MAJOR >= 5
  ActiveSupport::Reloader.to_prepare do
    init_redmine_dark
  end
elsif Rails::VERSION::MAJOR >= 3
  ActionDispatch::Callbacks.to_prepare do
    init_redmine_dark
  end
else
  Dispatcher.to_prepare :redmine_tags do
    init_redmine_dark
  end
end
    (1-9/9)