Ruby on Rails + mimemagic

I’m attempting to deploy a Rails 7 app but am getting the following error on deploy when installing image_processing 1.12.2 / mimemagic 0.4.3:

#16 28.53 Installing image_processing 1.12.2
#16 28.57 Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
#16 28.57 
#16 28.57 current directory:
#16 28.57 /app/vendor/bundle/ruby/3.0.0/gems/mimemagic-0.4.3/ext/mimemagic
#16 28.57 /usr/lib/fullstaq-ruby/versions/3.0.2-jemalloc/bin/ruby
#16 28.57 -I/usr/lib/fullstaq-ruby/versions/3.0.2-jemalloc/lib/ruby/3.0.0 -rrubygems
#16 28.57 /app/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/exe/rake
#16 28.57 RUBYARCHDIR\=/app/vendor/bundle/ruby/3.0.0/extensions/x86_64-linux/3.0.0/mimemagic-0.4.3
#16 28.57 RUBYLIBDIR\=/app/vendor/bundle/ruby/3.0.0/extensions/x86_64-linux/3.0.0/mimemagic-0.4.3
#16 28.57 rake aborted!
#16 28.57 Could not find MIME type database in the following locations:
#16 28.57 ["/usr/local/share/mime/packages/",
#16 28.57 "/opt/homebrew/share/mime/packages/",
#16 28.57 "/opt/local/share/mime/packages/",
#16 28.57 "/usr/share/mime/packages/"]
#16 28.57 
#16 28.57 Ensure you have either installed the shared-mime-info package for your
#16 28.57 distribution, or
#16 28.57 obtain a version of and set FREEDESKTOP_MIME_TYPES_PATH to
#16 28.57 the location
#16 28.57 of that file.

Any ideas how I might resolve this? (I’m not sure how I’d satisfy the steps in the error message.) Thanks!

You shouldn’t need mimemagic to use image_processing for Rails 7. Is it in your Gemfile?

Sorry, I should’ve added the final few lines of the error:

#16 28.57 An error occurred while installing mimemagic (0.4.3), and Bundler cannot
#16 28.57 continue.
#16 28.57 
#16 28.57 In Gemfile:
#16 28.57   imagekitio was resolved to 2.1.1, which depends on
#16 28.57     carrierwave was resolved to 2.1.1, which depends on
#16 28.57       mimemagic

This is a bundler gem dependency issue. Bundler can’t resolve the correct dependent gems bc gems listed in your gemfile have conflicting version requirements. You’ll need to resolve that in your local dev environment so the Gemfile.lock file is up to date.

Are you able to run bundle install successfully on your local machine?

Ah OK. This is telling you that carrierwave is still depending on mimemagic. Carrierwave also dropped support for it, but imagekitio didn’t bump its carrierwave dependency. Check out both carrierwave and imagekitio, though I suspect this means you’d need to fork imagekitio to get a matching version without mimemagic.

If you don’t want to do all that, you can add the package to your Docker image by setting the PROD_PACKAGES env var in fly.toml. Note that you’d want to also include in that var any package you need from the PROD_PACKAGES line set in your Dockerfile.

I’d recommend going with the gem route though, as the mimemagic as a gem has been shunned by the Rails community at large.

Thanks! Giving this a try now. Will let you know how it goes…

were you able to solve this?