Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix already initialized constant Account::VerificationKey warning #1

Closed
bkuhlmann opened this issue Apr 25, 2023 · 2 comments
Closed

Comments

@bkuhlmann
Copy link

bkuhlmann commented Apr 25, 2023

Overview

Hello. 馃憢 I'm experiencing an issue where I'm seeing a bunch of warnings in my console (dev and test) when using Rodauth in my Rails app:

/Users/bkuhlmann/.cache/frum/versions/3.1.3/lib/ruby/gems/3.1.0/gems/rodauth-model-0.2.1/lib/rodauth/model/active_record.rb:69: warning: already initialized constant Account::VerificationKey
/Users/bkuhlmann/.cache/frum/versions/3.1.3/lib/ruby/gems/3.1.0/gems/rodauth-model-0.2.1/lib/rodauth/model/active_record.rb:69: warning: previous definition of VerificationKey was here
/Users/bkuhlmann/.cache/frum/versions/3.1.3/lib/ruby/gems/3.1.0/gems/rodauth-model-0.2.1/lib/rodauth/model/active_record.rb:69: warning: already initialized constant Account::RememberKey
/Users/bkuhlmann/.cache/frum/versions/3.1.3/lib/ruby/gems/3.1.0/gems/rodauth-model-0.2.1/lib/rodauth/model/active_record.rb:69: warning: previous definition of RememberKey was here
/Users/bkuhlmann/.cache/frum/versions/3.1.3/lib/ruby/gems/3.1.0/gems/rodauth-model-0.2.1/lib/rodauth/model/active_record.rb:69: warning: already initialized constant Account::PasswordResetKey
/Users/bkuhlmann/.cache/frum/versions/3.1.3/lib/ruby/gems/3.1.0/gems/rodauth-model-0.2.1/lib/rodauth/model/active_record.rb:69: warning: previous definition of PasswordResetKey was here
/Users/bkuhlmann/.cache/frum/versions/3.1.3/lib/ruby/gems/3.1.0/gems/rodauth-model-0.2.1/lib/rodauth/model/active_record.rb:69: warning: already initialized constant Account::LoginChangeKey
/Users/bkuhlmann/.cache/frum/versions/3.1.3/lib/ruby/gems/3.1.0/gems/rodauth-model-0.2.1/lib/rodauth/model/active_record.rb:69: warning: previous definition of LoginChangeKey was here

Steps to Recreate

I'm afraid I don't have a quick way to reproduce this for you in an isolated environment but can try to do that if it'd help. I mostly wanted to report this in case you weren't aware. As a workaround, I can use the excellent Warning gem to workaround these issues.

Environment

  • Ruby: ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [arm64-darwin22.4.0]
  • Rails: 7.0.4
  • Rodauth: 2.29.0
@janko
Copy link
Owner

janko commented Apr 25, 2023

Thanks for reporting. The only way I can see this happening is if your Account model is being loaded twice, which is likely to cause other issues/warnings anyway. I suggest you try to figure out why/if your model is being loaded multiple times.

Does it happen during code reloading, i.e. when you change files in your project? I know Zeitwerk is supposed to unload the Account constant before loading the file again, so this problem shouldn't appear. I couldn't reproduce this warning on the demo app.

@bkuhlmann
Copy link
Author

Hey Janko, thanks. 馃檱 I'm finding this hard to track down at the moment so believe this issue is more obscure than I realized. I think you are right that there is something I'm not seeing in the application which is causing this to happen. I'm going to close this issue since there is no reason to hold you up on this. If I am able to detect the root cause -- and it's actionable -- I can reopen this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants