net-protocol icon indicating copy to clipboard operation
net-protocol copied to clipboard

Warning: already initialized constant

Open jproctor opened this issue 3 years ago • 4 comments

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.

jproctor avatar Mar 02 '22 00:03 jproctor

I have receive the same warnings with Ruby 2.7.5. Downgrading to 0.1.1 didn't help, though.

iltempo avatar Mar 06 '22 09:03 iltempo

@hsbt I'm seeing those too. Any idea what those could mean?

AxelTheGerman avatar Apr 02 '22 04:04 AxelTheGerman

It may be related to https://github.com/rails/rails/pull/44175

yahonda avatar Apr 04 '22 06:04 yahonda

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.

RogerE avatar Apr 05 '22 07:04 RogerE