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

Cannot install sharp on M1 Mac with Debian Stretch based Docker container #2875

Closed
MattyPalka opened this issue Sep 4, 2021 · 14 comments
Closed

Comments

@MattyPalka
Copy link

Did you see the documentation relating to installation?
yes

Have you ensured the architecture and platform of Node.js used for npm install is the same as the architecture and platform of Node.js used at runtime?
yes

Are you using the latest version? Is the version currently in use as reported by npm ls sharp the same as the latest version as reported by npm view sharp dist-tags.latest?
yes (0.29.0)

If you are using npm v6 or earlier and installing as a root or sudo user, have you tried with the npm install --unsafe-perm flag?
n/a

If you are using npm v7, does the user running npm install own the directory it is run in?
n/a

If you are using the ignore-scripts feature of npm, have you tried with the npm install --ignore-scripts=false flag?
no

What is the complete output of running npm install --verbose sharp? Have you checked this output for useful error messages?

What is the output of running npx envinfo --binaries --system?

Issue occurs on M1 Mac when I try yarn install dependencies (including sharp) on Docker. However it is fine when I yarn install locally.

What I did is to ensure that I'm using latest sharp 0.29.0. I also installed libvips globally with homebrew. It all works fine if I just yarn install from terminal, however if I go to docker it fails with the following error. To my Dockerfile I also added apt-get libvips but this didn't help.

Any suggestions?

OUTPUT ERROR

error /usr/src/app/node_modules/sharp: Command failed.
Exit code: 1
Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
Arguments: 
Directory: /usr/src/app/node_modules/sharp
Output:
sharp: Installation error: Use with glibc 2.24 requires manual installation of libvips >= 8.11.3
sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies
ERROR: Service 'saas-api' failed to build : The command '/bin/sh -c yarn install --frozen-lockfile && yarn cache clean' returned a non-zero code: 1

DOCKERFILE

FROM node:14.17.3-stretch as install

RUN apt-get update \
    && DEBIAN_FRONTEND=noninteractive apt-get install -y \
    imagemagick \
    ghostscript \
    libvips

WORKDIR /usr/src/app
RUN chown 1000:1000 .

USER node

COPY package.json ./
COPY yarn.lock ./

RUN yarn install --frozen-lockfile && yarn cache clean

COPY patches patches
RUN yarn patch-package

ARG version=dev
ENV VERSION=$version

FROM install as build

COPY . .

RUN yarn build
@lovell
Copy link
Owner

lovell commented Sep 4, 2021

Hi, did you see https://sharp.pixelplumbing.com/install ?

Ready-compiled sharp and libvips binaries are provided for use on the most common platforms:

  • Linux ARM64 (glibc >= 2.29, musl >= 1.1.24)

The following platforms require compilation of both libvips and sharp from source:

  • Linux ARM64 (glibc <= 2.28)

You'll need to use Debian Buster or later to take advantage of the prebuilt binaries.

@lovell lovell changed the title Cannot install sharp on M1 Mac with Docker Cannot install sharp on M1 Mac with Debian Stretch based Docker container Sep 4, 2021
@lovell
Copy link
Owner

lovell commented Oct 3, 2021

Please see #2837 and lovell/sharp-libvips#114

@lovell lovell closed this as completed Oct 3, 2021
@tayormi
Copy link

tayormi commented Oct 6, 2021

I am currently facing this issue as well. I have no idea what to do next.

@lovell
Copy link
Owner

lovell commented Oct 6, 2021

The Debian Buster based images should work e.g. FROM node:16-buster

@ODINSLAYER09
Copy link

I've been facing the issue as well. Tried the buster-based images but it didn't work. Any idea what else to check?

@lovell
Copy link
Owner

lovell commented Oct 11, 2021

I meant Debian Bullseye, not Buster, sorry. You could also try Alpine Linux. Eventually this will be solved via lovell/sharp-libvips#114

@ODINSLAYER09
Copy link

That seems to work now. Any idea what the problem is? Or when or how to overcome this with the base image of Node? Looking forward to your reply.

@sanzhardanybayev
Copy link

I confirm that choosing bullseye variant does help. In my case it was node:lts-bullseye.
Thanks all for the tips. Much appreciated!

@lovell
Copy link
Owner

lovell commented Dec 12, 2021

The future sharp v0.30.0 will provide binaries that work with older Linux OS on ARM64 - see #2938

@jmaferreira
Copy link

jmaferreira commented Dec 17, 2021

I had this problem on Apple M1 Pro. Fixed by changing the version of debian:

FROM node:14.18.2-bullseye-slim

@justyn-clark
Copy link

I had this problem on Apple M1 Pro. Fixed by changing the version of devian:

FROM node:14.18.2-bullseye-slim

Thank you!!! This worked for me. I went to bed really upset last night. Not tonight :)

@rlvk-vk
Copy link

rlvk-vk commented Feb 1, 2022

Changing from FROM node:16 to FROM node:16-bullseye as the first line in Dockerfile did the trick for me

@quochungphp
Copy link

Thanks FROM node:14.18.2-bullseye-slim worked on me

@simplenotezy
Copy link

@quochungphp Can you share your Dockerfile for reference? I am having some issues getting it up and running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants