ruby / openssl

Provides SSL, TLS and general purpose cryptography.
Other
240 stars 167 forks source link

Windows 10 MSYS2 openssl-3.4.0 "LoadError - The specified procedure could not be found." #812

Open andrewngo opened 15 hours ago

andrewngo commented 15 hours ago

Not able to require 'openssl' on Windows after updating the MSYS2 openssl library. I'm able to install it and I see the openssl.so file but it still doesn't run.

Packages (18) bsdtar-3.7.7-1  curl-8.10.1-1  gawk-5.3.1-1  info-7.1.1-1  libcurl-8.10.1-1  libexpat-2.6.3-1
              libgnutls-3.8.7-1  liblzma-5.6.3-1  libnghttp2-1.64.0-1  libopenssl-3.4.0-1  libreadline-8.2.013-1
              libsqlite-3.46.1-1  msys2-keyring-1~20241007-1  msys2-launcher-1.5-2  nano-8.2-1  ncurses-6.5.20240831-2
              openssl-3.4.0-1  xz-5.6.3-1

Packages (1) mingw-w64-x86_64-openssl-3.4.0-1
ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'
>>
<internal:C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require': 127: The specified procedure could not be found.   - C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/openssl-3.2.0/lib/openssl.so (LoadError)
        from <internal:C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/openssl-3.2.0/lib/openssl.rb:13:in `<top (required)>'
        from <internal:C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'

Computer info

 ruby -v
ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [x64-mingw-ucrt]

gem list openssl

*** LOCAL GEMS ***

openssl (3.2.0, default: 3.1.0, 3.0.1)

[System.Environment]::OSVersion.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      20348  0
MSP-Greg commented 14 hours ago

Try using mingw-w64-ucrt-x86_64-openssl. You listed mingw-w64-x86_64-openssl, which is the wrong package for Ruby 3.2.3, which shows x64-mingw-ucrt...

andrewngo commented 13 hours ago

Both seem to be installed. Is there a way to force the package?

I use these commands to install it

call %ruby_dir%\bin\ridk exec pacman -Sy
call %ruby_dir%\bin\ridk install 2 3

and then pacman shows the following:

C:\tools\msys64\usr\bin\pacman.exe -Q | findstr openssl

libopenssl 3.4.0-1
mingw-w64-ucrt-x86_64-openssl 3.4.0-1
mingw-w64-x86_64-openssl 3.4.0-1
openssl 3.4.0-1
C:\tools\msys64\usr\bin\pacman.exe -Ss | findstr openssl
clangarm64/mingw-w64-clang-aarch64-openssl 3.4.0-1
clangarm64/mingw-w64-clang-aarch64-python-pyopenssl 24.2.1-2
mingw32/mingw-w64-i686-openssl 3.4.0-1
mingw32/mingw-w64-i686-python-pyopenssl 24.2.1-2
mingw64/mingw-w64-x86_64-openssl 3.4.0-1 [installed]
mingw64/mingw-w64-x86_64-python-pyopenssl 24.2.1-2
ucrt64/mingw-w64-ucrt-x86_64-openssl 3.4.0-1 [installed]
ucrt64/mingw-w64-ucrt-x86_64-python-pyopenssl 24.2.1-2
clang32/mingw-w64-clang-i686-openssl 3.4.0-1
clang64/mingw-w64-clang-x86_64-openssl 3.4.0-1
clang64/mingw-w64-clang-x86_64-python-pyopenssl 24.2.1-2
msys/libopenssl 3.4.0-1 (libraries) [installed]
msys/openssl 3.4.0-1 [installed]
msys/openssl-devel 3.4.0-1 (development)
msys/openssl-docs 3.4.0-1
MSP-Greg commented 13 hours ago

I could repro the issue.

I haven't been in OpenSSL for a few months. It appears that OpenSSL 3.4 and 3.3 have some differences.

If I rename the OpenSSL dll's in Ruby's bin/ruby_builtin_dlls folder and copy the OpenSSL dlls from MSY2's ucrt64/bin into the Ruby folder, ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION works and shows OpenSSL 3.4.0 22 Oct 2024.

If you don't want to copy the dlls, you can get the OpenSSL 3.3.x packages from https://repo.msys2.org/mingw/ucrt64/. You'll have to uninstall Ruby OpenSSL 3.2.0 and reinstall it.