Skip to content

Warn and reraise LoadError instead of raising custom error#143

Merged
janko merged 1 commit into
janko:masterfrom
thatch-health:reraise-load-error
Jun 3, 2026
Merged

Warn and reraise LoadError instead of raising custom error#143
janko merged 1 commit into
janko:masterfrom
thatch-health:reraise-load-error

Conversation

@bdewater-thatch
Copy link
Copy Markdown
Contributor

@bdewater-thatch bdewater-thatch commented Jun 2, 2026

When upgrading to image_processing 2.0 and removing the image_magick gem (which we don't use) we ran into errors with Tapioca requiring all gems to compile RBI files. The quick fix was to add back image_magick, but the IMO proper fix is re-raising the original LoadError from Bundler which is handled by Tapioca. With these changes Tapioca can compile RBI for image_processing, just without the ImageProcessing::MiniMagick module being present.

The warn + reraise pattern is for example how Rails handles bcrypt: https://github.com/rails/rails/blob/fa8f0812160665bff083a089d2bb2fc1817ea03e/activemodel/lib/active_model/secure_password.rb#L129-L134

@janko
Copy link
Copy Markdown
Owner

janko commented Jun 3, 2026

Yes, it seems correct to raise LoadError here. Would Tapioca still rescue it if we raised LoadError with the custom message equal to current warning message? I feel like that way we ensure the friendly error won't be overlooked. For example, Active Storage raises a custom LoadError when image_processing gem is missing.

@bdewater-thatch
Copy link
Copy Markdown
Contributor Author

bdewater-thatch commented Jun 3, 2026

Yes, Tapioca doesn't care about the message. I've amended the PR.

@janko
Copy link
Copy Markdown
Owner

janko commented Jun 3, 2026

Thanks!

@janko janko merged commit 996862c into janko:master Jun 3, 2026
7 checks passed
@bdewater-thatch bdewater-thatch deleted the reraise-load-error branch June 3, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants