Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

couchbase=1.0.0-alpha.4 not working with libcouchbase setup on bullseye and buster #136

Open
anshul-mohil opened this issue Oct 21, 2021 · 6 comments

Comments

@anshul-mohil
Copy link

anshul-mohil commented Oct 21, 2021

Problem:

Unable to run application using couchbase=1.0.0-alpha.4 as it require a specific libcouchbase binary which is not present after C SDK setup.

C SDK setup doesn't seems to generate /usr/lib/x86_64-linux-gnu/libcouchbase.so.6 binary for buster and bullseye debian versions, which seems to be required by couchbase-rs based app to run.

Error:

/usr/bin/rust-api: error while loading shared libraries: libcouchbase.so.6: cannot open shared object file: No such file or directory

libcouchbase binaries seems to have slightly different binary names on different debian/libcouchbase(2/3) versions when following C SDK setup guide. Is couchbase-rs tightly coupled with libcouchbase.so.6 file?

Environment/Setup details:

App dependencies same as mentioned at #135 (switched to using couchbase=1.0.0-alpha.4)
Build env: Docker image rust:1-bullseye OR rust:1-buster
Prerequisite steps: setup libcouchbase by following C SDK setup as marked in below Dockerfile

Below Dockerfile is used to build/run rust application with couchbase-rs 1.0.0-alpha.4.
I was able to build and run couchbase-rs based app by manual copy of libcouchbase.so.6.0.4 binary( removing manual copy should help re-generate issue)

FROM rust:1-bullseye AS base
WORKDIR /code
#Below 2 lines are the additional work needs to do in order to run couchbase-rs based application
COPY ./custom-lib/libcouchbase.so.6.0.4 /code/libcouchbase.so.6.0.4
RUN ln -s "/code/libcouchbase.so.6.0.4" "/usr/lib/x86_64-linux-gnu/libcouchbase.so.6"



FROM base AS builder
WORKDIR /code
RUN cargo init
COPY Cargo.toml /code/Cargo.toml
RUN cargo fetch

CMD [ "cargo", "test", "--offline" ]

COPY src /code/src
COPY couchbase.key .
#TODO: Make below 3 lines as single line operation to reduce image layers
RUN apt-key add ./couchbase.key
RUN touch /etc/apt/sources.list.d/couchbase.list
RUN echo "deb https://packages.couchbase.com/clients/c/repos/deb/debian11 bullseye bullseye/main" >> /etc/apt/sources.list.d/couchbase.list
RUN apt-get update && apt-get install -y \
    pkg-config \
    cmake \
    llvm-dev \
    libclang-dev \
    clang \
    libssl-dev \
    libcouchbase3 \
    libcouchbase-dev \
    libcouchbase3-tools \
    libcouchbase-dbg \
    libcouchbase3-libev \
    libcouchbase3-libevent \
&& rm -rf /var/lib/apt/lists/*

RUN cargo build --release --offline



#FROM rust:1-stretch
FROM base as deployed
COPY --from=builder /code/target/release/rust-api /usr/bin/rust-api
EXPOSE 8080
ENTRYPOINT [ "/usr/bin/rust-api" ]
@chvck
Copy link
Collaborator

chvck commented Oct 21, 2021

Hi @anshul-mohil thanks for the detailed report. When you say

Unable to run application using couchbase=1.0.0-alpha.4 as it require a specific libcouchbase binary which is not present after C SDK setup.

Are you saying that when you run cargo build against an application using the rust SDK that the SDK cannot find libcouchbase? The rust SDK comes bundled with libcouchbase so you shouldn't need to install libcouchbase at all yourself.

Is the problem here that when the SDK is built then the bundled libcouchbase is being built with a different name to what the SDK is expecting and looking for?

@anshul-mohil
Copy link
Author

Hi @chvck , Thanks for your quick reply. Appreciate it!

Are you saying that when you run cargo build against an application using the rust SDK that the SDK cannot find libcouchbase? The rust SDK comes bundled with libcouchbase so you shouldn't need to install libcouchbase at all yourself.

There is no issue building couchbase-rs based app without libcouchbase present at os level(I am suspecting its because as you mentioned alpha comes bundled with libcouchbase), so no problem running cargo build --release --offline.

However issue surface when running built binary(taking above mentioned docker file as context: at step ENTRYPOINT [ "/usr/bin/rust-api" ])
Error:

/usr/bin/rust-api: error while loading shared libraries: libcouchbase.so.6: cannot open shared object file: No such file or directory

Is the problem here that when the SDK is built then the bundled libcouchbase is being built with a different name to what the SDK is expecting and looking for?

Is there a way you can suggest me to verify possibility of such issue?

@anshul-mohil
Copy link
Author

/usr/bin/rust-api: error while loading shared libraries: libcouchbase.so.6: cannot open shared object file: No such file or directory

To solve this issue, I had to place file at "/usr/lib/x86_64-linux-gnu/libcouchbase.so.6" manually in docker container as marked in docker file. I am hoping to avoid this manual step if possible.

@chvck
Copy link
Collaborator

chvck commented Oct 21, 2021

Hi @anshul-mohil thanks for updating, I'll take a look into this and get back to you.

@chvck
Copy link
Collaborator

chvck commented Oct 26, 2021

@anshul-mohil just to let you know that I've managed to reproduce this, and I'm looking into it.

@anshul-mohil
Copy link
Author

@chvck , Thank you for working on it. Great News! Looking forward to hear more. 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants