JStriedinger
JStriedinger

Reputation: 569

How to solve 'libcurl' not found with Rails on Windows

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 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

Upvotes: 39

Views: 21524

Answers (9)

David Airapetyan
David Airapetyan

Reputation: 5620

None of the solutions worked for me - no matter what I tried, libcurl failed to load.

I then did the following:

  1. Created a mini Ruby program that just tried loading the dll:
require 'ffi'

FFI::DynamicLibrary.open("libcurl", FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL)
  1. Ran procmon and filtered by ruby.exe process and any path containing "dll"

As a result, I saw the following:

C:\Ruby27-x64\bin\libzstd.dll - NAME NOT FOUND

That gave me an idea that I was missing a dependency. The libzstd.dll file is part of the mingw-w64-x86_64-zstd package but luckily I just had it sitting on my drive elsewhere (as part of the GIMP installation).

I copied libzstd.dll to C:\Ruby27-x64\bin and the problem was solved. Of course, I had libcurl.dll in my path already (got it from https://curl.haxx.se/windows)

Upvotes: 1

Luar Faria
Luar Faria

Reputation: 49

The solution which worked for me was download the dll, keep the exact name libcurl.dll and copy it to c:\windows\system32

Upvotes: 0

Marcus Salinas
Marcus Salinas

Reputation: 366

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.

Upvotes: 2

Newtoxton
Newtoxton

Reputation: 186

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.

Upvotes: 0

TT--
TT--

Reputation: 3205

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:

Upvotes: 14

Richard Peck
Richard Peck

Reputation: 76784

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

Upvotes: 60

0px
0px

Reputation: 7

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.

Upvotes: 0

ZX12R
ZX12R

Reputation: 4826

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

Upvotes: 7

barpaio
barpaio

Reputation: 1

If you're using WSL on Windows 10 (Make sure to update to Ubuntu 16.04) the following instructions worked perfectly for me. You might need to completely wipe what you have installed however. Within bash:

sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev postgresql-client-common postgresql-client libpq-dev

And then to build our path and plugin directory for rbenv:

cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

Finally we come to ruby:

rbenv install 2.4.1
rbenv global 2.4.1

Then bundler:

gem install bundler
rbenv rehash

Now our prerequisites:

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs

And then finally Rails:

gem install rails
rbenv rehash

Upvotes: -1

Related Questions