Ruby Loaderror: Cannot Load Such File

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

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

Ruby - LoadError: cannot load such file -- ../credentials_go_in_var_lib/credentials

Instead of require you need to use require_relative because the location of the file is relative to the file you are in

require_relative '../credentials_go_in_var_lib_havesomefun/credentials'


Related Topics



Leave a reply



Submit