title: Rails 7 Ruby 3.1 LoadError: cannot load such file -- net/smtp
body: <p>I upgraded to Rails 7 and Ruby 3.1. While trying to run tests with <code>rspec</code> I got the error below. How can I fix it?</p>
  <pre><code>An error occurred while loading rails_helper.
  Failure/Error: require File.expand_path('../config/environment', __dir__)
  
  LoadError:
    cannot load such file -- net/smtp
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:34:in `require'
  # .../gems/zeitwerk-2.5.2/lib/zeitwerk/kernel.rb:36:in `require'
  # .../gems/mail-2.7.1/lib/mail.rb:9:in `&lt;module:Mail&gt;'
  # .../gems/mail-2.7.1/lib/mail.rb:3:in `&lt;main&gt;'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
  # .../gems/zeitwerk-2.5.2/lib/zeitwerk/kernel.rb:36:in `require'
  # .../bundler/gems/rails-6a0f6c4d70b1/actionmailbox/lib/action_mailbox/mail_ext.rb:3:in `&lt;main&gt;'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
  # .../gems/zeitwerk-2.5.2/lib/zeitwerk/kernel.rb:36:in `require'
  # .../bundler/gems/rails-6a0f6c4d70b1/actionmailbox/lib/action_mailbox.rb:3:in `&lt;main&gt;'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
  # .../gems/zeitwerk-2.5.2/lib/zeitwerk/kernel.rb:36:in `require'
  # .../bundler/gems/rails-6a0f6c4d70b1/actionmailbox/lib/action_mailbox/engine.rb:9:in `&lt;main&gt;'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
  # .../gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
  # .../gems/zeitwerk-2.5.2/lib/zeitwerk/kernel.rb:36:in `require'
  # ./config/application.rb:11:in `&lt;top (required)&gt;'
  # ./config/environment.rb:2:in `require_relative'
  # ./config/environment.rb:2:in `&lt;top (required)&gt;'
  # ./spec/rails_helper.rb:4:in `require'
  # ./spec/rails_helper.rb:4:in `&lt;top (required)&gt;'
  No examples found.
  
  
  Finished in 0.00005 seconds (files took 0.57758 seconds to load)
  0 examples, 0 failures, 1 error occurred outside of examples
  </code></pre>