@ledsun blog

無味の味は佳境に入らざればすなわち知れず

Rails 7 のActiveStrageはデフォルトではImageMagickの代わりにlibvipsを使う

Rails 7 αを試して、エラーで躓いているところ - @ledsun blogCould not open library 'libvips.42.dylib': dlopen(libvips.42.dylib, 5): image not foundというメッセージを含むエラーが起きたので、ググったところ次のissueが見つかりました。

github.com

brew install vipsすると良さそうな気配を感じました。

~ brew install vips
==> Downloading https://ghcr.io/v2/homebrew/core/cfitsio/manifests/4.0.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/cfitsio/blobs/sha256:bfc9fd29dd3909123ab1ee9d1c0fa36543bfc4a330690826b8a94c545544888c
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:bfc9fd29dd3909123ab1ee9d1c0fa36543bfc4a330690826b8a94c545544888c?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/hwloc/manifests/2.5.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/hwloc/blobs/sha256:d0b225d121dcd50e56b2b592a2670f05e94d48316cd37e6c254c36b99690e278
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:d0b225d121dcd50e56b2b592a2670f05e94d48316cd37e6c254c36b99690e278?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/open-mpi/manifests/4.1.1_2
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/open-mpi/blobs/sha256:da310195e62c1a27aea7365b325cb15dd48f99dd673fd1f685f8b5247cfbb48d
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:da310195e62c1a27aea7365b325cb15dd48f99dd673fd1f685f8b5247cfbb48d?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/fftw/manifests/3.3.9_1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/fftw/blobs/sha256:8ee0fe663966dcc2ba924768dc921536873b172b024302f1f06e663237d11a29
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:8ee0fe663966dcc2ba924768dc921536873b172b024302f1f06e663237d11a29?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/imagemagick/manifests/7.1.0-7
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/imagemagick/blobs/sha256:7183ec417b94801b6192c4fc3c026e3b99b06b3794d98082d2675c4273386bd9
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:7183ec417b94801b6192c4fc3c026e3b99b06b3794d98082d2675c4273386bd9?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libexif/manifests/0.6.22
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libexif/blobs/sha256:93faf9081e80a6b1b30fd4dd941fa650d431b3064aeef00c9a7bccd042ff1bda
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:93faf9081e80a6b1b30fd4dd941fa650d431b3064aeef00c9a7bccd042ff1bda?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libgsf/manifests/1.14.47
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libgsf/blobs/sha256:190c702ad48598787b9fc72a019cd8f2701d1ae28ed41e3c111acd19b223d139
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:190c702ad48598787b9fc72a019cd8f2701d1ae28ed41e3c111acd19b223d139?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libimagequant/manifests/2.15.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libimagequant/blobs/sha256:0521a9c6ee13fb0859fa33c98b7dc07b552e0de9856e838fdb2b05657f24cd03
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:0521a9c6ee13fb0859fa33c98b7dc07b552e0de9856e838fdb2b05657f24cd03?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/szip/manifests/2.1.1_1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/szip/blobs/sha256:1779ec8c3312993ef7e22679df6bbcd3adce9db28d3ad98adb54650c018ed294
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:1779ec8c3312993ef7e22679df6bbcd3adce9db28d3ad98adb54650c018ed294?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/hdf5/manifests/1.12.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/hdf5/blobs/sha256:6c31504f6a44ef682977a38ef9327efce7e6ba9264add1965b1a76e8fddc2647
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:6c31504f6a44ef682977a38ef9327efce7e6ba9264add1965b1a76e8fddc2647?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libmatio/manifests/1.5.21_1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libmatio/blobs/sha256:06e8056f9862feace810dd233860e9b77af58e20e3eb916f48525c586e08eb42
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:06e8056f9862feace810dd233860e9b77af58e20e3eb916f48525c586e08eb42?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gdk-pixbuf/manifests/2.42.6
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gdk-pixbuf/blobs/sha256:f4cf795b20c84fb5074ceeeeaf7b1d22e164b7af13adb6d0b95e3655d867fd41
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:f4cf795b20c84fb5074ceeeeaf7b1d22e164b7af13adb6d0b95e3655d867fd41?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/librsvg/manifests/2.50.7
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/librsvg/blobs/sha256:7849cab410dfd63c3f8f635e0a0152cf34425524f728c2f01a36d7631f34688b
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:7849cab410dfd63c3f8f635e0a0152cf34425524f728c2f01a36d7631f34688b?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libspng/manifests/0.6.3
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libspng/blobs/sha256:8cba8c9454c2d9892b39cd4b4dff9e32974f82ea5c220dc1e0aa90eb19406711
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:8cba8c9454c2d9892b39cd4b4dff9e32974f82ea5c220dc1e0aa90eb19406711?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/mozjpeg/manifests/4.0.3
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/mozjpeg/blobs/sha256:62b7cba57dec06208ee2af6a726b918c0131c0d4f4b735d32eab16df348e1852
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:62b7cba57dec06208ee2af6a726b918c0131c0d4f4b735d32eab16df348e1852?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openslide/manifests/3.4.1_5
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openslide/blobs/sha256:5cc9273868f2816ac3b2cfd9d12bcbc44d68fb461000469896c4f10b8047511f
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:5cc9273868f2816ac3b2cfd9d12bcbc44d68fb461000469896c4f10b8047511f?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/orc/manifests/0.4.32
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/orc/blobs/sha256:7c5d9d6caf789828006ff7d604eb81a247c8d9ff6004c524978452a252dd8162
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:7c5d9d6caf789828006ff7d604eb81a247c8d9ff6004c524978452a252dd8162?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/nspr/manifests/4.32
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/nspr/blobs/sha256:fa4089b067d319a827833747ed64c0e9ed9ce1c95aa54d77fb1dabffd52436ed
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:fa4089b067d319a827833747ed64c0e9ed9ce1c95aa54d77fb1dabffd52436ed?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/nss/manifests/3.70
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/nss/blobs/sha256:238f33223e0a09ce14313f7e434b6379a727d8c2737a6d676c2d48ee38b9cfa4
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:238f33223e0a09ce14313f7e434b6379a727d8c2737a6d676c2d48ee38b9cfa4?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/poppler/manifests/21.09.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/poppler/blobs/sha256:ac1bbd7709dd6cccbfced46079c03a775c3981b467ee087255fb9f8f1fce4ec0
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:ac1bbd7709dd6cccbfced46079c03a775c3981b467ee087255fb9f8f1fce4ec0?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/vips/manifests/8.11.3
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/vips/blobs/sha256:fcc96568f87ab0beeb60ccdbcc756c4fe1e1fdefbb1231ed1f32225624e10d33
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:fcc96568f87ab0beeb60ccdbcc756c4fe1e1fdefbb1231ed1f32225624e10d33?se=2021-09-18T01%3A30%
######################################################################## 100.0%
==> Installing dependencies for vips: cfitsio, hwloc, open-mpi, fftw, imagemagick, libexif, libgsf, libimagequant, szip, hdf5, libmatio, gdk-pixbuf, librsvg, libspng, mozjpeg, openslide, orc, nspr, nss and poppler
==> Installing vips dependency: cfitsio
==> Pouring cfitsio--4.0.0.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/cfitsio/4.0.0: 17 files, 3.1MB
==> Installing vips dependency: hwloc
==> Pouring hwloc--2.5.0.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/hwloc/2.5.0: 959 files, 10MB
==> Installing vips dependency: open-mpi
==> Pouring open-mpi--4.1.1_2.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/open-mpi/4.1.1_2: 760 files, 15.9MB
==> Installing vips dependency: fftw
==> Pouring fftw--3.3.9_1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/fftw/3.3.9_1: 73 files, 14.7MB
==> Installing vips dependency: imagemagick
==> Pouring imagemagick--7.1.0-7.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/imagemagick/7.1.0-7: 799 files, 30.3MB
==> Installing vips dependency: libexif
==> Pouring libexif--0.6.22.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/libexif/0.6.22: 58 files, 2.9MB
==> Installing vips dependency: libgsf
==> Pouring libgsf--1.14.47.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/libgsf/1.14.47: 154 files, 2.5MB
==> Installing vips dependency: libimagequant
==> Pouring libimagequant--2.15.1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/libimagequant/2.15.1: 10 files, 200.7KB
==> Installing vips dependency: szip
==> Pouring szip--2.1.1_1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/szip/2.1.1_1: 11 files, 143.1KB
==> Installing vips dependency: hdf5
==> Pouring hdf5--1.12.1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/hdf5/1.12.1: 273 files, 18.3MB
==> Installing vips dependency: libmatio
==> Pouring libmatio--1.5.21_1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/libmatio/1.5.21_1: 38 files, 1MB
==> Installing vips dependency: gdk-pixbuf
==> Pouring gdk-pixbuf--2.42.6.big_sur.bottle.tar.gz
==> /usr/local/Cellar/gdk-pixbuf/2.42.6/bin/gdk-pixbuf-query-loaders --update-cache
🍺  /usr/local/Cellar/gdk-pixbuf/2.42.6: 147 files, 3.7MB
==> Installing vips dependency: librsvg
==> Pouring librsvg--2.50.7.big_sur.bottle.tar.gz
==> /usr/local/opt/gdk-pixbuf/bin/gdk-pixbuf-query-loaders --update-cache
🍺  /usr/local/Cellar/librsvg/2.50.7: 48 files, 138.6MB
==> Installing vips dependency: libspng
==> Pouring libspng--0.6.3.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/libspng/0.6.3: 9 files, 111.7KB
==> Installing vips dependency: mozjpeg
==> Pouring mozjpeg--4.0.3.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/mozjpeg/4.0.3: 40 files, 3.8MB
==> Installing vips dependency: openslide
==> Pouring openslide--3.4.1_5.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/openslide/3.4.1_5: 16 files, 476.4KB
==> Installing vips dependency: orc
==> Pouring orc--0.4.32.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/orc/0.4.32: 51 files, 1MB
==> Installing vips dependency: nspr
==> Pouring nspr--4.32.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/nspr/4.32: 86 files, 1.2MB
==> Installing vips dependency: nss
==> Pouring nss--3.70.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/nss/3.70: 225 files, 43.1MB
==> Installing vips dependency: poppler
==> Pouring poppler--21.09.0.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/poppler/21.09.0: 476 files, 27.5MB
==> Installing vips
==> Pouring vips--8.11.3.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/vips/8.11.3: 165 files, 13.2MB

Railsアプリケーションを起動してみたら、無事アップロード画像の表示に成功しました。

f:id:ledsun:20210918102933p:plain
Rails 7アプリケーションでアップロードした画像の表示に成功したところ

Rails 7 αのリリースブログ

weblog.rubyonrails.org

Active Storage now uses the faster and more secure libvips as its default variant processor.

が気になって、リンクをたどると...

https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#activestorage-variant-processor-changed-to-vips

Image transformation will now use libvips instead of ImageMagick.

ついにImageMagickを使わなくなるようです。

The :mini_magick option is not being deprecated, so it is fine to keep using it.

デフォルトでなくなるだけで、つかなくなるわけではないので、今ImageMagickを使っている人も心配ご無用です。

WindowsのMINGW64では

特に意識しなくてもlibvipsがインストールされるようです。

led_l@MSI MINGW64 /c/dev/rails7/showtell (master)
$ bundle
Fetching gem metadata from https://rubygems.org/............
Resolving dependencies...
Using rake 13.0.6
Using concurrent-ruby 1.1.9
Using i18n 1.8.10
Using minitest 5.14.4
Using tzinfo 2.0.4
Using activesupport 7.0.0.alpha2
Using builder 3.2.4
Using erubi 1.10.0
Using racc 1.5.2
Using nokogiri 1.12.4 (x64-mingw32)
Using rails-dom-testing 2.0.3
Using crass 1.0.6
Using loofah 2.12.0
Using rails-html-sanitizer 1.4.2
Using actionview 7.0.0.alpha2
Using rack 2.2.3
Using rack-test 1.1.0
Using actionpack 7.0.0.alpha2
Using nio4r 2.5.8
Using websocket-extensions 0.1.5
Using websocket-driver 0.7.5
Using actioncable 7.0.0.alpha2
Using globalid 0.5.2
Using activejob 7.0.0.alpha2
Using activemodel 7.0.0.alpha2
Using activerecord 7.0.0.alpha2
Using marcel 1.0.2
Using mini_mime 1.1.1
Using activestorage 7.0.0.alpha2
Using mail 2.7.1
Using actionmailbox 7.0.0.alpha2
Using actionmailer 7.0.0.alpha2
Using actiontext 7.0.0.alpha2
Using public_suffix 4.0.6
Using addressable 2.8.0
Using bindex 0.8.1
Using msgpack 1.4.2
Using bootsnap 1.9.1
Using bundler 2.2.22
Using regexp_parser 2.1.1
Using xpath 3.2.0
Using capybara 3.35.3
Using childprocess 3.0.0
Using io-console 0.5.9
Using reline 0.2.7
Using irb 1.3.7
Using debug 1.1.0
Fetching ffi 1.15.4 (x64-mingw32)
Installing ffi 1.15.4 (x64-mingw32)
Fetching mini_magick 4.11.0
Installing mini_magick 4.11.0
Fetching ruby-vips 2.1.3
Installing ruby-vips 2.1.3
警告: 循環依存が検出されました:
警告: mingw-w64-x86_64-harfbuzz は依存パッケージ mingw-w64-x86_64-freetype の前にインストールされます
警告: 循環依存が検出されました:
警告: mingw-w64-x86_64-libwebp は依存パッケージ mingw-w64-x86_64-libtiff の前にインストールされます
Fetching image_processing 1.12.1
Installing image_processing 1.12.1
Using method_source 1.0.0
Using thor 1.1.0
Using zeitwerk 2.5.0.beta4
Using railties 7.0.0.alpha2
Using sprockets 4.0.2
Using sprockets-rails 3.2.2
Using rails 7.0.0.alpha2
Using importmap-rails 0.7.3
Using jbuilder 2.11.2
Using puma 5.5.0
Using rubyzip 2.3.2
Using selenium-webdriver 3.142.7
Using sqlite3 1.4.2
Using stimulus-rails 0.5.4
Using turbo-rails 0.7.14
Using tzinfo-data 1.2021.1
Using web-console 4.1.0
Using webdrivers 4.6.1
Bundle complete! 15 Gemfile dependencies, 69 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.