LoadError: Could not open library 'libcurl' - ruby

curl-7.61.1_6-win64-mingw (for libcurl and curl)
windows 10 OS Build: 17134.346
java version "1.8.0_191"ruby
ruby 2.4.4p296 (2018-03-28 revision 63013) [x64-mingw32]
jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 Java HotSpot(TM) 64-Bit Server VM 25.191-b12 on 1.8.0_191-b12 +jit [mswin32-x86_64]
I'm trying to access a neo4j database using neo4j-core (8.1.4) gem with the HTTP adapter and I receive the error below. A couple of notes:
The machine was originally an 8.1 OS that I upgraded to windows 10. But I have also tried a fresh install.
I'm working with libcurl from curl-7.61.1-win64-mingw. I have tried both the 64 and 32 bit versions.
The NEO4J server works fine
I get the error when I try to establish a session neo4j_session = Neo4j::Core::CypherSession.new(neo4j_adaptor)
I try to install the curb gem and I get the error "Can't find libcurl or curl/curl.h (RuntimeError)". CURB has a dependencies on libcurl (i understand).
The curl.exe is in the path and works great. I ensured that the path containing the libcurl.dll and the curl.exe where first in the path order.
I executed the same script just using ruby, to eliminate any jruby specific issues, with the same problem: (LoadError)libcurl': The specified module could not be found.
I tried to register the dll with RegSvr32 but it says it cannot find the dll. However, the DLL is clearly at the location I'm specifying. I think this supports the idea that its one of libcurls dependencies...but not sure.
At this point its pretty clear that the system cannot find libcurl. So, I:
Update the path to point at the directory that libcurl.dll is in
I also try putting the DLL in known working path locations
Looked on haxx to better understand the prerequisites. No help.
I use dependency walker on libcurl-x64.dll (curl-7.61.1-win64-mingw) and I get the following in the log:
Error: At least one required implicit or forwarded dependency was not found.
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: A circular dependency was detected.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
and here is a sample of a modules it says are missing:
API-MS-WIN-CORE-CONSOLE-L3-2-0.DLL
API-MS-WIN-CORE-CRT-L1-1-0.DLL
API-MS-WIN-CORE-LARGEINTEGER-L1-1-0.DLL
I guess im surprised at the number of modules that are reported as missing considering the machine works fine otherwise. It appears that some were removed as part of architectural changes based on this: https://social.msdn.microsoft.com/Forums/en-US/a28331ae-19a3-4a34-b3ba-1e8fd4430375/missing-apimswincore-dlls
Libcurl is common tool and so I am surprised by the remarkable pain in the ass this has been.
Any thoughts? I'm reluctant to do a clean build at this point and hunting on DLL sites seems like a non starter.
The error
LoadError: Could not open library 'libcurl' : The operation completed successfully.
Could not open library 'libcurl.dll' : The operation completed successfully.
Could not open library 'libcurl.so.4' : The operation completed successfully.
Could not open library 'libcurl.so.4.dll' : The operation completed successfully.
block in ffi_lib at C:/jruby-9.2.0.0/lib/ruby/stdlib/ffi/library.rb:114
map at org/jruby/RubyArray.java:2557
ffi_lib at C:/jruby-9.2.0.0/lib/ruby/stdlib/ffi/library.rb:84
<module:Curl> at C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/ethon-0.11.0/lib/ethon/curls/settings.rb:7
<module:Ethon> at C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/ethon-0.11.0/lib/ethon/curls/settings.rb:2
<main> at C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/ethon-0.11.0/lib/ethon/curls/settings.rb:1
require at org/jruby/RubyKernel.java:970
require at C:/jruby-9.2.0.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59
<module:(root)> at C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/ethon-0.11.0/lib/ethon/curl.rb:1
<module:Curl> at C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/ethon-0.11.0/lib/ethon/curl.rb:27
<main> at C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/ethon-0.11.0/lib/ethon/curl.rb:13
require at org/jruby/RubyKernel.java:970
require at C:/jruby-9.2.0.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59
<main> at C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/ethon-0.11.0/lib/ethon/curl.rb:8
require at org/jruby/RubyKernel.java:970
require at C:/jruby-9.2.0.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59
<main> at C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/ethon-0.11.0/lib/ethon.rb:1
require at org/jruby/RubyKernel.java:970
require at C:/jruby-9.2.0.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59
block in (root) at C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/ethon-0.11.0/lib/ethon.rb:15
block in (root) at C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/typhoeus-1.3.0/lib/typhoeus.rb:1
(root) at C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/typhoeus-1.3.0/lib/typhoeus.rb:2
(root) at C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/neo4j-core-8.1.4/lib/neo4j/core/cypher_session/adaptors/http.rb:1
HTTP at C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/neo4j-core-8.1.4/lib/neo4j/core/cypher_session/adaptors/http.rb:20
block in faraday_connection at C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/neo4j-core-8.1.4/lib/neo4j/core/cypher_session/adaptors/http.rb:162
initialize at C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/faraday-0.15.3/lib/faraday/connection.rb:89
new at C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/faraday-0.15.3/lib/faraday.rb:70
faraday_connection at C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/neo4j-core-8.1.4/lib/neo4j/core/cypher_session/adaptors/http.rb:154
initialize at C:/jruby-9.2.0.0/lib/ruby/gems/shared/gems/neo4j-core-8.1.4/lib/neo4j/core/cypher_session/adaptors/http.rb:117
<main> at import-into-neo4j.rb:11

