cedarcode / webauthn-ruby

WebAuthn ruby server library ― Make your Ruby/Rails web server become a conformant WebAuthn Relying Party
https://rubygems.org/gems/webauthn
MIT License
644 stars 51 forks source link

Circular require warning in verbose mode #388

Closed jeremyevans closed 1 year ago

jeremyevans commented 1 year ago
$ ruby -w -r webauthn -e ''
<internal:/usr/local/lib/ruby/3.2/rubygems/core_ext/kernel_require.rb>:88: warning: <internal:/usr/local/lib/ruby/3.2/rubygems/core_ext/kernel_require.rb>:88: warning: loading in progress, circular require considered harmful - /usr/local/lib/ruby/gems/3.2/gems/webauthn-3.0.0/lib/webauthn/relying_party.rb
        from <internal:/usr/local/lib/ruby/3.2/rubygems/core_ext/kernel_require.rb>:152:in  `require'
        from <internal:/usr/local/lib/ruby/3.2/rubygems/core_ext/kernel_require.rb>:162:in  `rescue in require'
        from <internal:/usr/local/lib/ruby/3.2/rubygems/core_ext/kernel_require.rb>:162:in  `require'
        from /usr/local/lib/ruby/gems/3.2/gems/webauthn-3.0.0/lib/webauthn.rb:3:in  `<top (required)>'
        from <internal:/usr/local/lib/ruby/3.2/rubygems/core_ext/kernel_require.rb>:88:in  `require'
        from <internal:/usr/local/lib/ruby/3.2/rubygems/core_ext/kernel_require.rb>:88:in  `require'
        from /usr/local/lib/ruby/gems/3.2/gems/webauthn-3.0.0/lib/webauthn/configuration.rb:4:in  `<top (required)>'
        from <internal:/usr/local/lib/ruby/3.2/rubygems/core_ext/kernel_require.rb>:88:in  `require'
        from <internal:/usr/local/lib/ruby/3.2/rubygems/core_ext/kernel_require.rb>:88:in  `require'
        from /usr/local/lib/ruby/gems/3.2/gems/webauthn-3.0.0/lib/webauthn/relying_party.rb:4:in  `<top (required)>'
        from <internal:/usr/local/lib/ruby/3.2/rubygems/core_ext/kernel_require.rb>:88:in  `require'
        from <internal:/usr/local/lib/ruby/3.2/rubygems/core_ext/kernel_require.rb>:88:in  `require'
        from /usr/local/lib/ruby/gems/3.2/gems/webauthn-3.0.0/lib/webauthn/credential.rb:7:in  `<top (required)>'
        from <internal:/usr/local/lib/ruby/3.2/rubygems/core_ext/kernel_require.rb>:88:in  `require'
        from <internal:/usr/local/lib/ruby/3.2/rubygems/core_ext/kernel_require.rb>:88:in  `require'

webauthn/relying_party requires webauthn/credential requires webauthn/relying_party. If there is a true mutual dependency, and you want to allow users to require either independently, one option is to move the require calls to the end of the files, then guard them (e.g. require "webauthn/relying_party" unless defined?(Webauth::RelyingParty)). If you don't need to allow users to require each independently, then you can probably drop one of the requires.

On the plus side, congratulations on the 3.0.0 release! Works fine with Rodauth's webauthn feature, and allows the use of the default openssl gem in Ruby 3.1 and 3.2.