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

Issue: Sharp fails when installing with bun #4549

Closed
gtrabanco opened this issue Sep 7, 2023 · 53 comments
Closed

Issue: Sharp fails when installing with bun #4549

gtrabanco opened this issue Sep 7, 2023 · 53 comments
Labels
bug Something isn't working bun install Something that relates to the npm-compatible client

Comments

@gtrabanco
Copy link

What version of Bun is running?

1.0.0+5b9d8b87c41410091a7c602b895ad9ffda17819c

What platform is your computer?

Darwin 21.6.0 x86_64 i386

What steps can reproduce the bug?

Install Sharp

$ mkdir my-project && cd $_
$ bun init
$ bun install
$ bun add --exact sharp
$ mv index.ts index.js

Code

import sharp from "sharp";

const shield = sharp("shield.png");
const { width, height } = await shield.metadata();

console.log(await shield.metadata());

What is the expected behavior?

Output next content:

{
  format: "png",
  width: 415,
  height: 415,
  space: "srgb",
  channels: 4,
  depth: "uchar",
  density: 72,
  isProgressive: false,
  hasProfile: false,
  hasAlpha: true,
  orientation: 1,
  exif: Buffer(80) [ 77, 77, 0, 42, 0, 0, 0, 8, 0, 2, 1, 18, 0, 3, 0, 0, 0, 1, 0, 1, 0, 0, 135, 105, 0, 4, 0, 0, 0, 1, 0, 0, 0, 38, 0, 0, 0, 0, 0, 3, 160, 1, 0, 3, 0, 0, 0, 1, 0, 1, 0, 0, 160, 2, 0, 4, 0, 0, 0, 1, 0, 0, 1, 159, 160, 3, 0, 4, 0, 0, 0, 1, 0, 0, 1, 159, 0, 0, 0, 0 ],
  xmp: Buffer(323) [ 60, 120, 58, 120, 109, 112, 109, 101, 116, 97, 32, 120, 109, 108, 110, 115, 58, 120, 61, 34, 97, 100, 111, 98, 101, 58, 110, 115, 58, 109, 101, 116, 97, 47, 34, 32, 120, 58, 120, 109, 112, 116, 107, 61, 34, 88, 77, 80, 32, 67, 111, 114, 101, 32, 54, 46, 48, 46, 48, 34, 62, 10, 32, 32, 32, 60, 114, 100, 102, 58, 82, 68, 70, 32, 120, 109, 108, 110, 115, 58, 114, 100, 102, 61, 34, 104, 116, 116, 112, 58, 47, 47, 119, 119, 119, 46, 119, 51, 46, 111, 114, 103, 47, 49, 57, 57, 57, 47, 48, 50, 47, 50, 50, 45, 114, 100, 102, 45, 115, 121, 110, 116, 97, 120, 45, 110, 115, 35, 34, 62, 10, 32, 32, 32, 32, 32, 32, 60, 114, 100, 102, 58, 68, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 32, 114, 100, 102, 58, 97, 98, 111, 117, 116, 61, 34, 34, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 120, 109, 108, 110, 115, 58, 116, 105, 102, 102, 61, 34, 104, 116, 116, 112, 58, 47, 47, 110, 115, 46, 97, 100, 111, 98, 101, 46, 99, 111, 109, 47, 116, 105, 102, 102, 47, 49, 46, 48, 47, 34, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 60, 116, 105, 102, 102, 58, 79, 114, 105, 101, 110, 116, 97, 116, 105, 111, 110, 62, 49, 60, 47, 116, 105, 102, 102, 58, 79, 114, 105, 101, 110, 116, 97, 116, 105, 111, 110, 62, 10, 32, 32, 32, 32, 32, 32, 60, 47, 114, 100, 102, 58, 68, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 62, 10, 32, 32, 32, 60, 47, 114, 100, 102, 58, 82, 68, 70, 62, 10, 60, 47, 120, 58, 120, 109, 112, 109, 101, 116, 97, 62, 10 ]
}

What do you see instead?

$ bun index.js                 
32 |     if (loadedModule) {
33 |       const [, loadedPackage] = loadedModule.match(/node_modules[\\/]([^\\/]+)[\\/]/);
34 |       help.push(`- Ensure the version of sharp aligns with the ${loadedPackage} package: "npm ls sharp"`);
35 |     }
36 |   }
37 |   throw new Error(help.join('\n'));
            ^
error: 
Something went wrong installing the "sharp" module

