简体   繁体   中英

Lambda NodeJS error: libcouchbase.so.2: cannot open shared object file: No such file or directory

I get the error libcouchbase.so.2: cannot open shared object file: No such file or directory in my lambda when it tries to initalize

Running on Lambda using Couchbase and the Node SDK with external C bindings


These are the steps I do to package everything up:

  1. Install libcouchbase rpm package in docker container
  2. Copy across libcouchbase.so , libcouchbase.so.2 and libcouchbase.so.2.0.65 files into deployment package
  3. Install couchbase npm package pointing to the .so files.
  4. Use serverless framework to package and deploy to lambda

Here is a snippet of the commands I run to do so:

WORKDIR /lambda

RUN wget http://packages.couchbase.com/releases/couchbase-release/couchbase-release-1.0-6-x86_64.rpm
RUN rpm -iv couchbase-release-1.0-6-x86_64.rpm
RUN yum install -y libcouchbase-devel libcouchbase2-bin

RUN mkdir -p libs\
  && cp /usr/lib64/libcouchbase.so libs \
  && cp /usr/lib64/libcouchbase.so.2 libs \
  && cp /usr/lib64/libcouchbase.so.2.0.65 libs

RUN npm install couchbase --compile --couchbase-root=libs

The error I get is:

{
  "errorMessage": "libcouchbase.so.2: cannot open shared object file: No such file or directory",
  "errorType": "Error",
  "stackTrace": [
    "Module.load (module.js:565:32)",
    "tryModuleLoad (module.js:505:12)",
    "Function.Module._load (module.js:497:3)",
    "Module.require (module.js:596:17)",
    "require (internal/module.js:11:18)",
    "bindings (/var/task/node_modules/bindings/bindings.js:112:48)",
    "Object.<anonymous> (/var/task/node_modules/couchbase/lib/binding.js:213:36)",
    "Module._compile (module.js:652:30)",
    "Object.Module._extensions..js (module.js:663:10)"
  ]
}

Found the issue. Lambda has LD_LIBRARY_PATH set to /var/task/lib where I was putting the libraries in /var/task/libs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM