Could not open library ‘vips.42’; Could not open library ‘libvips.42.dylib’

If you have this problem on your local machine..

If you have just upgraded from rails 6 to 7, and have config.load_defaults 7.0 set in config/application.rb, then your app will use vips by default.

If that’s what you want, just make sure vips is installed locally. You can install it with homebrew (thanks to @timroman for this info):

brew install vips

However, if you don’t want to use vips, and prefer to use mini_magick as in rails 6, just include this line in config/application.rb

config.active_storage.variant_processor = :mini_magick

Notes

  • Moving from using :mini_magick to :vips will probably require code changes to make your application work as expected. See here for info on that.
  • Further reading:
    • Rails guides here and here
    • This PR
    • Installation instructions for macOS and Ubuntu

If you’re having problems with vips on heroku..

If you get a similar issue on heroku, make sure everything works fine locally first (if it doesn’t, see above), then to solve the issues on heroku, try the following 3 steps:

  1. Add gem "ruby-vips" to your gemfile if it isn’t already there

  2. Set these two buildpacks (in addition to any you already have, in this example I was also using the heroku/ruby buildpack, hence why it’s included as the last buildpack):

heroku-community/apt
https://github.com/brandoncc/heroku-buildpack-vips
heroku/ruby

I think the order here matters (if you have other buildpacks, best to add them after the first two). You can set buildpacks like this

heroku buildpacks:set --index=1 heroku-community/apt
heroku buildpacks:set --index=2 https://github.com/brandoncc/heroku-buildpack-vips
  1. Create a file in the root directory of your app called Aptfile with this as the contents:
libglib2.0-0
libglib2.0-dev
libpoppler-glib8

Notes:

  • You may wish to add more libraries to the Aptfile depending on what processing needed exactly (for example, pdf processing). Here’s an example of an Aptfile with more libraries included. And here is the rails guide showing which other things you may need.
  • Further reading:
    • Info on vips buildpack in this thread.
    • See here for vips buildpack
    • See here for information about the apt buildpack and Aptfile

If you’re having problems on GitHub Actions

Just like other environments (see above) you have to install libvips. Do so on ubuntu using apt-get, by adding this under ‘steps’ in your workflow file:

      - name: Install libvips
        run: sudo apt-get install -y libvips

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)