Warning: already initialized constant
Using Ruby 2.7.5 and Rails 7.0.2.2, when I have version 0.1.2 installed, every rake or rails task drops these warnings:
/usr/local/lib/ruby/2.7.0/net/protocol.rb:66: warning: already initialized constant Net::ProtocRetryError
/usr/local/bundle/gems/net-protocol-0.1.2/lib/net/protocol.rb:68: warning: previous definition of ProtocRetryError was here
/usr/local/lib/ruby/2.7.0/net/protocol.rb:206: warning: already initialized constant Net::BufferedIO::BUFSIZE
/usr/local/bundle/gems/net-protocol-0.1.2/lib/net/protocol.rb:208: warning: previous definition of BUFSIZE was here
/usr/local/lib/ruby/2.7.0/net/protocol.rb:503: warning: already initialized constant Net::NetPrivate::Socket
/usr/local/bundle/gems/net-protocol-0.1.2/lib/net/protocol.rb:504: warning: previous definition of Socket was here
There are no warnings if I downgrade to 0.1.1.
I’m happy to accept I’m doing something wrong (I inherited a Rails project from a former coworker and am trying to get it caught up to current versions of things), but I figured it was worth asking.
I have receive the same warnings with Ruby 2.7.5. Downgrading to 0.1.1 didn't help, though.
@hsbt I'm seeing those too. Any idea what those could mean?
It may be related to https://github.com/rails/rails/pull/44175
In a comment to rails/rails/pull/44175 @ryanb suggests you can add gem 'net-http' to your project to silence warnings. This worked for me.