Skip to content
Back

Appwrite Functions: Library not found

  • 0
  • Functions
  • Cloud
outroddet_
6 Jan, 2025, 22:05

I was trying to make a python function for renderering a pdf with weasyprint. Because appwrite uses alpine images I added following lines to the build settings:

TypeScript
apk add --no-cache weasyprint

pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt

In a local docker env everything works well, but appwrite does not find the library when trying to execute the function: OSError: cannot load library 'libgobject-2.0-0': Error loading shared library libgobject-2.0-0: No such file or directory. Additionally, ctypes.util.find_library() did not manage to locate a library called 'libgobject-2.0-0'

Additionally, I wanted to ask if this: return context.res.binary(io.BytesIO(rendered_pdf), 200, { "Content-Type": "application/pdf" }) would be the right return type of the main function? Because I didn't find any docs of the .binary function. Thanks 😄

TL;DR
Developers faced an issue with finding a library when trying to execute a function on Appwrite due to incorrect directory installation. The error pointed to a missing 'libgobject-2.0-0' library. To resolve this, consider adding the correct apk installation location and ensuring the library is in the right directory for the function's virtual machine. Additionally, the 'return context.res.binary(io.BytesIO(rendered_pdf), 200, { "Content-Type": "application/pdf" })' line is correct for returning a PDF from the main function.
Kenny
6 Jan, 2025, 22:09

I think this because the directory that apk add installs to is not the directory that is cloned into the vm that spins up for the function.

Kenny
6 Jan, 2025, 22:09

I had a similar issue with trying to install chrome, but I don't remember exacty what directory is the right one. Sorry /:

outroddet_
6 Jan, 2025, 22:13

So you installed chrome in a different dir?

outroddet_
7 Jan, 2025, 15:41

Somebody got an idea of what to do??

Kenny
7 Jan, 2025, 16:31

Yea... if I remember correctly there is a directory that gets copied to the vm that spins up for the function, but I don't remember the directory and I don't have access to my self hosted instance rn to check.

Kenny
7 Jan, 2025, 16:32

Though that was a long time ago and functions have been through various revisions since then

Kenny
7 Jan, 2025, 16:40

Someone else might have better insight, but here was the issue I was having while trying to frontload chromium.

https://discord.com/channels/564160730845151244/1152721465356066897/1157120187384991874

I ended up having to install it each time the function cold starts. They could be non-related at all, but that's the issue I was getting when trying to install something using the apline package manager.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more