Photo by Michael Dziedzic on Unsplash
Rails | Some warning messages you might find interesting
Suppress Rails warnings
Play this article
warning: already initialized constant Net::ProtocRetryError
/Users/username/.rbenv/versions/2.7.7/lib/ruby/2.7.0/net/protocol.rb:66: warning: already initialized constant Net::ProtocRetryError
/Users/username/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:68: warning: previous definition of ProtocRetryError was here
/Users/username/.rbenv/versions/2.7.7/lib/ruby/2.7.0/net/protocol.rb:206: warning: already initialized constant Net::BufferedIO::BUFSIZE
/Users/username/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:214: warning: previous definition of BUFSIZE was here
/Users/username/.rbenv/versions/2.7.7/lib/ruby/2.7.0/net/protocol.rb:503: warning: already initialized constant Net::NetPrivate::Socket
/Users/username/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:541: warning: previous definition of Socket was here
Cause
gem net-http
is defined as dependencies for multiple gems for network usages(like faraday
, net-ssh
, net-protocol
). This happen to load the gem multiple times and causing the warnings. As suggested here I explicitly added gem to the Gemfile and issue is fixed.
gem 'net-http', '0.3.2' # explicit added to suppress warnings
You have already activated uri 0.10.0, but your Gemfile requires uri 0.12.0.
/opt/xx/Ruby/2.7.7/x64/lib/ruby/gems/2.7.0/gems/bundler-2.4.6/lib/bundler/runtime.rb:304:in `check_for_activated_spec!': You have already activated uri 0.10.0, but your Gemfile requires uri 0.12.0. Since uri is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports uri as a default gem. (Gem::LoadError)
Cause:
This is caused by collision of two version of gems installed in your machine. (CI in my case).
Fix
To Fix it, I had to specify the uri
gem version to 0.10.0
which was default in my machine.
gem 'net-http', '0.3.2' # explicit added to suppress warnings
gem 'uri', '0.10.0'