How to solve 'libcurl' not found with Rail

2020-01-31 03:15发布

This is giving me a headache. I'm continuing a Rails project that started on Linux and I keep getting this when I run Puma on Ruby Mine:

Error:[rake --tasks] DL is deprecated, please use Fiddle
rake aborted!
LoadError: Could not open library 'libcurl': The specified module could not be found.
Could not open library 'libcurl.dll': The specified module could not be found.
Could not open library 'libcurl.so.4': The specified module could not be found.
Could not open library 'libcurl.so.4.dll': The specified module could not be found.
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/ffi-1.9.14-x86-mingw32/lib/ffi/library.rb:147:in `block in ffi_lib'
[...]

Now, what have I tried?

  • I installed Puma successfully on Windows following this steps
  • I downloaded curl-7.50.1-win32-mingw and put it on "C:/curl"
  • I added C:/curl/bin and C:/curl/include to PATH
  • I installed successfully curb gem with gem install curb --platform=ruby -- --with-curl-lib=C:/curl/bin --with-curl-include=C:/curl/include
  • I put the .dll files in Ruby bin folder, installed the certificate in curl/bin and even run the curl.exe just in case.

I rebooted the machine but I keep seeing the same error.

I do not know what to do. How to successfully install libcurl on Windows for use with Rails

7条回答
干净又极端
2楼-- · 2020-01-31 03:22

Answer that worked for me (W10/Ruby2.6.0) was:

  1. Download cURL from the following URL: https://curl.haxx.se/windows/ (I chose 64bit because that's the system I'm using)
  2. Go into the archive and browse to /bin
  3. Locate libcurl_x64.dll (it may be just libcurl.dll)
  4. Extract to your local drive
  5. Rename it to libcurl.dll if it has the _x64 suffix
  6. Cut + paste the file into the /bin directory of your Ruby installation
查看更多
Summer. ? 凉城
3楼-- · 2020-01-31 03:27

I had the same issue and tried the same steps that OP has listed. After breaking my head, cursing the existence of windows for some time and almost convincing the client to shift to a nix server I figured the libcurl.dll that I downloaded from https://curl.haxx.se/ (as suggested in all related posts) was corrupt.

Downloaded the one provided here http://www.dlldownloader.com/libcurl-dll/ and viola the ffi was able to load this one.

Hope this helps anyone else facing this issue

查看更多
聊天终结者
4楼-- · 2020-01-31 03:27

For anyone running Ruby 2.5 on Windows, my solution was similar to the top solutions however I had to move it to place the file in both the \bin folder and \bin\ruby_builtin_dlls folder to work.

Some other things is that I downloaded the 64bit version and changed its name to libcurl.dll. Also make sure to restart your IDE/terminal and then try to start the server again.

查看更多
倾城 Initia
5楼-- · 2020-01-31 03:28

I want to use wpscan, but i get libcurl error OK, if you also get the same error, then in a very easy way I will try to give the solution.

Just copy the libcurl.dll file to system32 if your windows is 32 bit,

If your windows 64 bit copied to syswo64.

Good luck.

查看更多
看我几分像从前
6楼-- · 2020-01-31 03:29

Well, the issue is caused by a missing lib as said in the error, So the solution is to download the lib here: http://www.dlldownloader.com/libcurl-dll/ and navigate to the ruby folder under bin and drop it there make sure to rename the downloaded .dll file to this exact one: libcurl.dll else won't work even after.

查看更多
Summer. ? 凉城
7楼-- · 2020-01-31 03:40

I just had the same problem on Windows 7 x64 and answered about it here. (Similar to you, I tried a lot of things that I thought should work but didn't.)

What worked was:

  • To take a libcurl.dll from one of the packages found here, https://curl.haxx.se/download.html#Win64, and put it on the PATH.

    (Link was updated, but originally pointed to version 7.40)

  • I just put it under \ruby24\bin\
  • Maybe for you it's C:\Ruby24-x64\bin

(Here are things I tried that didn't work:)

  • Putting on the PATH: the cygcurl-4.dll obtained from the current Curl Download Wizard
  • Renaming the above cygcurl-4.dll to libcurl.dlland putting it on the PATH
  • Installing the msys2 package libcurl-devel 7.57.0-1
  • Renaming the msys-curl-4.dll (from msys2 found at msys64\usr\bin) to libcurl.dll

I didn't try building curl / libcurl from the latest source because I already have the latest according to pacman -Ss libcurl:

msys/libcurl 7.57.0-1 (libraries) [installed]
Multi-protocol file transfer library (runtime)

msys/libcurl-devel 7.57.0-1 (development) [installed]
Libcurl headers and libraries

More details about this in these other questions:

查看更多
登录 后发表回答