Skip to content

v6.0.0: Auth0::Client.new raises NameError: uninitialized constant Auth0::VERSION (entrypoint never requires auth0/version) #786

Description

@Spence1115

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_headersInitializer#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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions