Describe the problem
In 6.0.0, constructing any client raises NameError: uninitialized constant Auth0::VERSION. The gem's entrypoint lib/auth0.rb never requires auth0/version, but Auth0::Mixins::Headers#telemetry (and Auth0::Internal::Http::RawClient) reference Auth0::VERSION while building the request headers during client construction.
Because it fires in #telemetry → #client_headers → Initializer#initialize, it happens on every client instantiation, so the Management API is effectively unusable out of the box unless the consuming app happens to require "auth0/version" itself.
Reproduction
require "auth0"
Auth0::Client.new(domain: "example.auth0.com", token: "any-token")
Actual behaviour
NameError: uninitialized constant Auth0::VERSION
version: Auth0::VERSION,
^^^^^^^^^
lib/auth0/mixins/headers.rb:10:in 'Auth0::Mixins::Headers#telemetry'
lib/auth0/mixins/headers.rb:24:in 'Auth0::Mixins::Headers#telemetry_encoded'
lib/auth0/mixins/headers.rb:30:in 'Auth0::Mixins::Headers#client_headers'
lib/auth0/mixins/initializer.rb:15:in 'Auth0::Mixins::Initializer#initialize'
Adding require "auth0/version" before constructing the client makes it work, confirming the cause:
require "auth0"
require "auth0/version" # <- without this line, the constructor raises
Auth0::Client.new(domain: "example.auth0.com", token: "any-token") # OK
Expected behaviour
require "auth0" should make Auth0::VERSION available, so constructing a client does not raise.
Root cause / suggested fix
lib/auth0.rb requires the internal modules, types, errors, auth0/client, etc., but has no require_relative "auth0/version". Neither lib/auth0/mixins.rb nor lib/auth0/mixins/headers.rb require it either, yet headers.rb:10 uses the constant. Adding require_relative "auth0/version" to lib/auth0.rb (or to mixins/headers.rb) resolves it.
Environment
- auth0 gem:
6.0.0
- Ruby:
3.4.2
- Reproduced with a plain
require "auth0" (no framework), so it is not app/bootloader specific.
Describe the problem
In
6.0.0, constructing any client raisesNameError: uninitialized constant Auth0::VERSION. The gem's entrypointlib/auth0.rbnever requiresauth0/version, butAuth0::Mixins::Headers#telemetry(andAuth0::Internal::Http::RawClient) referenceAuth0::VERSIONwhile building the request headers during client construction.Because it fires in
#telemetry→#client_headers→Initializer#initialize, it happens on every client instantiation, so the Management API is effectively unusable out of the box unless the consuming app happens torequire "auth0/version"itself.Reproduction
Actual behaviour
Adding
require "auth0/version"before constructing the client makes it work, confirming the cause:Expected behaviour
require "auth0"should makeAuth0::VERSIONavailable, so constructing a client does not raise.Root cause / suggested fix
lib/auth0.rbrequires the internal modules, types, errors,auth0/client, etc., but has norequire_relative "auth0/version". Neitherlib/auth0/mixins.rbnorlib/auth0/mixins/headers.rbrequire it either, yetheaders.rb:10uses the constant. Addingrequire_relative "auth0/version"tolib/auth0.rb(or tomixins/headers.rb) resolves it.Environment
6.0.03.4.2require "auth0"(no framework), so it is not app/bootloader specific.