GithubHelp home page GithubHelp logo

OSError: cannot load library '/var/task/tartiflette/language/parsers/libgraphqlparser/cffi/libgraphqlparser.dylib': /var/task/tartiflette/language/parsers/libgraphqlparser/cffi/libgraphqlparser.dylib: cannot open shared object file: No such file or directory. Additionally, ctypes.util.find_library() did not manage to locate a library called about tartiflette HOT 12 CLOSED

Lilja avatar Lilja commented on June 12, 2024
OSError: cannot load library '/var/task/tartiflette/language/parsers/libgraphqlparser/cffi/libgraphqlparser.dylib': /var/task/tartiflette/language/parsers/libgraphqlparser/cffi/libgraphqlparser.dylib: cannot open shared object file: No such file or directory. Additionally, ctypes.util.find_library() did not manage to locate a library called

from tartiflette.

Comments (12)

Lilja avatar Lilja commented on June 12, 2024 3

Would you accept a PR that adds a LIBGRAPHQL_LOCATION environmental variable to lookup?

from tartiflette.

abusi avatar abusi commented on June 12, 2024 1

thanks @Lilja
A dynlib file is a so file but for macos, the dynlib file is searched for only if the so one is not found.
The .so file should also be in the /var/task/tartiflette/language/parsers/libgraphqlparser/cffi/ folder, which is where the python are installed as I can see in the error.

Maybe we could provide a way to specify where the libgraphqlparser.so file is instead of only looking for it in the python package. The code that does this here https://github.com/tartiflette/tartiflette/blob/master/tartiflette/language/parsers/libgraphqlparser/parser.py#L35 it may help you understand the problem.

from tartiflette.

Lilja avatar Lilja commented on June 12, 2024 1

Amazing, thanks for your help. I changed our setup and stopped basing our build image in codebuild from ubuntu:20.04 to lambci/lambda:build-python3.8.

If you are running into this issue in the future, this is what we are building the build image with.

FROM lambci/lambda:build-python3.8
RUN curl --silent --location https://rpm.nodesource.com/setup_14.x | bash - && yum -y install nodejs

RUN yum install -y make git time

RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3 -
ENV PATH "$PATH:/root/.poetry/bin"

RUN npm install -g yarn && \
    npm install -g serverless

RUN node --version && \
    make --version && \
    npm --version && \
    yarn --version && \
    git --version && \
    python3 --version && \
    poetry --version && \
    sls --version && \
    serverless --version && \
    time --version

ENTRYPOINT "/bin/bash"

from tartiflette.

abusi avatar abusi commented on June 12, 2024

Hi,
Seems that tartiflette wasn't installed using pip install tartiflette (make sure to have the dependencies installed, cmake, bison>=3, flex)).
It's the setup.py file that compile the lib according to the target system.

I do not know how AWS Lambda works, this init step maybe missing.

from tartiflette.

Lilja avatar Lilja commented on June 12, 2024

Hmm. Interesting.

I use serverless to package the application. If I download the zip that serverless generates:

Some source code
image
Tartiflette:
image

It looks like most of these libgraphql-files are present. But not this .dylib-file I guess. Is this weird or expected?

from tartiflette.

Lilja avatar Lilja commented on June 12, 2024

I added some code to be run before I import tartiflette:

import os
from os import walk

path = "/"

for root, dirs, files in walk(path):
    for name in files:
        if "libgraphqlparser.so" in name:
            print(os.path.abspath(name))

image

Yeah, it looks like it's not placed as expected? That's strange.

from tartiflette.

abusi avatar abusi commented on June 12, 2024

@Lilja I'll gladly accept it. I was going to ask you if you wanted to do one :D

from tartiflette.

Lilja avatar Lilja commented on June 12, 2024

Hmm. I'm still having issues with this. I tried applying the environmental variable we introduced yesterday. It seems like my prognosis of the file being in /var/task/ was wrong - os.path.abspath() just prints out the current folder. More debugging leads the fact that is' actually placed where tartiflette actually think it should be?

Here are some logs from cloudwatch:
1st line: printing out os.environ.get()
2nd line: doing the os.walk from the previous script. Also running os.stat on the file.

image

To make diffing easier here is me ctrl+f-ing the paths. They are the same:
image

The script to check if it exists, etc:

import os
from os import walk

print(f"LIBGRAPHQLPARSER_DIR: {os.environ.get('LIBGRAPHQLPARSER_DIR')}")

for root, dirs, files in walk('./'):
    for name in files:
        if "libgraphqlparser" in name:
            abs_p = os.path.join(os.path.abspath(root), name)
            if os.path.exists(abs_p):
                print(f"Found libgraphqlparser file '{abs_p}' stat: '{os.stat(abs_p)}'")

Are we suppressing an important OSError in the parser-file?

from tartiflette.

Lilja avatar Lilja commented on June 12, 2024

Added this:

import os
from os import walk
from cffi import FFI

print(f"LIBGRAPHQLPARSER_DIR: {os.environ.get('LIBGRAPHQLPARSER_DIR')}")

a = None
for root, dirs, files in walk('./'):
    for name in files:
        if "libgraphqlparser" in name:
            abs_p = os.path.join(os.path.abspath(root), name)
            if os.path.exists(abs_p):
                print(f"Found libgraphqlparser file '{abs_p}' stat: '{os.stat(abs_p)}'")
                a = abs_p

if a:
    _FFI = FFI()
    _FFI.dlopen(a)

image
(/lib64/libstdc++.so.6: version `GLIBCXX_3.4.26' not found)

Hmm. I wonder how to solve it. I have some googling to do.

from tartiflette.

abusi avatar abusi commented on June 12, 2024

Ho, yes, the except OSError hide the fact that the libgraphqlparser.so file isn't loading due to a missing dependecy
This is because the .so file wasn't compiled for the target it is ran on.
IE. the systeme were you're trying to run the tartiflette lib is not the same as the one you made the "serverless" package for.

on the system you've installed ttftt (where you've done the pip install tartiflette), the so file is compiled and used system wide .so files (like the glibcxx_3.4.26.so one), but once deployed, this libgraphqlparser.so will ask the system for it's .so deps, and in the case of AWS lambda, it doesn't find it cause it is probable that the system running AWS Lambda isn't a GLIB based one or uses a != version.

from tartiflette.

abusi avatar abusi commented on June 12, 2024

Maybe you can "compile" the libgraphqlparser library for the AWS lambda system, ship it with serverless and use the ENV var to ask tartiflette to load it.

from tartiflette.

jgillich avatar jgillich commented on June 12, 2024

I'm getting the same error when using pipenv

$ pipenv run -- python app.py 
Loading .env environment variables...
Traceback (most recent call last):
  File "/home/vscode/.local/share/virtualenvs/tartiflette-CpQ0F0WG/lib/python3.9/site-packages/tartiflette/language/parsers/libgraphqlparser/parser.py", line 35, in <module>
    _LIB = _FFI.dlopen(f"{_LIBGRAPHQLPARSER_DIR}/libgraphqlparser.so")
  File "/home/vscode/.local/share/virtualenvs/tartiflette-CpQ0F0WG/lib/python3.9/site-packages/cffi/api.py", line 150, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "/home/vscode/.local/share/virtualenvs/tartiflette-CpQ0F0WG/lib/python3.9/site-packages/cffi/api.py", line 832, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "/home/vscode/.local/share/virtualenvs/tartiflette-CpQ0F0WG/lib/python3.9/site-packages/cffi/api.py", line 827, in _load_backend_lib
    raise OSError(msg)
OSError: cannot load library '/home/vscode/.local/share/virtualenvs/tartiflette-CpQ0F0WG/lib/python3.9/site-packages/tartiflette/language/parsers/libgraphqlparser/cffi/libgraphqlparser.so': libstdc++.so.6: cannot open shared object file: No such file or directory.  Additionally, ctypes.util.find_library() did not manage to locate a library called '/home/vscode/.local/share/virtualenvs/tartiflette-CpQ0F0WG/lib/python3.9/site-packages/tartiflette/language/parsers/libgraphqlparser/cffi/libgraphqlparser.so'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/workspaces/benchmarks/tartiflette/app.py", line 1, in <module>
    from tartiflette import Resolver
  File "/home/vscode/.local/share/virtualenvs/tartiflette-CpQ0F0WG/lib/python3.9/site-packages/tartiflette/__init__.py", line 5, in <module>
    from tartiflette.engine import Engine
  File "/home/vscode/.local/share/virtualenvs/tartiflette-CpQ0F0WG/lib/python3.9/site-packages/tartiflette/engine.py", line 20, in <module>
    from tartiflette.execution.collect import parse_and_validate_query
  File "/home/vscode/.local/share/virtualenvs/tartiflette-CpQ0F0WG/lib/python3.9/site-packages/tartiflette/execution/collect.py", line 11, in <module>
    from tartiflette.language.parsers.libgraphqlparser import parse_to_document
  File "/home/vscode/.local/share/virtualenvs/tartiflette-CpQ0F0WG/lib/python3.9/site-packages/tartiflette/language/parsers/libgraphqlparser/__init__.py", line 1, in <module>
    from .parser import parse_to_document
  File "/home/vscode/.local/share/virtualenvs/tartiflette-CpQ0F0WG/lib/python3.9/site-packages/tartiflette/language/parsers/libgraphqlparser/parser.py", line 37, in <module>
    _LIB = _FFI.dlopen(f"{_LIBGRAPHQLPARSER_DIR}/libgraphqlparser.dylib")
  File "/home/vscode/.local/share/virtualenvs/tartiflette-CpQ0F0WG/lib/python3.9/site-packages/cffi/api.py", line 150, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "/home/vscode/.local/share/virtualenvs/tartiflette-CpQ0F0WG/lib/python3.9/site-packages/cffi/api.py", line 832, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "/home/vscode/.local/share/virtualenvs/tartiflette-CpQ0F0WG/lib/python3.9/site-packages/cffi/api.py", line 827, in _load_backend_lib
    raise OSError(msg)
OSError: cannot load library '/home/vscode/.local/share/virtualenvs/tartiflette-CpQ0F0WG/lib/python3.9/site-packages/tartiflette/language/parsers/libgraphqlparser/cffi/libgraphqlparser.dylib': /home/vscode/.local/share/virtualenvs/tartiflette-CpQ0F0WG/lib/python3.9/site-packages/tartiflette/language/parsers/libgraphqlparser/cffi/libgraphqlparser.dylib: cannot open shared object file: No such file or directory.  Additionally, ctypes.util.find_library() did not manage to locate a library called '/home/vscode/.local/share/virtualenvs/tartiflette-CpQ0F0WG/lib/python3.9/site-packages/tartiflette/language/parsers/libgraphqlparser/cffi/libgraphqlparser.dylib'

But the lib exists:

$ ls /home/vscode/.local/share/virtualenvs/tartiflette-CpQ0F0WG/lib/python3.9/site-packages/tartiflette/language/parsers/libgraphqlparser/cffi/
__init__.py  libgraphqlparser.so  __pycache__

I am building on the same machine though so I'm not sure why it can't load it. Any ideas?

from tartiflette.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.