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
I am trying to use the Couchbase Node.JS SDK with external C SDK on AWS Lambda, however, even though I include the .so files into my deployment package, Couchbase is unable to find them.
Everything is installed and packaged for lambda on amazonlinux:latest docker container
Versions used:
- Node.js 8.10
- npm couchbase@2.6.5
- serverless 1.48.2 (to deploy lambda)
These are the steps I do to package everything up:
- Install libcouchbase rpm package in docker container
- Copy across
libcouchbase.so
,libcouchbase.so.2
andlibcouchbase.so.2.0.65
files into deployment package - Install couchbase npm package pointing to the
.so
files. - 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)"
]
}