DEPRECATION WARNING: Initialization autoloaded the constant Mailkick::UrlHelper.
majksner opened this issue · comments
Hi @ankane
First for all thank you for the gem, I appreciate it. When running rails commands like rails console
or rails db:migrate
I'm getting deprecation warning. This might not be necessarily an issue with your gem. As soon as I remove your gem from Gemfile
and run bundle
then deprecation warning disappears. I'm also using the code below (as suggested here) in the initializer to detect from where the warning comes from. But I'm not getting any results. Any help appreciated.
ActiveSupport.on_load(:action_controller_base) do
bc = ActiveSupport::BacktraceCleaner.new
bc.remove_silencers!
bc.add_silencer { |line| line.start_with?(RbConfig::CONFIG['rubylibdir']) }
bc.add_silencer do |line|
line =~ Regexp.union(
*(
%w[bootsnap railties spring activesupport actionpack zeitwerk thor rack]
.map { |g| /\A#{g} \([\w.]+\) / }
),
%r{\Abin/rails}
)
end
trace = bc.clean(caller)
puts "Cleaned backtrace:\n\t#{trace.join("\n\t")}\n"
puts "Most probably the cause is: #{trace.first}"
puts "If not - uncomment `raise` at #{__FILE__}:#{__LINE__ + 1}"
# raise "i can haz full backtrace"
exit(1)
end
Hey @majksner, thanks for reporting. Does the warning go away if you comment out this line?
mailkick/lib/mailkick/engine.rb
Line 22 in 15e9079
@ankane There is no warning if I remove that line.
module Mailkick
class Engine < ::Rails::Engine
isolate_namespace Mailkick
+ require_relative '../../app/helpers/mailkick/url_helper'
initializer "mailkick" do |app|
Mailkick.discover_services unless Mailkick.services.any?
Mailkick.secret_token ||= begin
creds =
if app.respond_to?(:credentials) && app.credentials.secret_key_base
app.credentials
elsif app.respond_to?(:secrets)
app.secrets
else
app.config
end
creds.respond_to?(:secret_key_base) ? creds.secret_key_base : creds.secret_token
end
ActiveSupport.on_load :action_mailer do
helper Mailkick::UrlHelper
end
end
end
end
This also removes the warning.
Want me to send pull request?
Hey @majksner, can you give master a shot?
@ankane No warning anymore. Thanks!