anothersmith / node-duckdb

DuckDB NodeJS bindings
MIT License
48 stars 12 forks source link

node-duckdb install fails on ARM mac #150

Open jsteelz opened 2 years ago

jsteelz commented 2 years ago

Using yarn to install node-duckdb fails with the following error message:

CMake Error at /opt/homebrew/Cellar/cmake/3.23.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
  system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY
  OPENSSL_INCLUDE_DIR)
Call Stack (most recent call first):
  /opt/homebrew/Cellar/cmake/3.23.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /opt/homebrew/Cellar/cmake/3.23.0/share/cmake/Modules/FindOpenSSL.cmake:578 (find_package_handle_standard_args)
  CMakeLists.txt:468 (find_package)
  src/main/extension/CMakeLists.txt:9 (add_extension_definitions)

-- Configuring incomplete, errors occurred!
See also "/Users/jsteelz/Transit/duckdb-test/node_modules/node-duckdb/duckdb/build/release/CMakeFiles/CMakeOutput.log".
See also "/Users/jsteelz/Transit/duckdb-test/node_modules/node-duckdb/duckdb/build/release/CMakeFiles/CMakeError.log".
make: *** [release] Error 1
error Command failed with exit code 2.

To Reproduce

in an empty directory on an ARM mac (with yarn) yarn init with whatever yarn add node-duckdb - crash occurs

alannelucq commented 2 years ago

Hello ! I had the same error until I define OPENSSL_ROOT_DIR in ~/.zshrc. But then, I have the following error :

CMake Error at CMakeLists.txt:188 (math):
  math cannot parse the expression: "1.4.9-release+1": syntax error,
  unexpected exp_NUMBER, expecting end of file (4).

-- Found OpenSSL: /opt/homebrew/opt/openssl@3/lib/libcrypto.dylib (found version "3.0.5")
-- Configuring incomplete, errors occurred!
See also "/Users/arthur/Workspace/dashboard-api/node_modules/node-duckdb/duckdb/build/release/CMakeFiles/CMakeOutput.log".
See also "/Users/arthur/Workspace/dashboard-api/node_modules/node-duckdb/duckdb/build/release/CMakeFiles/CMakeError.log".
make: *** [release] Error 1
error Command failed with exit code 2.

CMakeError.log contains following error :

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc 
Build flags: 
Id flags:  

The output was:
1
ld: library not found for -lSystem
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ 
Build flags: 
Id flags:  

The output was:
1
ld: library not found for -lc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@jsteelz Did you manage to fix the problem ?

rgoupil commented 1 year ago

There are two issues with OpenSSL and (node-)duckdb @jsteelz:

  1. You need to install the version 1.1 (for linux this mean building from scratch, on mac you can use brew AFAIR)
  2. On mac, the OpenSSL binary from brew is not in the search path of CMake. You need to run the command again with OPENSSL_ROOT_DIR=/opt/homebrew/Cellar/openssl@1.1/1.1.1s (or whatever path your openssl@1.1 was installed)

@alannelucq, I hope your having fun in your new gig! The problem you mentioned is caused by CMake which, for some reason, is looking for .git to figure find the latest tag to figure the version it is currently at. This is directly from the DuckDB CMake AFAICT and this version is only parsed, nothing useful is made from it. As .git folders are not preserved when uploading to NPM, the only .git CMake can find is the one of your project. This mean that using a format of version including words (like beta, release or others) will break the build as CMake can't parse it. The only way I've found to work around this is to either:

  1. create a blank .git in the node_modules folder, CMake find no tag and keep working happily
  2. stop using words in versions, yes semver handles it but not CMake apparently 😞

While we could make a case that both of these problems stem from the duckdb repository, I would like to point out that the SSL build is optional, however this option seem to be lost (please correct me if I'm wrong) in node-duckdb which forces all of us to install a deprecated SSL version and hack around. It would be great to bring the ability to control the build flags of duckdb, or at least the SSL one since it's a niche feature (accessing files directly through HTTPS) which involve installing a very old and insecure version of OpenSSL.