Uploaded image for project: 'Libmongocrypt'
  1. Libmongocrypt
  2. MONGOCRYPT-600

Cannot install mongodb-client-encryption npm dependency on Alpine

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: Node bindings
    • Labels:
      None

      How to reproduce: on clean Alpine Edge x86_64 system, install `nodejs`, `npm`, `python3`, `gcc`, `g++`, `make` and `krb5-dev` packages (all are needed to build other mongodb node packages, and at least some of them needed to build `mongodb-client-encryption`).

      Then, in a fresh clean directory, do `npm init` and `npm add mongodb-client-encryption`.

      Expected result: everything installs without any errors.

      Actual result:

      ```

      mongo-scratchpad:~/projects/tmp-mongo$ npm add mongodb-client-encryption
      npm ERR! code 1
      npm ERR! path /home/inga/projects/tmp-mongo/node_modules/mongodb-client-encryption
      npm ERR! command failed
      npm ERR! command sh -c prebuild-install --runtime napi --tag-prefix node-v || node-gyp rebuild
      npm ERR! make: Entering directory '/home/inga/projects/tmp-mongo/node_modules/mongodb-client-encryption/build'
      npm ERR!   CXX(target) Release/obj.target/mongocrypt/addon/mongocrypt.o
      npm ERR! make: Leaving directory '/home/inga/projects/tmp-mongo/node_modules/mongodb-client-encryption/build'
      npm ERR! prebuild-install warn install No prebuilt binaries found (target=4 runtime=napi arch=x64 libc=musl platform=linux)
      npm ERR! gyp info it worked if it ends with ok
      npm ERR! gyp info using node-gyp@9.4.0
      npm ERR! gyp info using node@18.18.2 | linux | x64
      npm ERR! gyp info find Python using Python version 3.11.6 found at "/usr/bin/python3"
      npm ERR! gyp info spawn /usr/bin/python3
      npm ERR! gyp info spawn args [
      npm ERR! gyp info spawn args   '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
      npm ERR! gyp info spawn args   'binding.gyp',
      npm ERR! gyp info spawn args   '-f',
      npm ERR! gyp info spawn args   'make',
      npm ERR! gyp info spawn args   '-I',
      npm ERR! gyp info spawn args   '/home/inga/projects/tmp-mongo/node_modules/mongodb-client-encryption/build/config.gypi',
      npm ERR! gyp info spawn args   '-I',
      npm ERR! gyp info spawn args   '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
      npm ERR! gyp info spawn args   '-I',
      npm ERR! gyp info spawn args   '/home/inga/.cache/node-gyp/18.18.2/include/node/common.gypi',
      npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
      npm ERR! gyp info spawn args   '-Dvisibility=default',
      npm ERR! gyp info spawn args   '-Dnode_root_dir=/home/inga/.cache/node-gyp/18.18.2',
      npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
      npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/inga/.cache/node-gyp/18.18.2/<(target_arch)/node.lib',
      npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/inga/projects/tmp-mongo/node_modules/mongodb-client-encryption',
      npm ERR! gyp info spawn args   '-Dnode_engine=v8',
      npm ERR! gyp info spawn args   '--depth=.',
      npm ERR! gyp info spawn args   '--no-parallel',
      npm ERR! gyp info spawn args   '--generator-output',
      npm ERR! gyp info spawn args   'build',
      npm ERR! gyp info spawn args   '-Goutput_dir=.'
      npm ERR! gyp info spawn args ]
      npm ERR! gyp info spawn make
      npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
      npm ERR! In file included from ../addon/mongocrypt.cc:1:
      npm ERR! ../addon/mongocrypt.h:16:10: fatal error: mongocrypt/mongocrypt.h: No such file or directory
      npm ERR!    16 | #include <mongocrypt/mongocrypt.h>
      npm ERR!       |          ^~~~~~~~~~~~~~~~~~~~~~~~~
      npm ERR! compilation terminated.
      npm ERR! make: *** [mongocrypt.target.mk:109: Release/obj.target/mongocrypt/addon/mongocrypt.o] Error 1
      npm ERR! gyp ERR! build error 
      npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
      npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23)
      npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:517:28)
      npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:292:12)
      npm ERR! gyp ERR! System Linux 6.1.57-0-lts
      npm ERR! gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
      npm ERR! gyp ERR! cwd /home/inga/projects/tmp-mongo/node_modules/mongodb-client-encryption
      npm ERR! gyp ERR! node -v v18.18.2
      npm ERR! gyp ERR! node-gyp -v v9.4.0
      npm ERR! gyp ERR! not ok

      ```

      System info:

      ```

      mongo-scratchpad:~/projects/tmp-mongo$ uname -a
      Linux mongo-scratchpad 6.1.57-0-lts #1-Alpine SMP PREEMPT_DYNAMIC Wed, 11 Oct 2023 15:33:17 +0000 x86_64 Linux
      mongo-scratchpad:~/projects/tmp-mongo$ node --version
      v18.18.2
      mongo-scratchpad:~/projects/tmp-mongo$ npm --version
      10.2.0

      ```

      Additional notes: in `node_modules/mongodb-client-encryption/addon`, `mongocrypt.cc` does `#include "mongocrypt.h"`; `mongocrypt.h` does `#include <mongocrypt/mongocrypt.h>`. There is no `mongocrypt/mongocrypt.h` on my system. Perhaps I should install `libmongocrypt` dev package somehow first, but package readme https://www.npmjs.com/package/mongodb-client-encryption does not mention any prerequisites, and there are no `mongocrypt` files in any packages in Alpine repository.

      Trying to find online how to install libmongocrypt produces the link to https://www.mongodb.com/docs/manual/core/queryable-encryption/reference/libmongocrypt/ , but this makes it seem that Alpine is not supported by libmongocrypt. Yet the npm package readme does not mention that.

      The npm package readme does mention that for development (not for ordinary use) one is supposed to run the following command: `bash ./etc/build-static.sh`. Yet there is no `etc` directory in npm package; and in `node-v6.0.0` branch of `libmongocrypt` github repository, there is no `build-static.sh` in `etc` directory.

            Assignee:
            Unassigned Unassigned
            Reporter:
            inga.lovinde@outlook.com Inga L
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: