Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not open library 'libvips-42.dll': The specified module could not be found.\r (LoadError) #326

Open
omokehinde opened this issue Jan 11, 2022 · 11 comments

Comments

@omokehinde
Copy link

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?

@jcupitt
Copy link
Member

jcupitt commented Jan 11, 2022

Hi again @omokehinde,

I tried on my win10 install. Here's what I did:

  1. I installed ruby with choco install ruby. It put a 64-bit ruby into c:/tools/ruby31.
  2. I installed msys with choco install msys2. That went to c:/tools/msys64.
  3. I ran gem install ruby-vips. This will pull in the libvips binary via msys, there's a line "msys2_mingw_dependencies" => "libvips" in ruby-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.

jcupitt added a commit that referenced this issue Jan 11, 2022
@jcupitt
Copy link
Member

jcupitt commented Jan 11, 2022

I've tried to fix the README. Does that help?

@omokehinde
Copy link
Author

omokehinde commented Jan 11, 2022

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?

@jcupitt
Copy link
Member

jcupitt commented Jan 12, 2022

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.

@omokehinde
Copy link
Author

@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

@jcupitt
Copy link
Member

jcupitt commented Jan 13, 2022

You'll need to find out why your windows ruby package manager is locked. Perhaps it was interrupted half-way through an update?

@omokehinde
Copy link
Author

@jcupitt
How can I find out? How can I fix this?

@jcupitt
Copy link
Member

jcupitt commented Jan 13, 2022

Sorry, I don't know. You'll need to read the documentation for your package manager.

@omokehinde
Copy link
Author

what package manager?

@jcupitt
Copy link
Member

jcupitt commented Jan 13, 2022

I don't know. pacman I guess, from the error message.

@niklasweber
Copy link

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 #331). Thankfully you updated the libvips package to 8.12.2 (msys2/MINGW-packages#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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants