I’m running a Rust web service via Render. This worked all fine and well until I added the
xlsxwriter crate. This crate expects the libclang library to be available on the system. The path can be specified via the
LIBCLANG_PATH environment variable.
This works for me locally:
$ echo $LIBCLANG_PATH
$ ls $LIBCLANG_PATH
clang libclangDoc.a libclangParse.a libclangTidyBoostModule.a libclangTidyOpenMPModule.a
libclangAnalysis.a libclangdRemoteIndex.a libclangQuery.a libclangTidyBugproneModule.a libclangTidyPerformanceModule.a
libclangApplyReplacements.a libclangDriver.a libclangReorderFields.a libclangTidyCERTModule.a libclangTidyPlugin.a
libclangARCMigrate.a libclangdSupport.a libclangRewrite.a libclangTidyCppCoreGuidelinesModule.a libclangTidyPortabilityModule.a
Is this library something which can be added to the base image like was done in Missing library to use Puppeteer?
For now I’ll switch to Docker I guess as was advised at Install binary dependencies - #3 by jake.
Thanks for reaching out!
If you want
libclang to be added to the base Rust image, feel free to open a feedback request to it can be recorded somewhere and eventually gain traction.
For now, you can use Docker to deploy your Rust service and have full configuration possibilities. Your Dockerfile may look something like:
FROM ubuntu:20.04RUN apt-get update && apt-get install -y \ curl \ git \ clang \ libclang-dev \ build-essential \ cmake \ libcurl4-openssl-dev \ libssl-dev \ make \ && curl https://sh.rustup.rs -sSf | sh -s -- -yWORKDIR /appCOPY . .RUN make
Let me know if that helped and/or if you require any additional assistance.
Jérémy, Render Support
Thanks and apologies for not responding quickly. I switched to Docker and that works great. With a bit of fiddling, caching of dependencies works now so that reduces the deployment time from 10-15 minutes to about 5 minutes.
The Dockerfile with caching looks follows for some package
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
# Build dependencies only.
RUN cargo init foo
COPY Cargo.toml foo/
RUN cargo build --release; \
rm -rf foo
# Install `foo`.
COPY . .
RUN echo "// force Cargo cache invalidation" >> foo/src/main.rs; \
cargo install --path foo
which is loosely based on https://github.com/rust-lang/cargo/issues/2644#issuecomment-335272535. The “// force Cargo cache invalidation” part is something that turned out to be necessary to force invalidate the cache. Without it, the package
foo from the
cargo build step is deployed since Cargo apparently doesn’t notice that
COPY . . copied in new files.