basecamp / basecamp/hotcell

activestorage-hotcell-client requires mini_magick at load even when only the Vips transformer is configured

Open
#57 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
23
Forks
0
Avg merge
11h 43m
Merged PRs (30d)
27

Description

`activestorage-hotcell-client` loads every transformer at require time. `lib/active_storage/hot_cell/client.rb:9` requires `transformers/image/magick`, which subclasses `ActiveStorage::Transformers::ImageMagick`, and Rails' `active_storage/transformers/image_magick.rb:3` requires `image_processing/mini_magick` unconditionally. With `image_processing` 2.x, where `mini_magick` is no longer a dependency, that require raises:

LoadError: ImageProcessing::MiniMagick requires the mini_magick gem. Please add `gem "mini_magick", "~> 5.0"` to your Gemfile.

So an application that only configures the Vips transformer, and never installs `mini_magick`, fails to boot as soon as it requires `active_storage/hot_cell/client`. Fizzy hit this on [basecamp/fizzy#3056](https://github.com/basecamp/fizzy/pull/3056), which bumped `image_processing` 1.14 → 2.0.3; the chain is `saas/lib/fizzy/saas/cell.rb:6` → `client.rb:9` → `transformers/image/magick.rb:4` → Rails `image_magick.rb:3` → `image_processing/mini_magick.rb:5`.

Rails guards the Vips side: `active_storage/vips` rescues the `LoadError` and sets `ActiveStorage::VIPS_AVAILABLE = false`. It does not guard the ImageMagick side, and neither does this gem, so the gem effectively requires both backends' gems while the application picks one.

Fizzy's workaround is [basecamp/fizzy#3106](https://github.com/basecamp/fizzy/pull/3106): declare `mini_magick` in `Gemfile.saas` with `require: false`, purely so the require can succeed.

Proposal: load the ImageMagick transformer (and the ImageMagick analyzer, which is fine today but shares the fate) lazily, with `autoload` under `ActiveStorage::HotCell::Client::Transformers::Image` or an `Image::Magick` `Kernel#require` inside a `begin`/`rescue LoadError` that leaves the constant undefined. An application then pays for the backend it configures, and the gemspec's silence on `mini_magick` and `ruby-vips` becomes accurate rather than accidental.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Contributor guide

Open the contributing guide

Research direction

Start in lib/active_storage/hot_cell/client.rb:9 and trace the ImageMagick transformer and analyzer requires through transformers/image/magick.rb and Rails' active_storage/transformers/image_magick.rb. Reproduce the load failure with image_processing 2.x and only the Vips transformer configured, then verify the client loads without mini_magick while the selected backend remains usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.