ruby-vips
ruby-vips copied to clipboard
Could not open library 'libvips-42.dll': The specified module could not be found.\r (LoadError)
I am a windows 11 users, using rails 7.0 and ruby 3.0.1p64. I followed the instruction on the ruby-vips, installed the gem, installed the vips lib at C:\vips-dev-w64-web-8.12.1 on my windows machine and added it to path, I also set the RUBY_DLL_PATH to C:\vips-dev-w64-web-8.12.1\vips-dev-8.12\bin. When I run the rails sever I rails application crashes with this error:
Could not open library 'libvips-42.dll': The specified module could not be found.\r (LoadError)
I have gem "image_processing", "~> 1.2" in my gem file. How can I fix this?
Hi again @omokehinde,
I tried on my win10 install. Here's what I did:
- I installed ruby with
choco install ruby. It put a 64-bit ruby intoc:/tools/ruby31. - I installed msys with
choco install msys2. That went toc:/tools/msys64. - I ran
gem install ruby-vips. This will pull in the libvips binary via msys, there's a line"msys2_mingw_dependencies" => "libvips"inruby-vips.gemspec.
I made this "hello world" program:
require "vips"
puts "using libvips version: #{Vips::version_string}"
image = Vips::Image.new_from_file ARGV[0]
puts "image: width = #{image.width}, height = #{image.height}"
And ran it like this:
jcupi@DESKTOP-HGI6HBR MINGW64 ~
$ ruby hello.rb /f/Pictures/1.png
using libvips version: 8.12.1-Wed Nov 24 15:41:04 UTC 2021
image: width = 1018, height = 490
And it all seems to work.
I think the advice about the environment variable is out of date -- now that the gemspec includes the msys dependency, it'll pull in the msys libvips package automatically. I'll update the docs.
I've tried to fix the README. Does that help?
Thanks @jcupitt This isn't how I installed ruby. I installed it using the ruby windows installer which installed ruby at C: whether I installed it with the msys64 I am not sure. How do I check if it was installed with the msys64 and do I have to install ruby on my windows following your installation steps using choco?
I had a look at rubyinstaller:
https://rubyinstaller.org/downloads/
Did you install "ruby+devkit 3.1.0-1 (x64)"? That's the one that also install msys2 for you.
If you installed the non-devkit version, I would uninstall and then install the one with msys.
@jcupitt
I just checked that my ruby installation was with devkit and contains the msys65. I still uninstalled it and installed the ruby 3.1.0. with devkit and ran bundle update and got this error while the update was running Fetching ruby-vips 2.1.4 Installing ruby-vips 2.1.4 error: failed to init transaction (unable to lock database) error: could not lock database: File exists if you're sure a package manager is not already running, you can remove /var/lib/pacman/db.lck
You'll need to find out why your windows ruby package manager is locked. Perhaps it was interrupted half-way through an update?
@jcupitt How can I find out? How can I fix this?
Sorry, I don't know. You'll need to read the documentation for your package manager.
what package manager?
I don't know. pacman I guess, from the error message.
Hi @jcupitt,
I have the same issue now with libvips 8.12.2. Previously, pacman installed libvips 8.11.2 but there ruby crashed (like discussed previously https://github.com/libvips/ruby-vips/issues/331). Thankfully you updated the libvips package to 8.12.2 (https://github.com/msys2/MINGW-packages/pull/11078). Unfortunately now with libvips 8.12.2 I get the same error like omokehinde:
C:\>ruby test.rb
Traceback (most recent call last):
2: from test.rb:1:in `<main>'
1: from C:/Ruby27-x64/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
C:/Ruby27-x64/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require': cannot load such file -- vips (LoadError)
8: from test.rb:1:in `<main>'
7: from C:/Ruby27-x64/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:147:in `require'
6: from C:/Ruby27-x64/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:158:in `rescue in require'
5: from C:/Ruby27-x64/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:158:in `require'
4: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/ruby-vips-2.1.4/lib/vips.rb:570:in `<top (required)>'
3: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/ruby-vips-2.1.4/lib/vips.rb:573:in `<module:Vips>'
2: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/ffi-1.13.1-x64-mingw32/lib/ffi/library.rb:99:in `ffi_lib'
1: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/ffi-1.13.1-x64-mingw32/lib/ffi/library.rb:99:in `map'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/ffi-1.13.1-x64-mingw32/lib/ffi/library.rb:145:in `block in ffi_lib': Could not open library 'libvips-42.dll': The specified procedure could not be found.\r (LoadError)
I even get this error on a fresh install of rubyinstaller-devkit-2.7.5-1-x64.exe with system update option enabled. mingw-w64-x86_64-libvips is installed via pacman, but somehow libvips can't be loaded anymore. Any clue what this could be? Thanks for your support!