Unable to install on macOS 11.4 Apple Silicon Node v16.4
Hi. I get the errors as below when trying to npm install in the environment noted in the description. We have other systems running identical (as far as we can tell) OS and other dependencies, but on macOS for Intel, and they build the same project just fine. Wondering if there is something still not right with node-libcurl on Node v16 and Apple Silicon, even at node-libcurl 2.3.3. Have tried at Node v16.4.0 and v16.4.2 FWIW.
Here's an extract from the log file:
1371 info run [email protected] install { code: 1, signal: null }
1372 info run [email protected] install { code: 0, signal: null }
1373 timing build:run:install:node_modules/fsevents Completed in 2043ms
1374 timing reify:rollback:createSparse Completed in 1585ms
1375 timing reify:rollback:retireShallow Completed in 1ms
1376 timing command:install Completed in 21734ms
1377 verbose stack Error: command failed
1377 verbose stack at ChildProcess.emit (node:events:394:28)
1377 verbose stack at maybeClose (node:internal/child_process:1067:16)
1377 verbose stack at Socket.<anonymous> (node:internal/child_process:453:11)
1377 verbose stack at Socket.emit (node:events:394:28)
1379 verbose cwd /Users/myname/GitHub/XC2-User-BE
1380 verbose Darwin 20.5.0
1382 verbose node v16.4.2
1383 verbose npm v7.18.1
1384 error code 1
1385 error path /Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl
1386 error command failed
1387 error command sh -c node-pre-gyp install --fallback-to-build
1389 error node-pre-gyp info it worked if it ends with ok
1389 error node-pre-gyp info using [email protected]
1389 error node-pre-gyp info using [email protected] | darwin | arm64
1389 error node-pre-gyp WARN Using request for node-pre-gyp https download
1389 error gyp info it worked if it ends with ok
1389 error gyp info using [email protected]
1389 error gyp info using [email protected] | darwin | arm64
1389 error gyp info ok
1389 error (Use `node --trace-deprecation ...` to show where the warning was created)
1389 error gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.9
1389 error gyp info spawn args [
1389 error gyp info spawn args '/Users/myname/.nvm/versions/node/v16.4.2/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
1389 error gyp info spawn args '-I',
1389 error gyp info spawn args '/Users/myname/Library/Caches/node-gyp/16.4.2/include/node/common.gypi',
1389 error gyp info spawn args '-Dlibrary=shared_library',
1389 error gyp info spawn args '-Dnode_lib_file=/Users/myname/Library/Caches/node-gyp/16.4.2/<(target_arch)/node.lib',
1389 error gyp info spawn args '-Dmodule_root_dir=/Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl',
1389 error gyp info spawn args '-Dnode_engine=v8',
1389 error gyp info spawn args '--depth=.',
1389 error gyp info spawn args '--no-parallel',
1389 error gyp info spawn args '--generator-output',
1389 error gyp info spawn args 'build',
1389 error gyp info spawn args '-Goutput_dir=.'
1389 error gyp info spawn args ]
1389 error error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool-classic: can't open file: /usr/lib/libcurl.dylib (No such file or directory)
1389 error gyp: Call to 'otool -D `curl-config --prefix`/lib/libcurl.dylib | sed -n 2p' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
1389 error gyp ERR! configure error
1389 error gyp ERR! stack Error: `gyp` failed with exit code: 1
1389 error gyp ERR! stack at ChildProcess.onCpExit (/Users/myname/.nvm/versions/node/v16.4.2/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
1389 error gyp ERR! stack at ChildProcess.emit (node:events:394:28)
1389 error gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
1389 error gyp ERR! System Darwin 20.5.0
1389 error gyp ERR! command "/Users/myname/.nvm/versions/node/v16.4.2/bin/node" "/Users/myname/.nvm/versions/node/v16.4.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl/lib/binding/node_libcurl.node" "--module_name=node_libcurl" "--module_path=/Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl/lib/binding" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93"
1389 error gyp ERR! cwd /Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl
1389 error gyp ERR! node -v v16.4.2
1389 error gyp ERR! node-gyp -v v7.1.2
1389 error gyp ERR! not ok
1389 error node-pre-gyp ERR! build error
1389 error node-pre-gyp ERR! stack Error: Failed to execute '/Users/myname/.nvm/versions/node/v16.4.2/bin/node /Users/myname/.nvm/versions/node/v16.4.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl/lib/binding/node_libcurl.node --module_name=node_libcurl --module_path=/Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl/lib/binding --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
1389 error node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/Users/myname/GitHub/XC2-User-BE/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
1389 error node-pre-gyp ERR! stack at ChildProcess.emit (node:events:394:28)
1389 error node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1067:16)
1389 error node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
1389 error node-pre-gyp ERR! System Darwin 20.5.0
1389 error node-pre-gyp ERR! command "/Users/myname/.nvm/versions/node/v16.4.2/bin/node" "/Users/myname/GitHub/XC2-User-BE/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
1389 error node-pre-gyp ERR! cwd /Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl
1389 error node-pre-gyp ERR! node -v v16.4.2
1389 error node-pre-gyp ERR! node-pre-gyp -v v0.15.0
1389 error node-pre-gyp ERR! not ok
1390 verbose exit 1
Now I am seeing the following, which is perhaps some progress, and more directly implicating node-libcurl:
1374 info run [email protected] install node_modules/fsevents node install.js
1375 info run [email protected] install node_modules/node-libcurl node-pre-gyp install --fallback-to-build
1376 info run [email protected] install { code: 1, signal: null }
1377 info run [email protected] install { code: 0, signal: null }
1378 timing build:run:install:node_modules/fsevents Completed in 1696ms
1379 timing reify:rollback:createSparse Completed in 1021ms
1380 timing reify:rollback:retireShallow Completed in 0ms
1381 timing command:install Completed in 21389ms
1382 verbose stack Error: command failed
1382 verbose stack at ChildProcess.<anonymous> (/Users/myname/.nvm/versions/node/v16.5.0/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
1382 verbose stack at ChildProcess.emit (node:events:394:28)
1382 verbose stack at maybeClose (node:internal/child_process:1067:16)
1382 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
1383 verbose pkgid [email protected]
1384 verbose cwd /Users/myname/GitHub/XC2-User-BE
1385 verbose Darwin 20.5.0
1386 verbose argv "/Users/myname/.nvm/versions/node/v16.5.0/bin/node" "/Users/myname/.nvm/versions/node/v16.5.0/bin/npm" "install"
1387 verbose node v16.5.0
1388 verbose npm v7.19.1
1389 error code 1
1390 error path /Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl
1391 error command failed
1392 error command sh -c node-pre-gyp install --fallback-to-build
1393 error Failed to execute '/Users/myname/.nvm/versions/node/v16.5.0/bin/node /Users/myname/.nvm/versions/node/v16.5.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl/lib/binding/node_libcurl.node --module_name=node_libcurl --module_path=/Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl/lib/binding --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
1394 error node-pre-gyp info it worked if it ends with ok
1394 error node-pre-gyp info using [email protected]
1394 error node-pre-gyp info using [email protected] | darwin | arm64
1394 error node-pre-gyp WARN Using request for node-pre-gyp https download
1394 error node-pre-gyp info check checked for "/Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl/lib/binding/node_libcurl.node" (not found)
1394 error node-pre-gyp http GET https://github.com/JCMais/node-libcurl/releases/download/v2.3.3/node_libcurl-v2.3.3-node-v93-darwin-arm64-unknown.tar.gz
1394 error node-pre-gyp http 404 https://github.com/JCMais/node-libcurl/releases/download/v2.3.3/node_libcurl-v2.3.3-node-v93-darwin-arm64-unknown.tar.gz
1394 error node-pre-gyp WARN Tried to download(404): https://github.com/JCMais/node-libcurl/releases/download/v2.3.3/node_libcurl-v2.3.3-node-v93-darwin-arm64-unknown.tar.gz
1394 error node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v93 ABI, unknown) (falling back to source compile with node-gyp)
1394 error node-pre-gyp http 404 status code downloading tarball https://github.com/JCMais/node-libcurl/releases/download/v2.3.3/node_libcurl-v2.3.3-node-v93-darwin-arm64-unknown.tar.gz
1394 error gyp info it worked if it ends with ok
1394 error gyp info using [email protected]
1394 error gyp info using [email protected] | darwin | arm64
1394 error gyp info ok
1394 error gyp info it worked if it ends with ok
1394 error gyp info using [email protected]
1394 error gyp info using [email protected] | darwin | arm64
1394 error gyp info find Python using Python version 3.8.2 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
1394 error (node:35713) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
1394 error (Use `node --trace-deprecation ...` to show where the warning was created)
1394 error gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
1394 error gyp info spawn args [
1394 error gyp info spawn args '/Users/myname/.nvm/versions/node/v16.5.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
1394 error gyp info spawn args 'binding.gyp',
1394 error gyp info spawn args '-f',
1394 error gyp info spawn args 'make',
1394 error gyp info spawn args '-I',
1394 error gyp info spawn args '/Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl/build/config.gypi',
1394 error gyp info spawn args '-I',
1394 error gyp info spawn args '/Users/myname/.nvm/versions/node/v16.5.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
1394 error gyp info spawn args '-I',
1394 error gyp info spawn args '/Users/myname/Library/Caches/node-gyp/16.5.0/include/node/common.gypi',
1394 error gyp info spawn args '-Dlibrary=shared_library',
1394 error gyp info spawn args '-Dvisibility=default',
1394 error gyp info spawn args '-Dnode_root_dir=/Users/myname/Library/Caches/node-gyp/16.5.0',
1394 error gyp info spawn args '-Dnode_gyp_dir=/Users/myname/.nvm/versions/node/v16.5.0/lib/node_modules/npm/node_modules/node-gyp',
1394 error gyp info spawn args '-Dnode_lib_file=/Users/myname/Library/Caches/node-gyp/16.5.0/<(target_arch)/node.lib',
1394 error gyp info spawn args '-Dmodule_root_dir=/Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl',
1394 error gyp info spawn args '-Dnode_engine=v8',
1394 error gyp info spawn args '--depth=.',
1394 error gyp info spawn args '--no-parallel',
1394 error gyp info spawn args '--generator-output',
1394 error gyp info spawn args 'build',
1394 error gyp info spawn args '-Goutput_dir=.'
1394 error gyp info spawn args ]
1394 error error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libcurl.dylib (No such file or directory)
1394 error gyp: Call to 'otool -D `curl-config --prefix`/lib/libcurl.dylib | sed -n 2p' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
1394 error gyp ERR! configure error
1394 error gyp ERR! stack Error: `gyp` failed with exit code: 1
1394 error gyp ERR! stack at ChildProcess.onCpExit (/Users/myname/.nvm/versions/node/v16.5.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
1394 error gyp ERR! stack at ChildProcess.emit (node:events:394:28)
1394 error gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
1394 error gyp ERR! System Darwin 20.5.0
1394 error gyp ERR! command "/Users/myname/.nvm/versions/node/v16.5.0/bin/node" "/Users/myname/.nvm/versions/node/v16.5.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl/lib/binding/node_libcurl.node" "--module_name=node_libcurl" "--module_path=/Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl/lib/binding" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93"
1394 error gyp ERR! cwd /Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl
1394 error gyp ERR! node -v v16.5.0
1394 error gyp ERR! node-gyp -v v7.1.2
1394 error gyp ERR! not ok
1394 error node-pre-gyp ERR! build error
1394 error node-pre-gyp ERR! stack Error: Failed to execute '/Users/myname/.nvm/versions/node/v16.5.0/bin/node /Users/myname/.nvm/versions/node/v16.5.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl/lib/binding/node_libcurl.node --module_name=node_libcurl --module_path=/Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl/lib/binding --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
1394 error node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/Users/myname/GitHub/XC2-User-BE/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
1394 error node-pre-gyp ERR! stack at ChildProcess.emit (node:events:394:28)
1394 error node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1067:16)
1394 error node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
1394 error node-pre-gyp ERR! System Darwin 20.5.0
1394 error node-pre-gyp ERR! command "/Users/myname/.nvm/versions/node/v16.5.0/bin/node" "/Users/myname/GitHub/XC2-User-BE/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
1394 error node-pre-gyp ERR! cwd /Users/myname/GitHub/XC2-User-BE/node_modules/node-libcurl
1394 error node-pre-gyp ERR! node -v v16.5.0
1394 error node-pre-gyp ERR! node-pre-gyp -v v0.15.0
1394 error node-pre-gyp ERR! not ok
1395 verbose exit 1
OK I think I am past this issue. Regarding both traces above:
First trace:
- Likely due to not well installed xcode-select
Second trace:
- Resolved by:
brew install curl-opensslexport PATH="/opt/homebrew/opt/curl/bin:$PATH" >> ~/.zshrc
+1 having this issue as well
Edit: Thank you @pbryant-xag! Your solution fixed the issue for me!
Second trace:
- Resolved by:
brew install curl-opensslexport PATH="/opt/homebrew/opt/curl/bin:$PATH" >> ~/.zshrc
I think I'm running into a similar issue with node-libcurl over here: https://github.com/Homebrew/homebrew-core/pull/86456
Is the expectation that node-libcurl should be depending on the libcurl.dylib installed via homebrew on Mac OS 11.6+?
Is the expectation that node-libcurl should be depending on the libcurl.dylib installed via homebrew on Mac OS 11.6+?
@curiositycasualty no it is not, my expectation is that the library should work with the macOS version of libcurl. We do have an expectation (probably not that well documented) that curl-config is available when doing the macOS build. This happens because of the postbuild step we have for macOS here: https://github.com/JCMais/node-libcurl/blob/35f21f8cae7018e1a947cc3a9364e460b2dc3b5b/binding.gyp#L223-L234
This postbuild step was added to make sure we are using @rpath to search for the libcurl library (when building with dynamic linking). This was done here: https://github.com/JCMais/node-libcurl/pull/145 by @koskokos2 to fix a different issue (#43).
We are setting the search paths here: https://github.com/JCMais/node-libcurl/blob/35f21f8cae7018e1a947cc3a9364e460b2dc3b5b/binding.gyp#L169-L177
The issue presented in the OP is happening in the postbuild step, as it is shown here:
1394 error error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libcurl.dylib (No such file or directory)
1394 error gyp: Call to 'otool -D `curl-config --prefix`/lib/libcurl.dylib | sed -n 2p' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
It seems that it is not able to find the file returned by: $(curl-config --prefix)/lib/libcurl.dylib, which in this case is /usr/lib/libcurl.dylib.
In the issue that you linked above, @SMillerDev mentions the following:
You're fixing a symptom with that dependency, not the problem. The problem is that it's trying to read a system dylib file, but those aren't accessible as normal files in macOS. You can only access them by including them.
So it seems the initial expectation that it should work with the system libcurl version is not really valid, as if this file is never available on macOS (with the command line tools installed), otool will always return the above error.
I'm trying to get a hold of a macOS so I can better investigate this. But I do lack some expertise with those linking issues, so any help on how to fix this would be appreciated.
Seems like the folks over here dealt/are dealing with a similar issue: https://github.com/tarantool/tarantool/issues/5543#issuecomment-752326777
https://github.com/nodejs/node-gyp/issues/892 is maybe a more useful example since they breakdown usage of install_name_tool
OK I think I am past this issue. Regarding both traces above:
First trace:
- Likely due to not well installed xcode-select
Second trace:
- Resolved by:
brew install curl-opensslexport PATH="/opt/homebrew/opt/curl/bin:$PATH" >> ~/.zshrc
Just noting that this worked for me again on another M1 Mac, and on macOS 12.0.1, from the same error message. I know this shouldn't be surprising, but it is alway pleasing nonetheless.
@JCMais I'm not sure I have depth of skills to help you here, but would gladly do so if I can. I can at least test things for you on macOS, for example, and you can go ahead and fire me if I'm not up to the job!
Hi Guys,
Follow this tutorial to resolve this problem:
This error invoke because curl-config --prefix/lib/libcurl.dylib | sed -n 2p' dont is valid in MacOS or in curl in my file binding.gyp
before:
'conditions': [['OS=="mac" and curl_static_build!="true"', {
'postbuilds': [
{
'postbuild_name': '@rpath for libcurl',
'action': [
'install_name_tool',
'-change',
'<!@(otool -D `curl-config --prefix`/lib/libcurl.dylib | sed -n 2p)',
'@rpath/libcurl.dylib',
'<(module_path)/<(module_name).node'
],
},
]
but my currently path valid is =>
'conditions': [['OS=="mac" and curl_static_build!="true"', {
'postbuilds': [
{
'postbuild_name': '@rpath for libcurl',
'action': [
'install_name_tool',
'-change',
'<!@(otool -D `curl-config --prefix`/local/opt/curl/lib/libcurl.dylib | sed -n 2p)',
'@rpath/libcurl.dylib',
'<(module_path)/<(module_name).node'
],
},
]
/lib/libcurl.dylib => /local/opt/curl/lib/libcurl.dylib
After of alter path in file my process of build binding.gyp work fine.
Same thing happening for me on x86, neither node 16.16 or 18.16 works, trying to build under electron v23
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool-classic: can't open file: /usr/lib/libcurl.dylib (No such file or directory)
gyp: Call to 'otool -D `curl-config --prefix`/lib/libcurl.dylib | sed -n 2p' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/Users/myuser/hacking/union-mono/node_modules/node-gyp/lib/configure.js:259:16)
gyp ERR! stack at ChildProcess.emit (node:events:513:28)
gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Darwin 21.4.0
Darwin dev-team.local 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64 x86_64
curl-openssl & xcode-select seems to be working correctly
> sudo xcode-select --install
Password:
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
> brew install curl-openssl
Warning: Use curl instead of deprecated curl-openssl
Warning: Use curl instead of deprecated curl-openssl
Warning: curl 7.86.0 is already installed and up-to-date.
To reinstall 7.86.0, run:
brew reinstall curl
brew reinstall curl or brew reinstall curl-openssl also did not solve the issue
I tried manually copying the dylib but it also seems that we are no longer able to write files under "/" after Catalina (https://stackoverflow.com/a/57445554/1922857)
This
postbuildstep was added to make sure we are using@rpathto search for the libcurl library (when building with dynamic linking). This was done here: #145 by @koskokos2 to fix a different issue (#43).
I wonder if this postbuild step is still necessary? It looks like it was originally added because the pre-built binaries were dynamically linking to a non-system copy of curl, which wasn't there on anyone's computer that downloaded it and so didn't work.
That's no longer an issue, since the pre-built binaries are now statically linked. So, I think it might be fine to go back to just baking in the path to whichever version of curl node-libcurl is being built against. The only benefit that I can still see from using @rpath here is that if you build against a non-system version of curl and then uninstall it, it'll automatically fall back to using the system version of curl.
This should be fixed on v4