Fixing wall of net/protocol warnings

Posted . Visible to the public.

After upgrading to Rails 6.1.7.2 one of our apps printed a wall of warnings while booting:

/var/www/app/shared/bundle/ruby/2.6.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:68: warning: already initialized constant Net::ProtocRetryError
/home/deploy-app/.rbenv/versions/2.6.10/lib/ruby/2.6.0/net/protocol.rb:66: warning: previous definition of ProtocRetryError was here
/var/www/app/shared/bundle/ruby/2.6.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:214: warning: already initialized constant Net::BufferedIO::BUFSIZE
/home/deploy-app/.rbenv/versions/2.6.10/lib/ruby/2.6.0/net/protocol.rb:206: warning: previous definition of BUFSIZE was here
/var/www/app/shared/bundle/ruby/2.6.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:541: warning: already initialized constant Net::NetPrivate::Socket
/home/deploy-app/.rbenv/versions/2.6.10/lib/ruby/2.6.0/net/protocol.rb:503: warning: previous definition of Socket was here

We could fix this by adding the following to our Gemfile:

gem 'net-http', require: false
gem 'net-imap', require: false
gem 'net-protocol', require: false
gem 'net-smtp', require: false

Background

Alternative

Turned out that it was caused by an update of the mail gem from 2.7.0 to 2.8.0.1.
So another possibility would be to stay at version 2.7.0.

Henning Koch
Last edit
Florian Leinsinger
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2023-01-26 16:12)