[MONGOCRYPT-600] Cannot install mongodb-client-encryption npm dependency on Alpine Created: 18/Oct/23  Updated: 08/Dec/23

Status: Blocked
Project: Libmongocrypt
Component/s: Node bindings
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Unknown
Reporter: Inga L Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on MONGOCRYPT-416 Publish libmongocrypt builds for Alpi... Backlog
Related
is related to MONGOCRYPT-609 Publish libmongocrypt distribution pa... Closed

 Description   

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.



 Comments   
Comment by Angus Ryer [ 08/Dec/23 ]

Created a related ticket: https://jira.mongodb.org/browse/MONGOCRYPT-609

Comment by Angus Ryer [ 07/Dec/23 ]

I'm getting identical behaviour attempting to deploy an encryption-enabled node client to my Amazon Linux 2023 EC2 instance at the `npm i mongodb-client-encryption` step.

Now I'm attempting to install the `libmongocrypt` library on my instance in order to provide the header file indicated in the error but, as stated by the OP regarding Alpine Linux, the MongoDB docs that describe how to do so] do not provide the repository source URL and data to add to the `yum` repo sources list for Amazon Linux 2023, only Amazon Linux 2013.3 and AL2. The existing S3 bucket (https://libmongocrypt.s3.amazonaws.com/) only contains debian packages, no RPMs.

It does look like it's gotten closer to being added as part of MONGOCRYPT-580, however. Maybe it just hasn't been packaged and upload to S3, but I cannot find a JIRA ticket related to this.

As the OP mentions too, there is no `etc` folder nor bash script available to run that comes from the `mongodb-client-encryption`.

 

Comment by Inga L [ 30/Oct/23 ]

Also related: COMPASS-7358.

(The reason I ran into this issue was not because I wanted to use explicit encryption on Alpine, but because I tried to set up a Compass dev environment.)

Generated at Thu Feb 08 09:09:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.