Don't swallow exception in actionmailer/actionmailbox when requiring "mail" fails #46898
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation / Background
PR #44600 introduced a fallback for missing system dependencies related to the Mail gem. That PR had the unintended side effect of swallowing exceptions when require "mail" fails.
For example, recently, there was a regression in the Mail gem, where some of the files had their permission removed. This caused issues during the Rails initialization process when certain conditions were met:
config.eager_load = true
require "mail"
under these conditions would fail but Rails would swallow the exception, causing eager_load (and potentially other calls) to fail with weird error messages.Vanilla rails app with minimal settings changes to demonstrate the bug: https://github.com/chitty/repro-46898
Detail
This PR changes the code introduced in #44600 so that it always re-raises the exception.
This does not affect Rails 7 since the fallback isn't needed in that case, as mentioned in #44600:
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]