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

Vercel only: 0.33.0: error Could not load the "sharp" module using the linux-x64 runtime #3870

Closed
3 tasks done
JClackett opened this issue Nov 29, 2023 · 44 comments
Closed
3 tasks done
Labels

Comments

@JClackett
Copy link

JClackett commented Nov 29, 2023

Possible bug

Is this a possible bug in a feature of sharp, unrelated to installation?

  • Running npm install sharp completes without error.
  • Running node -e "require('sharp')" completes without error.

If you cannot confirm both of these, please open an installation issue instead.

Are you using the latest version of sharp?

  • I am using the latest version of sharp as reported by npm view sharp dist-tags.latest.

If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.

If you are using another package which depends on a version of sharp that is not the latest, please open an issue against that package instead.

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

What are the steps to reproduce?

Running sharp on Vercel breaks after updating from 0.32.6 to 0.33.0

ERROR	Error: Could not load the "sharp" module using the linux-x64 runtime

Downgrading to 0.32.6 for now

@lovell
Copy link
Owner

lovell commented Nov 29, 2023

Do you only see this problem on Vercel? If so, please can you contact their support team. If not, please can you provide answers to the questions in the installation issue template.

@lovell lovell added question and removed triage labels Nov 29, 2023
@c100k

This comment was marked as off-topic.

@lovell
Copy link
Owner

lovell commented Nov 29, 2023

@c100k Please open a new installation issue and answer all of the questions.

@bhr

This comment was marked as off-topic.

@SeongwoonHong

This comment was marked as off-topic.

@JClackett
Copy link
Author

I'm pretty sure it's just that the new version has stricter OS/cpu requirements and likely that the installs that's we're used to using aren't adding the correct binaries. Still haven't figured out how to install the correct ones yet though 😵

@benmccann
Copy link

I'm also getting this on my local Linux machine while trying to upgrade vite-imagetools to the latest sharp. It installs fine, but then fails at runtime when I run pnpm test:

Error: Could not load the "sharp" module using the linux-x64 runtime
Possible solutions:
- Add platform-specific dependencies:
    npm install --os=linux --cpu=x64 sharp
  or
    npm install --force @img/sharp-linux-x64
- Consult the installation documentation: https://sharp.pixelplumbing.com/install
  System:
    OS: Linux 6.5 Ubuntu 23.10 23.10 (Mantic Minotaur)
    CPU: (8) x64 Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
  Binaries:
    pnpm: 8.11.0
    Node: 18.16.0

@JClackett JClackett changed the title 0.33.0: Vercel error: Could not load the "sharp" module using the linux-x64 runtime 0.33.0: error: Could not load the "sharp" module using the linux-x64 runtime Nov 29, 2023
@JClackett JClackett changed the title 0.33.0: error: Could not load the "sharp" module using the linux-x64 runtime 0.33.0: error Could not load the "sharp" module using the linux-x64 runtime Nov 29, 2023
@sawaYch
Copy link

sawaYch commented Nov 30, 2023

Facing same issue on Vercel.
Confirmed that my Vercel and local env are running node version = 18.17.1

I have already install sharp by npm install --force @img/sharp-linux-x64
When I run locally on a Linux machine (ArchLinux x64) it works fine both on build and runtime;
while on Vercel build success but the serverless function call throw the following exception at runtime:

⨯ Error: Could not load the "sharp" module using the linux-x64 runtime
Possible solutions:
- Add platform-specific dependencies:
    npm install --os=linux --cpu=x64 sharp
  or
    npm install --force @img/sharp-linux-x64
- Consult the installation documentation: https://sharp.pixelplumbing.com/install
    at Object.<anonymous> (/var/task/node_modules/sharp/lib/sharp.js:85:9)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at r.<computed>.e._load (/var/task/___vc/__launcher/__launcher.js:14:2299)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at w.require (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:11:25815)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (/var/task/node_modules/sharp/lib/constructor.js:10:1) {
  page: '/api/og'
}

update:
downgrade to 0.32.6 works (fyi who really need a workaround)

@lovell
Copy link
Owner

lovell commented Nov 30, 2023

If everything works locally and you're seeing this problem only on Vercel, please contact Vercel support.

If you're seeing this problem locally, please open a new installation issue and answer all the questions. This will help me to gather lots of information from as many people as possible before starting to look for patterns.

@dresende
Copy link

I'm having this and I'm not using Vercel. Can it be because of an npm-shrinkwrap.json created on a MacOS and later on, on Github, the image of my app installs dependencies on a linux?

@lovell
Copy link
Owner

lovell commented Nov 30, 2023

@dresende If you're seeing this problem locally, please open a new installation issue and answer all the questions. This will help me to gather lots of information from as many people as possible before starting to look for patterns.

@lovell lovell changed the title 0.33.0: error Could not load the "sharp" module using the linux-x64 runtime Vercel only: 0.33.0: error Could not load the "sharp" module using the linux-x64 runtime Nov 30, 2023
@mackermans
Copy link

mackermans commented Nov 30, 2023

FYI it's not just on Vercel, we encountered this issue yesterday (caused an incident in prod) on AWS Lambda using the Node 18 runtime because we install latest (0.33.0 in this case) on every deployment. We fixed it by pinning sharp to 0.32, but didn't investigate further.

@lovell
Copy link
Owner

lovell commented Nov 30, 2023

I've renamed this issue so it can focus on those experiencing problems on Vercel only. If you are experiencing it anywhere else, please open a new issue.

