Project

General

Profile

sidekiq do not find Mailer class (NameError: uninitialized constant Mailer)

Added by Mateusz Makowski about 2 months ago

Environment:
  Redmine version                5.1.3.stable
  Ruby version                   2.7.5-p203 (2021-11-24) [x86_64-linux-gnu]
  Rails version                  6.1.7.8
  Environment                    production
  Database adapter               Mysql2
  Mailer queue                   ActiveJob::QueueAdapters::SidekiqAdapter
  Mailer delivery                smtp
Redmine settings:
  Redmine theme                  Bleuclair (includes JavaScript)
SCM:
  Git                            2.46.2
  Filesystem                     
Redmine plugins:
  no plugin installed

I have added sidekiq web panel to redmine in config/routes.rb:

require 'sidekiq/web'

Rails.application.routes.draw do
  root :to => 'welcome#index', :as => 'home'

  mount Sidekiq::Web => '/sideki

There i can see such logs:

Next Retry Retry Count Queue Job Arguments Error
za 2 dni 23 mailers Mailer#issue_add {"_aj_globalid"=>"gid://redmine-app/User/10"}, {"_aj_globalid"=>"gid://redmine-app/Issue/14256"} NameError: uninitialized constant Mailer
# config/additional_environment.rb
config.active_job.queue_adapter = :sidekiq
#/etc/systemd/system/sidekiq.service
[Unit]
Description=Sidekiq Background Job Processor
After=network.target

[Service]
Type=simple
User=redmine
WorkingDirectory=/opt/redmine/www
ExecStart=/usr/local/bin/bundle exec sidekiq -e production --logfile /opt/redmine/www/log/sidekiq.log
Restart=always

[Install]
WantedBy=multi-user.target

I found that someone previously had a similar problem, and changing the config.eager_load parameter to true in the config/environments/production.rb file helped. Unfortunately it didn't work for me.

sidekiq version:

# Gemfile.local
gem 'sidekiq', '~> 6.4'

Any idew what i can do?

$ uname -a
Linux redmine 5.15.0-94-generic #104-Ubuntu SMP Tue Jan 9 15:25:40 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/issue.net 
Ubuntu 22.04.5 LTS