ruby-on-railsrubyrubygemsruby-on-rails-6ruby-2.7

Understanding Ruby Versioning Conflicts: Unraveling the Net::ProtocRetryError and Net::BufferedIO::BUFSIZE Warnings


Every time i'm working when i try to launch any gem like mailcatcher, start my server or run the command rails c i see this error message and i don't know why it's look like some kind of error version un ruby.

/home/santiago/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/net/protocol.rb:66: warning: already initialized constant Net::ProtocRetryError

/home/santiago/.rvm/gems/ruby-2.7.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:68: warning: previous definition of ProtocRetryError was here

/home/santiago/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/net/protocol.rb:206: warning: already initialized constant Net::BufferedIO::BUFSIZE

/home/santiago/.rvm/gems/ruby-2.7.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:214: warning: previous definition of BUFSIZE was here

/home/santiago/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/net/protocol.rb:503: warning: already initialized constant Net::NetPrivate::Socket

/home/santiago/.rvm/gems/ruby-2.7.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:541: warning: previous definition of Socket was here

I'm using this ruby version: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]

Rails version: Rails 6.0.4.7.

And I installed ruby with rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io].

enter image description here

I tried to update net-protocol gem, change the ruby version to another version of 2.7.0 but didn't work.

i want to know why is this happening and solve it to not see these kind of message anymore.


Solution

  • Some (maybe all, I am not sure) of the Net::* classes were moved from the stdlib to gems (they were gemified) around Ruby 3.0. Since then, for Ruby versions previous to 3.0, gems that depend on the Net::* classes (such as faraday) may be loading the same class twice. Once from the stdlib and once from the gem.

    Solution 1 upgrade to ruby 3.X (I can't apply this solution). Solution 2 explĂ­city add net-http to your gemfile, works for not see the message.