I've run out of time. The answer is (sadly) a workaround: neography
The neography gem apparently avoids the libcurl dependency which has been a plague on my existence and yet still provides enough abstraction. Thanks.

Related

Running PACT test is throwing a Ruby Load Error

I am trying to run a pact test for a typescript/angular service, from Visual Studio Code .I am getting the following error:
ERROR (15568 ): pact-node#10.11.11: Pact Binary Error: C:/projects/App/sample.webapp/node_modules/#pact-foundation/pact-node/standalone/win32-1.88.40/pact/lib/ruby/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in
`require': cannot load such file -- bundler/setup (ERROR (15568): pact-node#10.11.11: Pact Binary Error: LoadError)
from C:/projects/App/sample.webapp/node_modules/#pact-foundation/pact-node/standalone/win32-1.88.40/pact/lib/ruby/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
This issue was resolved in Ruby v3.0.2 (see this PR https://github.com/ruby/ruby/pull/4505). Though contributors are not going to repack Pact library with the latest Ruby version and still suggest to workaround the problem by locating your project directory close to the root c:\ or start using pact-js v3.
It looks like the infamous windows long path issue. See that issue for further details, but the simplest option is to move your project directory closer to the root of c:.
For context, Ruby is bundled into Pact JS as a core engine for matching, broker interaction, and verification logic. Our v3 (which does not suffer this issue) is going to have a rust core, you can try out the beta here: https://github.com/pact-foundation/pact-js/#pact-js-v3

Typhoeus Windows installation

Tried installing Typhoeus on a Windows 7 environment. Gem installs successfully but when trying to run a simple ruby script::
require 'typhoeus'
Typhoeus.get("www.google.com", verbose: true)
I get the following error::
D:/Ruby193/lib/ruby/gems/1.9.1/gems/ffi-1.9.3-x86-mingw32/lib/ffi/library.rb:133:in `block in ffi_lib': Could not open l
(LoadError)url': 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.
I tried adding curl.exe and libcurl.dll that I found in one of the packages on the curl website but that didn't help. Not sure what to do at this point. Thnks.
Seem to have figured it out. If anyone is having the same issue, make sure to download the following package from curl.haxx.se/download.html
Win32 2000/XP zip 7.34.0 libcurl SSL Günter Knauf 3.34 MB
Extract the bin directory to wherever and make sure to add it to your PATH. I also added .DLL to PATHEXT reset comp and it worked.
I just had the same problem on Windows 7 x64 and answered about it here. Typhoeus requires Ruby-FFI (see this answer) and libcurl.
The accepted answer is a little out of date now, but the same idea works:
Get a libcurl.dll from one of the packages here:
https://curl.haxx.se/gknw.net/7.40.0/dist-w64/ and put it on the PATH.
(I did not add .DLL to the PATHEXT)

