Rails 7 Ruby 3.1 LoadError: cannot load such file — net/smtp

For Rails 6

Add gem 'net-smtp', require: false to your Gemfile and run bundle.

Similarly I assume you may have problems with net-imap and net-pop and so have to add them until a new mail gem version is released.

gem 'net-smtp', require: false
gem 'net-imap', require: false
gem 'net-pop', require: false

UPD: The mail gem version 2.8.0 was released on December 3rd, 2022 which includes the fix. Just upgrade to >= 2.8.0.

For Rails 7

On January 6th, 2022 Rails 7.0.1 was released:

The focus of this release is bring support to Ruby 3.1

Amongh other Ruby 3.1-related issues it brought a fix for this problem. So upgrade to Rails >= 7.0.1.


Related pull requests and issues:

  • mikel/mail: Add former default gems as a dependency for Ruby 3.1 compatibility
  • Add net/smtp gem for bug report templates to support Ruby 3.1

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)