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

Getting error while using Node v4.2.4 #43

Closed
angelinetran opened this issue Jan 6, 2016 · 36 comments
Closed

Getting error while using Node v4.2.4 #43

angelinetran opened this issue Jan 6, 2016 · 36 comments

Comments

@angelinetran
Copy link

Hello~

Could you help me diagnose my error? Everything was working fine when I was using Node v 0.12.7.

return process.dlopen(module, path._makeLong(filename));
                 ^

Error: dlopen(/Users/angie/projects/node-projects/search-api/node_modules/node-libcurl/lib/binding/node_libcurl.node, 1): Library not loaded: /Users/travis/lib/libcurl.4.dylib
  Referenced from: /Users/angie/projects/node-projects/search-api/node_modules/node-libcurl/lib/binding/node_libcurl.node
  Reason: Incompatible library version: node_libcurl.node requires version 9.0.0 or later, but libcurl.4.dylib provides version 7.0.0

OS: OSX 10.10.5
xcode: 7.2
libcurl: 7.43.0

Thanks!

@JCMais
Copy link
Owner

JCMais commented Jan 6, 2016

Hi, which version of the addon are you using?

@angelinetran
Copy link
Author

Which version of node-libcurl am I using? 0.7.0

@JCMais
Copy link
Owner

JCMais commented Jan 6, 2016

When you updated node.js, did you rebuilt the module? (aka, npm install node-libcurl)

If yes, try running npm install node-libcurl --build-from-source.

I don't have a Mac to test it, but looks like an issue with homebrew from what I can see searching for this error, can you try to update libcurl/homebrew?

@JCMais JCMais added the darwin label Jan 6, 2016
@angelinetran
Copy link
Author

I didn't have homebrew on the computer I'm working in so I installed it, and now I have libcurl v7.46.0.

Running node . I get a different error:

module.js:460
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: Module version mismatch. Expected 46, got 14.
    at Error (native)
    at Object.Module._extensions..node (module.js:460:18)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/angie/projects/node/search-api/node_modules/node-libcurl/lib/Curl.js:27:14)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)

I also tried running tried running npm install node-libcurl --build-from-source and I get this error:

npm WARN enoent ENOENT, open '/Users/angie/projects/node/search-api/node_modules/bin/package.json'
npm WARN enoent ENOENT, open '/Users/angie/projects/node/search-api/node_modules/etc/package.json'
npm WARN enoent ENOENT, open '/Users/angie/projects/node/search-api/node_modules/lib/package.json'
npm WARN search-api@1.0.0 No license field.
npm ERR! Darwin 15.2.0
npm ERR! argv "node" "/Users/angie/projects/node/search-api/node_modules/.bin/npm" "install" "node-libcurl" "--build-from-source"
npm ERR! node v0.12.7
npm ERR! npm  v3.5.2
npm ERR! path /Users/angie/projects/node/search-api/node_modules/.staging/abbrev-ad080861
npm ERR! code ENOENT
npm ERR! errno -2

npm ERR! enoent ENOENT, rename '/Users/angie/projects/node/search-api/node_modules/.staging/abbrev-ad080861'
npm ERR! enoent ENOENT, rename '/Users/angie/projects/node/search-api/node_modules/.staging/abbrev-ad080861'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/angie/projects/node/search-api/npm-debug.log

Thank you so much for helping me!

@JCMais
Copy link
Owner

JCMais commented Jan 7, 2016

Looks like an issue with npm, try cleaning the cache and reinstalling the node modules:

$ npm clean cache
$ rm -rf node_modules

@angelinetran
Copy link
Author

yay!

That did the trick.

Thank you so much!

Btw, for reference the first command needs to be switched around to be $ npm cache clean

@JCMais
Copy link
Owner

JCMais commented Jan 7, 2016

Glad you got it fixed!

@JCMais JCMais closed this as completed Jan 7, 2016
@yoshprogrammer
Copy link

@JCMais I'm experiencing this issue as well... Any thoughts?

I have libcurl 7.43.0 and followed these same commands as you instructed. Even clearing the cache, deleting node_modules and rebuilding them.

module.js:435
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: dlopen(/Users/jbrown/Documents/projects/Weebly-API/node_modules/node-libcurl/lib/binding/node_libcurl.node, 1): Library not loaded: /Users/travis/lib/libcurl.4.dylib
  Referenced from: /Users/jbrown/Documents/projects/Weebly-API/node_modules/node-libcurl/lib/binding/node_libcurl.node
  Reason: Incompatible library version: node_libcurl.node requires version 9.0.0 or later, but libcurl.4.dylib provides version 7.0.0
    at Error (native)
    at Object.Module._extensions..node (module.js:435:18)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/jbrown/Documents/projects/Weebly-API/node_modules/node-libcurl/lib/Easy.js:38:29)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/jbrown/Documents/projects/Weebly-API/node_modules/node-libcurl/index.js:1:74)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)

@JCMais
Copy link
Owner

JCMais commented Feb 4, 2016

This is an issue with the libcurl version installed, it wants compatibility with library version 4 (Which probably means Mac 10.4), but this module only supports 9 (Mavericks, 10.9) or later. So it doesn't want to open libcurl.

I really don't know how to fix this since I don't own a Mac, but from what I could gather doing some research you can try to install homebrew which has a libcurl version compiled with the latest xcode.

@yoshprogrammer
Copy link

Interesting cause I'm running 10.10.5
I'll see if I can get it to work, otherwise I'll switch to laravel framework for the project im trying to do.

thanks

@yoshprogrammer
Copy link

Yeah I'm already running Homebrew and installed latest curl + libcurl so just an odd error. Bummer, was hoping this library would work for me.

Thanks anyways

@JCMais
Copy link
Owner

JCMais commented Feb 4, 2016

The Mac version you have installed is not the cause, but the minimum version required by the libcurl module (not this addon). This is set while compiling it.

@yoshprogrammer
Copy link

ahh I see, the libcurl itself is saying hey I need compatibility with 4 but this module is 9+

@JCMais
Copy link
Owner

JCMais commented Feb 4, 2016

yup, the easy way to fix that is you getting libcurl and compiling it from source, if you have the time to do that, it would be like the following:

$ cd ~
$ git clone https://github.com/curl/curl.git --single-branch --branch=curl-7_47_0 && cd curl
$ git checkout curl-7_47_0
$ export MACOSX_DEPLOYMENT_TARGET="10.8"
$ export PATH=$PATH:~/curl-binaries
$ ./configure --prefix=~/curl-binaries --with-darwinssl --disable-shared --enable-static
$ make && make install
$ npm install node-libcurl --build-from-source

@yoshprogrammer
Copy link

@JCMais i'll try that, i'd rather avoid losing some of the node work i've done so far for this project

@yoshprogrammer
Copy link

@JCMais running into a snag, it doesn't appear there is a configure file or directory when getting to that step, i've googled but not much help so far. Any pointers on what that means/why it's saying no such file or dir?

@JCMais
Copy link
Owner

JCMais commented Feb 4, 2016

I've missed the call to ./buildconf before the ./configure.

Ping me on gitter if you have other issues.

@yoshprogrammer
Copy link

Will do thanks for going above and beyond on this!

@kohanyirobert
Copy link

Sorry for updating a closed issue, but I was having the same problem and I was able to solve it without building manually anything.

I just removed the module npm uninstall node-libcurl then reinstalled it npm install node-libcurl --build-from-source after that I saw the following

> node-pre-gyp install --fallback-to-build

  CXX(target) Release/obj.target/node_libcurl/src/node_libcurl.o
  CXX(target) Release/obj.target/node_libcurl/src/Easy.o
  CXX(target) Release/obj.target/node_libcurl/src/Share.o
  CXX(target) Release/obj.target/node_libcurl/src/Multi.o
  ...

and then it was working. If I just installed it with npm install node-libcurl the following was logged

> node-libcurl@0.8.0 install /Users/.../node_modules/node-libcurl
> node-pre-gyp install --fallback-to-build

[node-libcurl] Success: "/Users/.../node_modules/node-libcurl/lib/binding/node_libcurl.node" is installed via remote

I don't know what installed via remote means, but essentially it doesn't work that way, only if the library is built locally. Hope this helps others.

@JCMais
Copy link
Owner

JCMais commented Feb 27, 2016

I don't know what installed via remote means

It means that one pre built binary for your system was found, however you are probably getting one error when trying to use the library because it was compiled with one more recent toolchain, that your system currently doesn't have, that is why it works when you use --build-from-source, because it ignores the prebuilt binaries and just build it directly, using the toolchain you currently have.

@sridharspeaks
Copy link

@kohanyirobert thank you, your solution simply worked for me.

@simiansim
Copy link

Just pointing this out that all of these people reported exactly "Library not loaded: /Users/travis/lib/libcurl.4.dylib", and I don't think any of those people are named "travis". This is a baked-in incorrect reference.

The compiled file "node_modules/node-libcurl/lib/binding/node_libcurl.node" contains this reference (BTW: the "Users/travis" directory does not exist on my machine either, in case that was a surprise). The fact that this actually works for most people on a Mac seems very accidental (It fails trying an invalid ref before trying other system paths).

Once rebuilt with the commands described above there is no such reference at all ("travis" or otherwise), in the binding file.

@meabed
Copy link

meabed commented Sep 27, 2017

@simiansim
you are right, i have installed

npm install node-pre-gyp -g
npm install node-libcurl --build-from-source --fallback-to-build

and it works just fine, i am sure this travis issue is something but the message displayed is wrong maybe.

@peterruijter
Copy link

Sorry for commenting on this closed issue, but what helped me to solve this problem is:
brew update && brew upgrade and lastly brew reinstall curl

The suggested solution that @JCMais gave on 4 Feb 2016, does not create or replace the libcurl.4.dylib file what the source of the problem is and where the compiler is complaining about.

I hope this solution will work for someone else too...

@simiansim
Copy link

What you are doing by running brew is to separately install curl and ensure that libcurl.4.dylib is "somewhere" on your system path & it only works if the place that brew installs it is also on your system path. While I am not sure, I suspect (hope) that @JCMais is updating the build automation (travis) that creates the bindings so that you don't have to fix it externally.

@JCMais
Copy link
Owner

JCMais commented Oct 25, 2017

I'm keeping an eye on this issue, but currently I'm not having time to work on it, if anyone has the opportunity and know-how to fix it, it would be awesome.

@JCMais
Copy link
Owner

JCMais commented Aug 17, 2018

reopening this since it's still an issue.

For a matter of fact, there is travis on the path of the linked library because the process of generating macOS prebuilt binaries is by building the library in a macOS environment on Travis CI, the build config is here if anyone can take a look: https://github.com/JCMais/node-libcurl/blob/84006ec/.travis.yml

This issue is really hard for me to track down, since I don't have access to a mac right now.

@koskokos2
Copy link
Contributor

koskokos2 commented Aug 17, 2018

Full path should be replaced with @rpath and rpaths added for mac, so basically after node_libcurl.node is built we need to execute:

install_name_tool -change /Users/travis/lib/libcurl.4.dylib @rpath/libcurl.4.dylib node_libcurl.node && install_name_tool -add_rpath /opt/local/lib node_libcurl.node && install_name_tool -add_rpath /usr/lib node_libcurl.node

@koskokos2
Copy link
Contributor

koskokos2 commented Aug 19, 2018

I submitted changes to binding.gyp that will fix this issue. They make output of "otool -L" look way better and "otool -l" has standard paths to libs on mac.
otool -L lib/binding/node_libcurl.node
lib/binding/node_libcurl.node:
@rpath/libcurl.dylib (compatibility version 10.0.0, current version 10.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.4.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)

@simiansim
Copy link

simiansim commented Aug 20, 2018

I tried @koskokos2's branch "linking-improvement-mac", and found it works mostly... certainly looking in the right direction.

Specifically the use of install_name_tool to change the linking paths is important. Playing with the specific set of paths passed to install_name_tool -change will likely be the solution.
https://github.com/koskokos2/node-libcurl/blob/linking-improvement-mac/binding.gyp#L119

my results.

doing an npm install resulted in a lib/binding/node_libcurl.node binary file that contains a reference to "/Users/travis" (visually found string within the binary file). Running some code that used the module resulted in Reason: Incompatible library version: node_libcurl.node requires version 10.0.0 or later, but libcurl.4.dylib provides version 7.0.0
I assume this is using a prebuilt binary and so once these binaries are replaced maybe it will start to work.

npm install --rebuild --build-from-source

So at this point my test code started to work... but again I am worried it is finding the path incorrectly. I am including info about my system. /usr/local/lib seems to be my working lib location.

The resulting binding file contained a reference using @rpath and some system paths
@rpath/libcurl.dylib, /opt/local/lib, /usr/local/lib, /usr/lib

otool run against the binding file shows an issue

otool -L lib/binding/node_libcurl.node 
lib/binding/node_libcurl.node:
        @rpath/libcurl.dylib (compatibility version 7.0.0, current version 9.0.0)
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)

on my system the build seems to point towards
/usr/lib/libcurl.4.dylib as the destination location place to find libcurl. otool reports this as 7.0.0 compatible,
/usr/local/lib/libcurl.4.dylib reports as 9.0.0 compatible,
and /usr/local/Cellar/curl/7.61.0/lib/libcurl.4.dylib (the one homebrew will install) reports as 10.0.0 compatible.

...I am not an expert on otool and install_name_tool (and its tricks like rpath) either. I found this background info:
https://medium.com/@donblas/fun-with-rpath-otool-and-install-name-tool-e3e41ae86172
https://wincent.com/wiki/@executable_path,_@load_path_and_@rpath

@berstend
Copy link

Ran into the same issue today:

 Reason: Incompatible library version: node_libcurl.node requires version 10.0.0 or later, but libcurl.4.dylib provides version 7.0.0

Switched to @koskokos2's branch (thanks!) and everything is super now 🎉:

yarn add koskokos2/node-libcurl#linking-improvement-mac
console.log(require('node-libcurl').Curl.getVersion())
// => libcurl/7.43.0 SecureTransport zlib/1.2.5

@koskokos2
Copy link
Contributor

I added one more path that will handle Brew when does not want to mess with system curl and is using special path. Now I think it is ready to be merged.

@simiansim
Copy link

LGTM too.

@JCMais JCMais closed this as completed in 56c2be4 Aug 25, 2018
@JCMais
Copy link
Owner

JCMais commented Aug 26, 2018

just published an alpha release for that, if anyone wanna test: node-libcurl@next

@pietermees
Copy link
Contributor

@JCMais worked for me!

@JCMais
Copy link
Owner

JCMais commented Sep 6, 2018

Glad to hear, all props to @koskokos2 for the awesome work!

I will cut a major release some time next week.

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

No branches or pull requests