Using curb gem and libcurl on Windows

I am trying to install the curb gem, which is libcurl bindings for Ruby, and of course I need to have "A working (lib)curl installation, with development stuff" installed on my computer. So, I went to the cURL Download Wizard and downloaded this package.
But adding the bin into my PATH does not produce improvement and I still get an error when I try to install the curb gem, such as:
extconf.rb:19: Can't find libcurl or curl/curl.h
(RuntimeError)
Even though, curl is already in the PATH.
EDIT: I also tried raking the gem, as per the instructions. It fails saying "make failed" and throwing a bunch of errors like this:
C:/Ruby/lib/ruby/gems/1.8/gems/curb-0.7.7.1/ext/curb_postfield.c:76:
undefined reference to
`_imp__curl_formadd'
Execute Below command for windows only and its works
gem install curb --platform=mswin32
I realise this is a very old question, but I had this exact problem today and found the instructions on someone else's site. These worked for me so I thought I would share them since people with this issue are most likely to come across StackOverflow first: http://jes.al/2012/10/installing-curb-gem-on-windows-7/
In a nutshell:
Get the 32-bit development version of curl (see my notes below)
Add the curl bin directory to your PATH
Run the following command (replacing the paths to curl as necessary)
gem install curb --platform=ruby -- -- --with-curl-lib="C:/curl-7.27.0-devel-mingw32/bin" --with-curl-include="C:/curl-7.27.0-devel-mingw32/include"
A couple of personal notes:
Even though I am on 64-bit Windows 7, I had to download the 32-bit libcurl version under "Win32 - Generic", identified as "Win32 2000/XP zip".
I got the error c:/Ruby193/lib/ruby/1.9.1/mkmf.rb:246:in 'initialize': Permission denied - mkmftmp1.log (Errno::EACCES) while installing the gem. This rather messed up page here suggested that it might be a problem with my anti-virus, and that just retrying a couple of times might work, and indeed, it did.

pg.so problem with Ruby in Windows

I have installed the pg module with help of
gem install pg
Which returned
Successfully installed pg-0.8.0-x86-mswin32-60
When a .rb-file looks like this
require 'rubygems'
require 'pg'
I get an LoadError (exception 126) which tells me that it can't find the module C:/Ruby/lib/ruby/gems/1.8/gems/pg-0.8.0-x86-mswin32-60/lib/pg.so.
I heard something about that it is a Linux compilation. I'm really stuck so I really welcome suggestions.
I have also installed PostgreSQL, I use Windows XP.
Perhaps it's not pg that's missing but some other dependency? Perhaps devkit?: http://blog.smajn.net/2009/07/installing-ruby-191-rails-232-and.html
pg gem depends on PostgreSQL DLL being in the PATH.
In case the required DLL is not found, Ruby will throw a loading error about pg.so
Please check that PostgreSQL binaries and DLL are in the PATH:
SET PATH
Or copy the required DLL (pq.dll) has been copied to Ruby installation directory.
I recommend read this blog article about setting PostgreSQL with new RubyInstaller (One-Click Installer successor):
Install Ruby 1.9.1 and Rails 2.3.2 on Windows Vista
Hope that helps.
I just wrestled with this myself.
1) Make sure C:\Program Files\PostgreSQL\8.4\bin is in your path (as Luis suggested)
2) Make sure the libeay32.dll and ssleay32.dll from C:\Program Files\PostgreSQL\8.4\bin are loaded first. In my case I copied them over from C:\ruby\bin, which (in my case) is first in my path.
I was getting errors like
The ordinal 4046 could not be located in dynamic link library LIBEAY32.dll
and
The ordinal 284 could not be located in the dynamic link library SSLEAY32.DLL
until I did step 2)
Good luck...

Ruby cannot find sqlite3 driver on windows

I am trying to set up Ruby on Rails on windows. I am using the Flash Rails distribution that looks pretty good, but there is an issue with sqlite3. I found the threads telling me to install version 1.2.3, which installed fine. I'm using ruby 1.9.0, and every time I try and run a script (e.g. rake db:create) that uses the database I get an error message "no driver for sqlite3 found".
This apparently is a missing sqlite3.dll, but I have the dll in my %PATH%, and I have also tried copying it into the directory where I am running the script from, the directory where the sqlite3 ruby code lives.
Does anyone have any ideas? If possible I want all teh ruby stuff to be self contained so I can use it from a pen drive.
EDIT: To clarify, I already used gem install to install the ruby-sqlite3 gem - it is just non functional as it cannot find the sqlite3.dll (even though it is actually present in a directory on my %PATH%)
EDIT PART 2: After doing some more digging, the problem appears that ruby will not load the sqlite3_api.dll. I have copied it all over my filesystem, I just get a failure to read file. Other dll libraries in the same directory (e.g. zlib.dll) work fine!
I tried installing the dlls into system32, and that did not work either.
The problem put simply is that sqlite3-ruby 1.2.3 is not compatible with ruby 1.9. This is caused because ruby 1.9 does not use .dll files for c libraries it uses .so files instead. Additionally, since sqlite3_api.dll is written against msvcrt-ruby18.dll. This means that it specifically only will support ruby 1.8.*.
The good news is that there is a fat binary version that will support both ruby 1.8 and ruby 1.9. Uninstalling all former versions of sqlite3-ruby and then installing this one. (You may have to manually delete some versions the gem after uninstalling.) in order to install it use
install sqlite3-ruby --source http://gems.rubyinstaller.org
for more information see this website
Try installing the sqlite3-ruby gem:
gem install sqlite3-ruby
Something similar happened to me recently so I thought I'd update my answer.
For reference there's a sqlite3_api.dll file located in the gem's lib directory. Also the sqlite3.dll file needs to be reachable on the path. They are different files, the first is required by the gem to interface Ruby to C code, while the second contains the actual Sqlite implementation.
It's best to get the second file from the sqlite website and extract it to the Ruby\bin directory (as you shouldn't manually put DLL's into the windows or windows\system directories any more).
So for reference "sqlite3_api.dll" needs to be in:
Ruby\lib\ruby\gems\1.8\gems\sqlite3-ruby-1.2.3-x86-mswin32\lib
and "sqlite3.dll" needs to be on the path, possibly in:
Ruby\bin
As for the "driver not found" problem I would suggest trying the easy things first and making sure gems is installed correctly, up to date, and that the RUBYLIB and PATH environment variables are set appropriately. (System restart may be required to propagate the changes fully.)
Re this link
Download sqlitedll-3_6_10.zip and extract into ruby/bin!
Try going to sqlite.org download page and get the zipped up dll. Then put that in your c:\windows\system32 folder, that should allow Ruby to find it.
Restart your machine after running install sqlite3-ruby
To clarify, which gem are you using? sqlite-ruby or sqlite3-ruby?
They're part of the same project, but different releases. The key is that sqlite3 appears to have driver code included.
I assume you're attempting to use the first, since it's giving me the same error. If so, try switching.
Also.. How literal do you mean by this?
but I have the dll in my %PATH%
PATH=...;C:\sqlite\sqlite3.dll
PATH=...;C:\sqlite
The first will attempt to find C:\sqlite\sqlite3.dll\sqlite3.dll, AFAIK.
I use Ruby 1.8.7 (works with 1.9.1 too)
OS is WindowsXP SP3
Go to
http://www.sqlite.org/download.html
and Download file
sqlitedll-3_7_0_1.zip (265.19 KiB)
and unzip then we will get
sqlite3.dll
Copy sqlite3.dll to your bin folder
as C:\Ruby191\bin or C:\Ruby187\bin
then it works

Resources