I genuinely want to help people, and the best way to do that right now is for you to give me lots of information, but not all in the same issue all at once. Lots of separate issues that I can use to find out specifics about each failing environment will allow me to help you to help others. Thank you.

@JClackett
Copy link
Author

Vercel uses AWS lambda right? so its probably not to do with Vercel itself but AWS lambda in this case

@lovell
Copy link
Owner

lovell commented Nov 30, 2023

In terms of Vercel, my suspicion is that there is something slightly different happening during the remote build that is preventing the right dependencies being installed. Paging @styfle who is always very helpful and may be able to provide more information about Vercel-internal systems for those who are experiencing this problem on Vercel only.

@acalcutt
Copy link

I am also seeing this error in my tileserver-gl workflow, but I have not had a chance to troubleshoot locally yet.
maptiler/tileserver-gl#1083 . Looks like it installs sharp but fails with the error mentioned when it tries to run the tests.

This workflow that fails is Ubuntu 20.04/Node18
https://github.com/maptiler/tileserver-gl/actions/runs/7039464819/job/19158648527?pr=1083

One thing I still have to test is the order of sharp/canvas/maplibre-native imports. sometimes the order they are imported seems to make a difference that causes weird errors like this.

@lovell
Copy link
Owner

lovell commented Nov 30, 2023

@acalcutt It looks like you've configured npm to not install optional dependencies by using --omit=optional, so please try removing that.

@devunt
Copy link

devunt commented Nov 30, 2023

Looks like @vercel/nft does not pick up corresponding dependency files. We are using it for deployment tree-shaking while not using Vercel itself. We are experiencing the same problem.

Also related: getsentry/sentry-cli#1849

@lovell
Copy link
Owner

lovell commented Nov 30, 2023

Please use either https://vercel.com/help#issues or https://github.com/orgs/vercel/discussions to report issues directly to Vercel.

@daniel-trevino
Copy link

As a quick fix for now you could install an older version of sharp manually in your app. I tried with sharp@0.32.6 and it should remove the error from Vercel.

@devunt
Copy link

devunt commented Nov 30, 2023

Please use either https://vercel.com/help#issues or https://github.com/orgs/vercel/discussions to report issues directly to Vercel.

Appreciate for the pointing the right direction. However I just wanna let maintainers and others to know that I suspect this is a Vercel (and its library) issue, not a sharp specific issue.

@devunt
Copy link

devunt commented Nov 30, 2023

After some investigation, if I change https://github.com/lovell/sharp/blob/main/lib/sharp.js#L24 to require('@img/sharp-darwin-arm64/sharp.node') @vercel/nft collects the corresponding sharp-darwin-arm64.node file correctly. I opened the issue at vercel/nft#371.

@lovell
Copy link
Owner

lovell commented Nov 30, 2023

@devunt Great detective work, thank you, it confirms that deployment logic run within Vercel is causing this problem.

@kbourro

This comment was marked as off-topic.

@lovell
Copy link
Owner

lovell commented Dec 5, 2023

I'm going to temporarily lock this issue as it relates only and specifically to a problem with Vercel that is being tracked at vercel/nft#371 - please subscribe to that issue and/or contact Vercel support for updates.

For anyone else coming here, please open a new installation issue and answer all the questions. I need your answers to these questions as a minimum starting point to be able to try to help you.

Repository owner locked and limited conversation to collaborators Dec 5, 2023
Repository owner unlocked this conversation Jan 3, 2024
@lovell
Copy link
Owner

lovell commented Jan 3, 2024

The vercel/nft#371 issue has now been fixed. If you are deploying to Vercel (or using Next.js standalone mode) please ensure you upgrade your dependencies to use @vercel/nft version 0.26.1 or later.

For anyone else coming here experiencing similar symptoms, please open a new installation issue and answer all the questions.

@hewar-saber
Copy link

As a quick fix for now you could install an older version of sharp manually in your app. I tried with sharp@0.32.6 and it should remove the error from Vercel.

sharp@0.32.6

This worked for me, I had the same issue with Next.js on Vercel and Netlify.

@JClackett
Copy link
Author

I wasn't using @vercel/nft, and its still error in vercel for me using latest versions

@lovell
Copy link
Owner

lovell commented Jan 5, 2024

@JClackett I think Vercel uses @vercel/nft under the hood so perhaps they have not yet updated their build infrastructure with the latest version. You'll need to ask Vercel support about this.

@slavanossar
Copy link

slavanossar commented Jan 8, 2024

Was also experiencing this issue and updating Node fixed it (18.16.1 > 18.19.0).

@aoioioi
Copy link

aoioioi commented Jan 9, 2024

Not working for me deployed on render. Using node 18.19.0. Rolling back to 0.32.6 fixed the issue for me

@dalyr95
Copy link

dalyr95 commented Jan 10, 2024

Same issue on AWS, not vercel. Node 18.17.0 - x64, 0.32.6 rollback works

@lovell
Copy link
Owner

lovell commented Jan 10, 2024

There was a problem affecting both Next.js standalone mode and Vercel deployments, which has now been fixed - please ensure @vercel/nft version 0.26.1 or later is being used - see vercel/nft#371 for details.

Lots of people are running into npm/cli#4828 and the symptoms are similar so please check that one first if you're sharing lockfiles between multiple platforms.

If you're still having problems, please open a new installation issue and answer all the questions. I need your answers to these questions as a minimum starting point to be able to try to help you.

I'm going to lock this issue again.

Repository owner locked and limited conversation to collaborators Jan 10, 2024
ryngonzalez added a commit to ryngonzalez/ryngonzalez.com that referenced this issue Mar 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests