lostisland/faraday-net_http

Duplicate require warnings on Ruby 2.7.5

jaco-terbraak opened this issue · 1 comments

When I run an application which includes this gem, I get the following:

/Users/xxx/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/net/protocol.rb:66: warning: already initialized constant Net::ProtocRetryError
/Users/xxx/.rvm/gems/ruby-2.7.5/gems/net-protocol-0.1.3/lib/net/protocol.rb:68: warning: previous definition of ProtocRetryError was here
/Users/xxx/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/net/protocol.rb:206: warning: already initialized constant Net::BufferedIO::BUFSIZE
/Users/xxx/.rvm/gems/ruby-2.7.5/gems/net-protocol-0.1.3/lib/net/protocol.rb:208: warning: previous definition of BUFSIZE was here
/Users/xxx/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/net/protocol.rb:503: warning: already initialized constant Net::NetPrivate::Socket
/Users/xxx/.rvm/gems/ruby-2.7.5/gems/net-protocol-0.1.3/lib/net/protocol.rb:504: warning: previous definition of Socket was here

After some debugging I have been able to trace it to faraday-net_http:

	 7: from /Users/xxx/.rvm/gems/ruby-2.7.5/gems/faraday-net_http-2.0.3/lib/faraday/adapter/net_http.rb:4:in `require'
	 6: from /Users/xxx/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/net/https.rb:22:in `<top (required)>'
	 5: from /Users/xxx/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/net/https.rb:22:in `require_relative'
	 4: from /Users/xxx/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/net/http.rb:23:in `<top (required)>'
	 3: from /Users/xxx/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/net/http.rb:23:in `require_relative'
	 2: from /Users/xxx/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/net/protocol.rb:26:in `<top (required)>'
	 1: from /Users/xxx/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/net/protocol.rb:66:in `<module:Net>'

From what I understand is that Ruby 3.0 moves these dependencies from the standard lib into gems, and a such we need to require them. However Ruby 2.7 still has them in the standard lib, and thus we see the duplicate require.

@jaco-terbraak This is a known issue, but it's not directly caused by Faraday.
Please check this comment