Cannot find module "../build/Release/sharp-darwin-x64.node" from "~/MyProjects/compose-images/node_modules/sharp/lib/sharp.js"

Possible solutions:
- Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"
- Install for the current darwin-x64 runtime: "npm install --platform=darwin --arch=x64 sharp"
- Consult the installation documentation: https://sharp.pixelplumbing.com/install
      at ~/MyProjects/compose-images/node_modules/sharp/lib/sharp.js:37:8
      at globalThis (~/MyProjects/compose-images/node_modules/sharp/lib/sharp.js:37:33)
      at require (:1:20)
      at ~/MyProjects/compose-images/node_modules/sharp/lib/constructor.js:11:0
      at globalThis (~/MyProjects/compose-images/node_modules/sharp/lib/constructor.js:439:17)
      at require (:1:20)
      at ~/MyProjects/compose-images/node_modules/sharp/lib/index.js:6:6
      at globalThis (~/MyProjects/compose-images/node_modules/sharp/lib/index.js:16:17)

Additional information

Workaround

$ rm -rf node_modules bun.lockb
$ npm install
$ bun index.js

When using npm to install de dependencies it does not fail even while running with bun. Possible there is any missing feature in bun install?

I haven't tried with previous versions of Bun.

@gtrabanco gtrabanco added the bug Something isn't working label Sep 7, 2023
@gtrabanco
Copy link
Author

Sorry, yes... Adding to trustedDependencies in package.json resolve also this issue with bun install.

Should I close this issue? I am not sure.

@Electroid
Copy link
Contributor

Sorry, yes... Adding to trustedDependencies in package.json resolve also this issue with bun install.

Should I close this issue? I am not sure.

For now, if you are running into this issue you can add the following to your package.json.

{
  "trustedDependencies": [
     "sharp"
  ]
}

For sharp specifically, this won't be an issue once we merge #4263

@birkskyum
Copy link
Collaborator

birkskyum commented Sep 8, 2023

0.8.2+4b63ced72dc1b304e737d9ea055c8b6e75f46119 , Darwin 22.6.0 arm64 arm

I find that adding sharp to "trustedDependencies" doesn't do anything. The only way I can run this is if i cd into ./node_modules/sharp and run bun install. @gtrabanco , does trustedDependencies work for you?

@gtrabanco
Copy link
Author

gtrabanco commented Sep 8, 2023

Yes it worked after delete node_modules folder and run bun install.

I will post the repo with the code.

@birkskyum
Copy link
Collaborator

Great to hear! It didn't do the trick for me unfortunately, but looking forward to try your project for see if that can narrow it down somehow.

@gtrabanco
Copy link
Author

Here you have it.

https://github.com/gtrabanco/compose-images

Here you can see after delete node_modules and bun.lockb that all is installed well.

Captura de Pantalla 2023-09-08 a las 13 47 34

@gtrabanco
Copy link
Author

0.8.2+4b63ced72dc1b304e737d9ea055c8b6e75f46119 , Darwin 22.6.0 arm64 arm

I find that adding sharp to "trustedDependencies" doesn't do anything. The only way I can run this is if i cd into ./node_modules/sharp and run bun install. @gtrabanco , does trustedDependencies work for you?

I just show you are on arm and I am at intel... Maybe any issue with arch?

@gtrabanco gtrabanco reopened this Sep 8, 2023
@gtrabanco
Copy link
Author

Sorry I closed the issue, was an accident 🫣

@birkskyum
Copy link
Collaborator

I just show you are on arm and I am at intel... Maybe any issue with arch?

@gtrabanco Oh, that is an interesting observation - your repo also breaks for me.

It would be interesting to hear from someone else running a macos arm64 if this example works.

@vfritzon
Copy link

vfritzon commented Sep 8, 2023

On macos/arm I need to both have sharp listed in trustedDependencies and remove the lockfile to have it install properly.

@birkskyum
Copy link
Collaborator

birkskyum commented Sep 8, 2023

@vfritzon Interesting, removing the bun.lockb and node_modules before running bun i works for me too

@gtrabanco
Copy link
Author

gtrabanco commented Sep 8, 2023

From the absolute ignorance about Bun internals... Strange issue 😅

I mean, would be nice know whats happening.

@andresribeiro
Copy link

@vfritzon Interesting, removing the bun.lockb and node_modules before running bun i works for me too

For me too, with bun.lockb the trustedDependencies doesn't have any effect

@birkskyum
Copy link
Collaborator

@alexlamsl , can you tell why trustedDependencies (introduced here #3288) are ignored if bun.lockd or node_modules already exists?

@lukasver
Copy link

lukasver commented Sep 9, 2023

Same issue here, the trustedDependencies workarround worked after:

rm -rf bun.lockb node_modules
bun i

sanman1k98 added a commit to sanman1k98/www that referenced this issue Sep 9, 2023
Add a "trustedDependencies" property containing `sharp` (the default
image processing service for Astro) because it uses custom install
scripts which makes it incompatible with a normal `bun install`.

For security reasons, Bun **will not** run the lifecycle scripts of
installed dependencies.

The "trustedDependencies" property enables developers to explicitly
define an allowlist of packages that are allowed to run scripts.

Steps for this workaround:
- add the "trustedDependencies" property to the `package.json`
- `rm -rf node_modules bun.lockb`
- `bun install`

See these issues and PRs:
- oven-sh/bun#4549
- oven-sh/bun#2073
- oven-sh/bun#3746
@kuzzmi
Copy link

kuzzmi commented Sep 12, 2023

In monorepo (ex-yarn workspaces), the trustedDependencies worked in the package.json that mentioned sharp. After that arm + workaround worked.

UPD: It actually does a weird thing. When bun is used in combo with --hot, reloading the app fails on requiring sharp.

@kanashimia
Copy link

kanashimia commented Sep 12, 2023

trustedDependencies workaround doesn't seem to work when no node is installed.

› bun install sharp
bun add v1.0.0 (822a00c4)
 + @astrojs/[email protected]
 + [email protected]
 + [email protected]
 + [email protected]
 + @astrojs/[email protected]
 + @astrojs/[email protected]
 + @astrojs/[email protected]
 + @astrojs/[email protected]
 + [email protected]
 + [email protected]
 + [email protected]

 installed [email protected]

error: script not found "install/libvips"
error: script not found "install/can-compile"

 564 packages installed [3.79s]
error: script "install" exited with code 1 (SIGHUP)

@vfritzon
Copy link

@kanashimia I faced the same problem when using the bun docker image as base. I changed to

FROM node:lts
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH="/root/.bun/bin:$PATH"

as a workaround.

My guess is that is due to the sharp install script which uses node:
"install": "(node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)",

@gtrabanco
Copy link
Author

trustedDependencies workaround doesn't seem to work when no node is installed.

› bun install sharp
bun add v1.0.0 (822a00c4)
 + @astrojs/[email protected]
 + [email protected]
 + [email protected]
 + [email protected]
 + @astrojs/[email protected]
 + @astrojs/[email protected]
 + @astrojs/[email protected]
 + @astrojs/[email protected]
 + [email protected]
 + [email protected]
 + [email protected]

 installed [email protected]

error: script not found "install/libvips"
error: script not found "install/can-compile"

 564 packages installed [3.79s]
error: script "install" exited with code 1 (SIGHUP)

Have you tried with bun --bun install. Just curious, not sure if it is supported...

@vfritzon

@mquandalle
Copy link

mquandalle commented Sep 12, 2023

trustedDependencies works on my computer (macos) but not when I deploy on Vercel (linux), maybe because the bun.lockb file need to be generated on the same OS in this particular case?

My workaround is to manually bun install sharp (and sqlite3) in a postinstall script :

"postinstall": "cd node_modules/sharp && bun install && cd ../.. && cd node_modules/sqlite3 && bun install && cd ../.."

@andresribeiro
Copy link

@mquandalle i don't think it's related to the OS. even on my own pc (Linux Mint) that generated the lockfile it's doesn't run postinstall scripts

itsbjoern added a commit to itsbjoern/bjoernf.com that referenced this issue Oct 30, 2023
chantastic added a commit to chantastic/sites that referenced this issue Nov 2, 2023
does just deleting this stuff work?
oven-sh/bun#4549
@7heMech
Copy link

7heMech commented Nov 7, 2023

@birkskyum I get

error: Could not load the "sharp" module at runtime
undefined: libstdc++.so.6: cannot open shared object file: No such file or directory
Possible solutions:
- Add explicit dependencies for the runtime platform:
    npm install --force @sharpen/sharp-libvips-linux-x64
    npm install --force @sharpen/sharp-linux-x64

@Eveeifyeve
Copy link

Hey @Electroid I experienced the same issue with astro starlight having issues with installing sharp.

This is what I got without running npm install:

MissingSharp: Could not find Sharp. Please install Sharp (`sharp`) manually into your project or migrate to another image service.
    at loadSharp (file:///Users/eveeify/Documents/Coding/Github/TeaClient/TeaClientDocs/dist/chunks/astro/assets-service_db46dbed.mjs:547:11)
    at async Object.transform (file:///Users/eveeify/Documents/Coding/Github/TeaClient/TeaClientDocs/dist/chunks/astro/assets-service_db46dbed.mjs:559:15)
    at async generateImageInternal (file:///Users/eveeify/Documents/Coding/Github/TeaClient/TeaClientDocs/node_modules/astro/dist/assets/build/generate.js:120:24)
    at async generateImage (file:///Users/eveeify/Documents/Coding/Github/TeaClient/TeaClientDocs/node_modules/astro/dist/assets/build/generate.js:67:28)
    at async file:///Users/eveeify/Documents/Coding/Github/TeaClient/TeaClientDocs/node_modules/p-queue/dist/index.js:118:36 {
  loc: undefined,
  title: 'Could not find Sharp.',
  hint: "See Sharp's installation instructions for more information: https://sharp.pixelplumbing.com/install. If you are not relying on `astro:assets` to optimize, transform, or process any images, you can configure a passthrough image service instead of installing Sharp. See https://docs.astro.build/en/reference/errors/missing-sharp for more information.\n" +
    '\n' +
    'See https://docs.astro.build/en/guides/images/#default-image-service for more information on how to migrate to another image service.',
  frame: undefined,
  type: 'AstroError'
}

With running rpm Install I got:

❯ bun run build
$ astro build
02:36:35 PM [content] Unsupported file types found. Prefix with an underscore (`_`) to ignore:
- components/Button.astro
components/social.astro
components/youtubeVideo.astro
02:36:35 PM [content] The "i18n" collection does not have an associated folder in your `content` directory. Make sure the folder exists, or check your content config for typos.
02:36:35 PM [content] Types generated 196ms
02:36:35 PM [build] output target: static
02:36:35 PM [build] Collecting build info...
02:36:35 PM [build] Completed in 212ms.
02:36:35 PM [build] Building static entrypoints...
02:36:37 PM [build] Completed in 1.75s.

 building client 
vite v4.5.0 building for production...
✓ 11 modules transformed.
dist/_astro/hoisted.3dbafceb.js   6.05 kB │ gzip:  2.43 kB
dist/_astro/ui-core.cc8fec6f.js  51.45 kB │ gzip: 16.83 kB
✓ built in 205ms
Completed in 210ms.


 generating static routes 
The collection **i18n** does not exist or is empty. Ensure a collection directory with this name exists.
▶ node_modules/@astrojs/starlight/404.astro
  └─ /404.html (+70ms)
▶ node_modules/@astrojs/starlight/index.astro
  ├─ /api/intro/index.html (+60ms)
  ├─ /api/tea/index.html (+31ms)
  ├─ /contributing/contribute/index.html (+30ms)
  ├─ /getting-started/install/index.html (+28ms)
  ├─ /getting-started/intro/index.html (+28ms)
  ├─ index.html (+37ms)
  └─ /website/robots/index.html (+28ms)
Completed in 316ms.


 generating optimized images 
  ▶ /_astro/Tea_client.ee701e2e_24sMJl.webp (before: 39kB, after: 6kB) (+415ms) (1/1)
Completed in 416ms.


Running Pagefind v1.0.3 (Extended)
Running from: "/Users/eveeify/Documents/Coding/Github/TeaClient/TeaClientDocs/node_modules/@astrojs/starlight"
Source:       "../../../dist"
Output:       "../../../dist/pagefind"

[Walking source directory]
Found 8 files matching **/*.{html}

[Parsing files]
Found a data-pagefind-body element on the site.
↳ Ignoring pages without this tag.

[Reading languages]
Discovered 1 language: en

[Building search indexes]
Total: 
  Indexed 1 language
  Indexed 7 pages
  Indexed 233 words
  Indexed 0 filters
  Indexed 0 sorts

Finished in 0.32 seconds
@astrojs/sitemap: `sitemap-index.xml` created at `dist`

02:36:41 PM [build] 8 page(s) built in 5.76s
02:36:41 PM [build] Complete!

So maybe it's just an installing issue trustedDependencies does not work.

@KMJ-007
Copy link

KMJ-007 commented Nov 22, 2023

facing the same issue

if i use yarn it get solved but with bun it gives me error

bun run dev
$ astro dev
/Users/karanjanthe/workspace/snapcraft/node_modules/sharp/lib/sharp.js:37
  throw new Error(help.join('\n'));
        ^

Error: 
Something went wrong installing the "sharp" module

Cannot find module '../build/Release/sharp-darwin-arm64v8.node'
Require stack:
- /Users/karanjanthe/workspace/snapcraft/node_modules/sharp/lib/sharp.js
- /Users/karanjanthe/workspace/snapcraft/node_modules/sharp/lib/constructor.js
- /Users/karanjanthe/workspace/snapcraft/node_modules/sharp/lib/index.js

Possible solutions:
- Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"
- Install for the current darwin-arm64v8 runtime: "npm install --platform=darwin --arch=arm64v8 sharp"
- Consult the installation documentation: https://sharp.pixelplumbing.com/install
    at Object.<anonymous> (/Users/karanjanthe/workspace/snapcraft/node_modules/sharp/lib/sharp.js:37:9)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/Users/karanjanthe/workspace/snapcraft/node_modules/sharp/lib/constructor.js:11:1)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)

Node.js v20.5.1
error: script "dev" exited with code 1 (SIGHUP)

@cyfung1031
Copy link
Contributor

cyfung1031 commented Dec 8, 2023

Sorry, yes... Adding to trustedDependencies in package.json resolve also this issue with bun install.
Should I close this issue? I am not sure.

For now, if you are running into this issue you can add the following to your package.json.

{
  "trustedDependencies": [
     "sharp"
  ]
}

For sharp specifically, this won't be an issue once we merge #4263

#4263 is closed due to #5077
#5077 is turned to a draft
This issue is still here in the latest version 1.0.15+b3bdf22eb.

Remarks

confirmed not required if sharp: ^0.33.0 is used

@gtrabanco
Copy link
Author

You will be unable to reproduce this issue with latest sharp version because the need of running postinstall script was deleted in 0.33.0.

@birkskyum
Copy link
Collaborator

birkskyum commented Dec 8, 2023

Since sharp has a good solution now, this can be closed in favor of the more general issues on this topic:

@kkhnifes
Copy link

kkhnifes commented Dec 29, 2023

hey sorry for the question but I didn't really understand what the solution to this problem is. I added sharp 0.33.1 to the trustedDependencies but it still doesn't work for me when I try to deploy my astro starlight to gitlab pages

@gtrabanco
Copy link
Author

hey sorry for the question but I didn't really understand what the solution to this problem is. I added sharp 0.33.1 to the trustedDependencies but it still doesn't work for me when I try to deploy my astro starlight to gitlab pages

What error do you have? Which version of Bun are you using?

@kkhnifes
Copy link

kkhnifes commented Dec 29, 2023

Thanks for the help but I already solved it the image i was using in my pipeline bun:alpine had the wrong version changed to bun:latest everything works fine now.

@birkskyum
Copy link
Collaborator

birkskyum commented Dec 29, 2023

Sharp only works server side, and GitHub/gitlab pages are statically side generated, so only client side. could that be the issue here?

@7heMech

This comment was marked as resolved.

@Darkle
Copy link

Darkle commented Aug 13, 2024

I seem to be running into this issue too.

I have the following package.json

{
  "name": "bun-sharp-test",
  "module": "index.mjs",
  "type": "module",
  "devDependencies": {
    "@types/bun": "latest"
  },
  "peerDependencies": {
    "typescript": "^5.0.0"
  },
  "trustedDependencies": [
    "sharp"
  ],
  "dependencies": {
    "sharp": "^0.33.4"
  }
}

After running bun install and then bun ./index.mjs I get the following error:

bun ./index.mjs 
109 |   }
110 |   help.push(
111 |     '- Consult the installation documentation:',
112 |     '    See https://sharp.pixelplumbing.com/install'
113 |   );
114 |   throw new Error(help.join('\n'));
              ^
error: Could not load the "sharp" module using the linux-x64 runtime
undefined: libstdc++.so.6: cannot open shared object file: No such file or directory
Possible solutions:
- Ensure optional dependencies can be installed:
    npm install --include=optional sharp
    yarn add sharp --ignore-engines
- Ensure your package manager supports multi-platform installation:
    See https://sharp.pixelplumbing.com/install#cross-platform
- Add platform-specific dependencies:
    npm install --os=linux --cpu=x64 sharp
- Consult the installation documentation:
    See https://sharp.pixelplumbing.com/install
      at /home/coop/Coding/scratch/bun-sharp-test/node_modules/sharp/lib/sharp.js:114:9
      at /home/coop/Coding/scratch/bun-sharp-test/node_modules/sharp/lib/constructor.js:10:1
      at /home/coop/Coding/scratch/bun-sharp-test/node_modules/sharp/lib/index.js:6:7

Bun v1.1.20 (Linux x64)

Versions:

  • Bun: 1.1.20
  • Sharp: 0.33.4
  • Linux: Debian Linux (bookworm) x64

@pjdarch
Copy link

pjdarch commented Aug 23, 2024

Just battled with the issue for the last few days when trying to create a Dockerfile for Nuxt. Switched my docker build from alpine to debian and the issue resolved itself. Hopefully this is helpful to someone.

@zolero
Copy link

zolero commented Aug 23, 2024

You need to go to node_modules/sharp and then just do bun install again.

@rbozan
Copy link

rbozan commented Sep 16, 2024

I seem to be running into this issue too.

I have the following package.json

{
  "name": "bun-sharp-test",
  "module": "index.mjs",
  "type": "module",
  "devDependencies": {
    "@types/bun": "latest"
  },
  "peerDependencies": {
    "typescript": "^5.0.0"
  },
  "trustedDependencies": [
    "sharp"
  ],
  "dependencies": {
    "sharp": "^0.33.4"
  }
}

After running bun install and then bun ./index.mjs I get the following error:

bun ./index.mjs 
109 |   }
110 |   help.push(
111 |     '- Consult the installation documentation:',
112 |     '    See https://sharp.pixelplumbing.com/install'
113 |   );
114 |   throw new Error(help.join('\n'));
              ^
error: Could not load the "sharp" module using the linux-x64 runtime
undefined: libstdc++.so.6: cannot open shared object file: No such file or directory
Possible solutions:
- Ensure optional dependencies can be installed:
    npm install --include=optional sharp
    yarn add sharp --ignore-engines
- Ensure your package manager supports multi-platform installation:
    See https://sharp.pixelplumbing.com/install#cross-platform
- Add platform-specific dependencies:
    npm install --os=linux --cpu=x64 sharp
- Consult the installation documentation:
    See https://sharp.pixelplumbing.com/install
      at /home/coop/Coding/scratch/bun-sharp-test/node_modules/sharp/lib/sharp.js:114:9
      at /home/coop/Coding/scratch/bun-sharp-test/node_modules/sharp/lib/constructor.js:10:1
      at /home/coop/Coding/scratch/bun-sharp-test/node_modules/sharp/lib/index.js:6:7

Bun v1.1.20 (Linux x64)

Versions:

  • Bun: 1.1.20
  • Sharp: 0.33.4
  • Linux: Debian Linux (bookworm) x64

I have the same, not sure how to fix it.

❯ bun --version
1.1.27
  "resolutions": {
    "sharp": "0.33.5"
  },

@Enskiadmin
Copy link

Why was this issue closed please?

Bun seems to be having some arbitrary issues with sharp.

@ZeldOcarina
Copy link

It still doesn't work for me, unsure why this was closed..

@sequencerr
Copy link
Contributor

It still doesn't work for me, unsure why this was closed..

because other root cause was fixed. afaik it was due postinstall script

@John-Dennehy
Copy link

Same issue with Deno:

error: failed to run scripts for packages: [email protected], [email protected]

@ansh
Copy link

ansh commented Dec 2, 2024

I had to do bun pm untrusted and then trust the postinstall script by sharp

Alternatively you can cd node_modules/sharp and do bun i

@caturbgs
Copy link

just wonder after 2 years this issue still exist🤯

@sequencerr
Copy link
Contributor

@caturbgs, no it doesn't. It's closed. Please share more details about the issue. If this is a new problem, you might want to open a new issue instead of commenting on a closed one.

@Jarred-Sumner
Copy link
Collaborator

@caturbgs please open a new issue and paste the errors and the logs for what you're running into

this issue has been fixed for some time. Usually, the reason this could still come up is if a postinstall script is trying to run a C/C++ compiler and the machine or docker image doesn't have one installed or configured properly (you may need to run sudo apt-get install build-essential if this is on Ubuntu)

@oven-sh oven-sh locked as resolved and limited conversation to collaborators Jan 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working bun install Something that relates to the npm-compatible client
Projects
None yet
Development

Successfully merging a pull request may close this issue.