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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.2.1 warning: already initialized constant JWT Error #335

Closed
jychen7 opened this issue Oct 7, 2019 · 0 comments · Fixed by #357
Closed

v2.2.1 warning: already initialized constant JWT Error #335

jychen7 opened this issue Oct 7, 2019 · 0 comments · Fixed by #357
Assignees
Labels
Milestone

Comments

@jychen7
Copy link

jychen7 commented Oct 7, 2019

Background

when we upgrade from 2.1.0 to 2.2.1, we receive a lot of warnings about "already initialized constant JWT Error" when start rails or simply run rails c
all errors inside this are shown

module JWT
EncodeError = Class.new(StandardError)
DecodeError = Class.new(StandardError)
RequiredDependencyError = Class.new(StandardError)
VerificationError = Class.new(DecodeError)
ExpiredSignature = Class.new(DecodeError)
IncorrectAlgorithm = Class.new(DecodeError)
ImmatureSignature = Class.new(DecodeError)
InvalidIssuerError = Class.new(DecodeError)
InvalidIatError = Class.new(DecodeError)
InvalidAudError = Class.new(DecodeError)
InvalidSubError = Class.new(DecodeError)
InvalidJtiError = Class.new(DecodeError)
InvalidPayload = Class.new(DecodeError)
JWKError = Class.new(DecodeError)
end

I think it is related to use first-class object short hand
c0b4c59
and

require 'jwt/error'

require_relative './error'

Expect

git checkout v2.1.0

irb
2.4.0 :001 > require 'jwt/error'
 => true
2.4.0 :002 > require_relative './lib/jwt/error'
 => true

Actual

git checkout v2.2.1

irb
2.4.0 :001 > require 'jwt/error'
 => true
2.4.0 :002 > require_relative './lib/jwt/error'
~/Documents/github/ruby-jwt/lib/jwt/error.rb:5: warning: already initialized constant JWT::DecodeError
~/.rvm/gems/ruby-2.4.0/gems/jwt-1.5.6/lib/jwt/error.rb:3: warning: previous definition of DecodeError was here
~/Documents/github/ruby-jwt/lib/jwt/error.rb:8: warning: already initialized constant JWT::VerificationError
~/.rvm/gems/ruby-2.4.0/gems/jwt-1.5.6/lib/jwt/error.rb:4: warning: previous definition of VerificationError was here
~/Documents/github/ruby-jwt/lib/jwt/error.rb:9: warning: already initialized constant JWT::ExpiredSignature
~/.rvm/gems/ruby-2.4.0/gems/jwt-1.5.6/lib/jwt/error.rb:5: warning: previous definition of ExpiredSignature was here
~/Documents/github/ruby-jwt/lib/jwt/error.rb:10: warning: already initialized constant JWT::IncorrectAlgorithm
~/.rvm/gems/ruby-2.4.0/gems/jwt-1.5.6/lib/jwt/error.rb:6: warning: previous definition of IncorrectAlgorithm was here
~/Documents/github/ruby-jwt/lib/jwt/error.rb:11: warning: already initialized constant JWT::ImmatureSignature
~/.rvm/gems/ruby-2.4.0/gems/jwt-1.5.6/lib/jwt/error.rb:7: warning: previous definition of ImmatureSignature was here
~/Documents/github/ruby-jwt/lib/jwt/error.rb:12: warning: already initialized constant JWT::InvalidIssuerError
~/.rvm/gems/ruby-2.4.0/gems/jwt-1.5.6/lib/jwt/error.rb:8: warning: previous definition of InvalidIssuerError was here
~/Documents/github/ruby-jwt/lib/jwt/error.rb:13: warning: already initialized constant JWT::InvalidIatError
~/.rvm/gems/ruby-2.4.0/gems/jwt-1.5.6/lib/jwt/error.rb:9: warning: previous definition of InvalidIatError was here
~/Documents/github/ruby-jwt/lib/jwt/error.rb:14: warning: already initialized constant JWT::InvalidAudError
~/.rvm/gems/ruby-2.4.0/gems/jwt-1.5.6/lib/jwt/error.rb:10: warning: previous definition of InvalidAudError was here
~/Documents/github/ruby-jwt/lib/jwt/error.rb:15: warning: already initialized constant JWT::InvalidSubError
~/.rvm/gems/ruby-2.4.0/gems/jwt-1.5.6/lib/jwt/error.rb:11: warning: previous definition of InvalidSubError was here
~/Documents/github/ruby-jwt/lib/jwt/error.rb:16: warning: already initialized constant JWT::InvalidJtiError
~/.rvm/gems/ruby-2.4.0/gems/jwt-1.5.6/lib/jwt/error.rb:12: warning: previous definition of InvalidJtiError was here
~/Documents/github/ruby-jwt/lib/jwt/error.rb:17: warning: already initialized constant JWT::InvalidPayload
~/.rvm/gems/ruby-2.4.0/gems/jwt-1.5.6/lib/jwt/error.rb:13: warning: previous definition of InvalidPayload was here
 => true
@jychen7 jychen7 changed the title warning: already initialized constant JWT Error v2.2.1 warning: already initialized constant JWT Error Oct 7, 2019
@excpt excpt added this to the Version 2.2.2 milestone Jul 6, 2020
@excpt excpt added the bug label Jul 6, 2020
@excpt excpt self-assigned this Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants