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

Import error trying to run gRPC on alpine #6126

Closed
bbassingthwaite-va opened this Issue Apr 8, 2016 · 13 comments

Comments

Projects
None yet
9 participants
@bbassingthwaite-va
Copy link

bbassingthwaite-va commented Apr 8, 2016

Hi, I am trying to run a gRPC server inside of a docker container and I am receiving the error:

Traceback (most recent call last):
  File "main.py", line 34, in <module>
    import pt_pb2
  File "/etc/app/pt_pb2.py", line 179, in <module>
    from grpc.beta import implementations as beta_implementations
  File "/usr/lib/python2.7/site-packages/grpc/beta/implementations.py", line 38, in <module>
    from grpc._adapter import _intermediary_low
  File "/usr/lib/python2.7/site-packages/grpc/_adapter/_intermediary_low.py", line 57, in <module>
    from grpc._adapter import _low
  File "/usr/lib/python2.7/site-packages/grpc/_adapter/_low.py", line 33, in <module>
    from grpc._cython import cygrpc
ImportError: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /usr/lib/python2.7/site-packages/grpc/_cython/cygrpc.so)

My docker file is:

FROM gliderlabs/alpine:3.3

RUN apk add --update \
    python \
    python-dev \
    py-pip \
    build-base \
    libffi-dev \
    openssl-dev \
    curl \
  && pip install virtualenv \
  && rm -rf /var/cache/apk/*

RUN mkdir /etc/app/
COPY ./app/ /etc/app/
RUN pip install gcloud grpcio
WORKDIR /etc/app/
EXPOSE 80
CMD ["python", "main.py"]

I am installing gRPC from PYPI and would not expect any other dependencies?

Thanks,
Braden

@deedubs

This comment has been minimized.

Copy link

deedubs commented Apr 19, 2016

@samkelleher

This comment has been minimized.

Copy link

samkelleher commented Apr 24, 2016

Adding a comment as found this error via Google and the solution worked for me. Had the same error, slightly different trace - but ultimately resolved by installing the libc6-compat package.

My tracelog for reference:

module.js:440
  return process.dlopen(module, path._makeLong(filename));
                 ^
Error: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /usr/src/app/node_modules/grpc/src/node/extension_binary/grpc_node.node)
    at Error (native)
    at Object.Module._extensions..node (module.js:440:18)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/src/app/node_modules/grpc/src/node/src/grpc_extension.js:38:15)
@nathanielmanistaatgoogle

This comment has been minimized.

Copy link
Member

nathanielmanistaatgoogle commented Jun 6, 2016

Closing; the question here seems to be satisfactorily answered.

bcessa added a commit to mxabierto/EDCA that referenced this issue Nov 19, 2016

New Docker Image
Use Alpine 3.4 as base and add libc6-compat as a dependency to solve
an issue with the gRPC nodejs module.

grpc/grpc#6126
@rochdev

This comment has been minimized.

Copy link

rochdev commented Sep 28, 2017

I feel this has not in fact been satisfactorily answered. This should not be necessary if gRPC would have an official alpine build. The error on the npm module was also very confusing.

@deedubs

This comment has been minimized.

Copy link

deedubs commented Sep 28, 2017

I'll admit I scratched my head when I first encountered this but I don't put the onus on the gRPC team to create builds for every exotic libc implementation people can conjure up.

Alpine is very forthcoming with the use of musl libc. I think the onus is on us to understand what that means to the code we are trying to run.

In this case it means we need to install a compatibility shim libc6-compat.

Alpine has an excellent tool for getting to the bottom of these issues https://pkgs.alpinelinux.org/contents
(its actually how I initially resolved this issue myself)

For example you can find what, if any, packages may offer the missing ld-linux-x86-64.so.2 file we can use it like so https://pkgs.alpinelinux.org/contents?file=ld-linux-x86-64.so.2&path=&name=&branch=&repo=&arch=

@kpayson64

This comment has been minimized.

Copy link
Contributor

kpayson64 commented Sep 28, 2017

Is the libc6-compat workaround still necessary?

I just spun up the alpine docker image we use for testing
https://github.com/grpc/grpc/blob/master/tools/dockerfile/test/cxx_alpine_x64/Dockerfile

I pip installed grpc, and was able to import grpc without running into the issue described above.

To make sure we didn't transitively pull in libc6-compat into our alpine docker image, I did
bash-4.3# apk info | grep libc6 and it came back empty.

@rochdev

This comment has been minimized.

Copy link

rochdev commented Sep 28, 2017

I agree in general that supporting other libc implementations is not necessarily a good idea, but in this case Alpine is quickly becoming the de facto Docker images base OS.

While I do agree that the fix is easy, understanding why it doesn't work can be painful as demonstrated by the quantity of issues related to Alpine in this repo (and any other large project that doesn't support musl).

Also note that I have no idea of the effort required to implement this directly in gRPC. I simply think it should at least be in the roadmap.

@rochdev

This comment has been minimized.

Copy link

rochdev commented Sep 28, 2017

@kpayson64 It is possible the entire glibc gets installed? Otherwise maybe an Alpine build does exist and is simply not being used by the npm module?

@kpayson64

This comment has been minimized.

Copy link
Contributor

kpayson64 commented Sep 28, 2017

@rochdev
Can you confirm that you are still seeing this issue with the latest version of gRPC?

Alpine support was added this April, so probably wasn't there before gRPC 1.4.

@rochdev

This comment has been minimized.

Copy link

rochdev commented Sep 29, 2017

Indeed it seems that the @google-cloud/common-grpc npm module depends on ^1.3.1

https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/packages/common-grpc/package.json

I will open a PR there. Sorry for reviving this old thread!

@JustinBeckwith

This comment has been minimized.

Copy link

JustinBeckwith commented Dec 18, 2017

@murgatroid99 Why is this issue closed? This seems like something that should stay open until we make gRPC work out of the box on alpine.

@murgatroid99

This comment has been minimized.

Copy link
Member

murgatroid99 commented Dec 18, 2017

Well, it was originally closed because some solution had been provided. Now I believe it can stay closed because we have published precompiled binaries for alpine in gRPC 1.8.

@JustinBeckwith

This comment has been minimized.

Copy link

JustinBeckwith commented Dec 19, 2017

👏 this is awesome news! I didn't see that 1.8 went out!

@lock lock bot locked as resolved and limited conversation to collaborators Sep 30, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.