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
Error While Installing Ruby Using Rvm
Search Multiple Models at Once with Ransack
Is Inject the Same Thing as Reduce in Ruby
Rake Assets:Precompile Attempting to Connect to Database
How to Check Whether a Value in a String Is an Ip Address
Why Does Accessing a Ssl Site with Mechanize on Windows Fail, But on MAC Work
Fast Way to Get Remote Image Dimensions
Sprockets::Circulardependencyerror in Store#Index
How to Use Watir::Waiter::Wait_Until to Force Chrome to Wait
How to Validate Members of an Array Field
Making Multiple Http Requests Asynchronously
Getting Webpage Content with Ruby -- I'm Having Troubles
How to Use Dot Syntax for Ruby Hash
How to Share the Factories That I Have in a Gem and Use It in Other Project