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

Error loading shared libraries on alpine because of prebuilt(?) #1140

Closed
iCrawl opened this issue Apr 13, 2018 · 11 comments
Closed

Error loading shared libraries on alpine because of prebuilt(?) #1140

iCrawl opened this issue Apr 13, 2018 · 11 comments

Comments

@iCrawl
Copy link

iCrawl commented Apr 13, 2018

I recently decided to upgrade from the master build I was running off this repo which was around 2.0.0-alpha.9 to the latest 2.0.0-alpha.12 just to get greeted with some nice errors on my alpine docker container.

I am aware that I can stay at alpha.9 but it would be in my best interest to keep my software updated, esp when I see commits like [...] fixed memory leak [...]

Issue or Feature

Any version above 2.0.0-alpha.9 throws

Error: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /usr/src/Tohru/node_modules/canvas/build/Release/libpixman-1.so.0)

in Alpine Linux after installing and executing the code.

First thing I tried was adding --build-from-source to yarn install but that obviously didn't work out as I expected it to.
I assume what's happening here is that it tries to always use a prebuilt version regardless and that it correlates to this issue afterwards? node-gfx/node-canvas-prebuilt#31

Steps to Reproduce

Just run any Alpine Dockerfile (for reproduce cases node:8-alpine I guess) with those packages.

#  Install dependencies
RUN apk add --update \
&& apk add --no-cache ffmpeg opus pixman cairo pango giflib ca-certificates \
&& apk add --no-cache --virtual .build-deps git curl build-base jpeg-dev pixman-dev \
cairo-dev pango-dev pangomm-dev libjpeg-turbo-dev giflib-dev freetype-dev python g++ make \
\
# Install node.js dependencies
&& yarn install --build-from-source \
\
# Clean up build dependencies
&& apk del .build-deps

It will work fine on 2.0.0-alpha.9 but not anything above that (since node-pre-gyp got added) basically.
Is there anyway to go back to the old behavior that alpha.9 used? Since that works perfectly fine.

Your Environment

  • Version of node-canvas (e.g. 1.4.0): 2.0.0-alpha.10 - 2.0.0-alpha.12
  • Environment (e.g. node 4.2.0 on Mac OS X 10.8): node 8.x.x on Alpine Linux
@chearon
Copy link
Collaborator

chearon commented Apr 13, 2018

I assume what's happening here is that it tries to always use a prebuilt version regardless and that it correlates to this issue afterwards? node-gfx/node-canvas-prebuilt#31

That's correct, Alpine doesn't use glibc, it uses musl, an alternate implementation of libc. I don't think it will be super hard to add that to the build matrix.

The real issue here is that canvas should be falling back to build, so I need to add a libc option to the binary's URL path. I'll do that after I add the musl builds soon.

@iCrawl
Copy link
Author

iCrawl commented Apr 13, 2018

Bless. I appreciate the effort being made.

As a general side-note, and reason why I posted this here and not over at the prebuilt-repo, shouldn't --build-from-source completely ignore even "trying" to use a prebuilt? Or do I misunderstand how this is intended to be used.

@chearon
Copy link
Collaborator

chearon commented Apr 13, 2018

It should not try to use prebuilt with that argument, no. Did you install it like this?

yarn add canvas@next --build-from-source

It worked for me. In NPM that argument doesn't work if it goes before the package name.

@iCrawl
Copy link
Author

iCrawl commented Apr 13, 2018

Not really?

As you can see above I am using a simple yarn install or yarn (since those are interchangeable) to install all my packages defined in the package.json after copying over the package.json and the yarn.lock file and it doesn't seem to apply in this case.

Like

COPY package.json yarn.lock ./

#  Install dependencies
RUN apk add --update \
&& apk add --no-cache ffmpeg opus pixman cairo pango giflib ca-certificates \
&& apk add --no-cache --virtual .build-deps git curl build-base jpeg-dev pixman-dev \
cairo-dev pango-dev pangomm-dev libjpeg-turbo-dev giflib-dev freetype-dev python g++ make \
\
# Install node.js dependencies
&& yarn install --build-from-source \
\
# Clean up build dependencies
&& apk del .build-deps

# Add project source
COPY . .

I think it would go against the principle of having it defined in the yarn.lock file if I had to manually run yarn add canvas@next --build-from-source because then it wouldn't pin down the version anymore. Correct me if I am wrong though.

Edit:
I did try, for the heck of it, installing it with yarn add canvas@next --build-from-source to add it to my yarn.lock and package.json again on my development env (which runs windows), and it seemed to have built from source, but obviously the moment I need to deploy the code with docker I would run yarn install to get all my packages installed and it won't apply there.

@DevYukine
Copy link

I agree to what @iCrawl said since i encountere exactly the same issue and would love to have that fallback method to build itself so i could actuall use the newest beta version.

@chearon
Copy link
Collaborator

chearon commented May 5, 2018

No longer a problem in the next release thanks to #1156

@chearon chearon closed this as completed May 5, 2018
@ryedin
Copy link

ryedin commented Jun 27, 2018

This seems to still be an issue, unless I'm just doing something wrong.

After npm install canvas@next, I get "canvas": "^2.0.0-alpha.12", in my package.json...

My dockerfile has this:

RUN apk --no-cache --virtual .build-deps add \
        python \
        make \
        g++ \
    && apk --no-cache --virtual .canvas-build-deps add \
        build-base \
        cairo-dev \
        jpeg-dev \
        pango-dev \
        giflib-dev \
        pixman-dev \
        pangomm-dev \
        libjpeg-turbo-dev \
        freetype-dev \
    && apk --no-cache add \
        pixman \
        cairo \
        pango \
        giflib \
    && npm install \
    && apk del .build-deps \
    && apk del .canvas-build-deps

And I still get the following error:
Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /usr/src/built/node_modules/canvas/build/Release/libpixman-1.so.0)

I'm unsure what to do based on this thread, which seems to indicate it "should just work now"

@ryedin
Copy link

ryedin commented Jun 27, 2018

ugh, nevermind. I was missing the --build-from-source flag in my npm install command. I guess I was assuming that @chearon's last comment here was indicating it would somehow detect that I was in an environment not supported by the prebuilts (alpine).

I was also missing libjpeg but I think I'm now on my way.

@Ugzuzg
Copy link
Contributor

Ugzuzg commented Jun 27, 2018

@ryedin, your expectations were correct, but there was no release since that commit, so nothing actually changed.

@ryedin
Copy link

ryedin commented Jun 27, 2018

ah :) - makes total sense now. I just assumed since that was May 4th that a release had been made. My bad!

ty

EDIT: I just now went back to the OP and saw the version (and feel silly) 🥇

@JakinMiao
Copy link

ugh, nevermind. I was missing the --build-from-source flag in my npm install command. I guess I was assuming that @chearon's last comment here was indicating it would somehow detect that I was in an environment not supported by the prebuilts (alpine).

I was also missing libjpeg but I think I'm now on my way.

i have the same problem. can you send me your dockerfile to me?

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

6 participants