Search code examples
ruby-on-railsrubyimage-processingvips

Ruby 3 Rails 7 minitest ruby vips warning (from image processing)


I am getting a ton of warnings from ruby vips when running my test suit. Not causing any issues... just really annoying. Does anyone know the root issue here or know how to suppress the ruby vips warnings?

ruby '3.1.2'
gem 'rails', '~> 7.0.4'
gem 'image_processing', '~> 1.2' # ruby vips is a depency here. Gemfile.lock has ruby-vips 2.1.4 installed

When running tests (mini tests) I get this. Has anyone else seen this?

/Users/clarktaylor/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/ruby-vips-2.1.4/lib/vips.rb:51: warning: already initialized constant GLib::G_FREE
/Users/clarktaylor/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/ruby-vips-2.1.4/lib/vips.rb:51: warning: previous definition of G_FREE was here
/Users/clarktaylor/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/ruby-vips-2.1.4/lib/vips.rb:59: warning: already initialized constant GLib::LOG_FLAG_RECURSION
...

The warning go on for about 80 lines. Any help would be greatly appreciated!


Solution

  • Looks like it was an issue when setting the defaults for the image_processing gem. The default used supposed to be image_magick... however with rails 7, the default for active storage is ruby-vips. I tried adding config.active_storage.variant_processor = :mini_magick to config/application.rb but it made no difference.

    HOWEVER, when I added config.active_storage.variant_processor = :mini_magick to config/environments/test.rb, it fixed the issue.

    I went ahead and added that line to ALL my environment files just to be safe.

    NOTE: ruby-vips is much faster than image_magick so it's probably best to keep ruby-vips. If you keep ruby-vips however, it does have a different syntax for creating variants