Closed dwomick closed 11 months ago
@Electroid This is a sharp install issue if sharp is installed with npm i sharp it adds the prebuilt binaries where using bun i it dosn't i cant really uncover which think that makes it run in node and not in bun
Could be post install this is npm i --verbose sharp
That second to last line
npm info run sharp@0.32.4 install node_modules/sharp (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
I guess its the same issue as: https://github.com/oven-sh/bun/issues/606
@sp90 you can try add sharp to trustedDependencies like in this issues https://github.com/lovell/sharp/issues/3511
@nemesisqp didnt work for me in my docker env but works locally :)
@sp90 I have a project used sharp + bun in docker too, this is my Dockerfile
FROM node:20-bookworm as builder
WORKDIR /app
RUN apt update
RUN apt install curl unzip libjemalloc2 -y
RUN curl https://bun.sh/install | bash
COPY package.json .
#COPY bun.lockb .
RUN /root/.bun/bin/bun install && \
cp /usr/lib/x86_64-linux-gnu/libjemalloc.so.2 /usr/lib/ 2>/dev/null || : && \
cp /usr/lib/aarch64-linux-gnu/libjemalloc.so.2 /usr/lib/ 2>/dev/null || :
# ? -------------------------
FROM gcr.io/distroless/cc-debian12
WORKDIR /app
COPY --from=builder /root/.bun/bin/bun bun
COPY --from=builder /app/node_modules node_modules
COPY --from=builder /app/bun.lockb ./
COPY --from=builder /usr/lib/libjemalloc.so.2 /usr/lib/
COPY src src
COPY tsconfig.json .
COPY package.json .
COPY public public
ENV NODE_ENV production
ENV VIPS_CONCURRENCY=1
ENV MALLOC_ARENA_MAX=2
ENV LD_PRELOAD=libjemalloc.so.2
CMD ["./bun", "src/index.ts"]
EXPOSE 3000
the important is don't copy bun.lockdb, I don't know if there is any side effect but it install sharp properly, above docker used jemalloc and some env for reduce memory usage, it best just spawn sharp in a child process, use it as worker process then after a while close and spawn a new one
Sharp v0.33 alpha is supported on bun FYI
Fixed by @dylan-conway and @paperdave in #7132
This will be part of the Bun v1.0.17 release, which ships in a few hours from the time of writing.
[edit: somehow missed the reporting templates when opening this issue. Providing some of the missing information below. Sorry about that.]
Bun version: 0.6.4
System: Linux 6.3.2-1-default x86_64 x86_64
Issue: The 11ty theme "Eleventy Excellent" (https://github.com/madrilene/eleventy-excellent) loads and runs with npm, but not with bun 0.6.4 (installation fails on the "sharp" module).
Steps to reproduce:
1) with bun:
git clone https://github.com/madrilene/eleventy-excellent.git test cd test bun install bun start
$ run-p dev:* $ eleventy --serve --watch [11ty] Eleventy CLI Fatal Error: (more in DEBUG output) [11ty] 1. Error in your Eleventy config file '.eleventy.js'. You may need to run (/home/don/projects/web/test/node_modules/sharp/lib/sharp.js:37:9)
[11ty] at Module._compile (node:internal/modules/cjs/loader:1218:14)
[11ty] at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
[11ty] at Module.load (node:internal/modules/cjs/loader:1081:32)
[11ty] at Module._load (node:internal/modules/cjs/loader:922:12)
[11ty] at Module.require (node:internal/modules/cjs/loader:1105:19)
[11ty] at require (node:internal/modules/cjs/helpers:103:18)
[11ty] at Object. (/home/don/projects/web/test/node_modules/sharp/lib/constructor.js:11:1)
[11ty] at Module._compile (node:internal/modules/cjs/loader:1218:14)
[11ty] at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
error: script "dev:11ty" exited with code 1 (SIGHUP)
ERROR: "dev:11ty" exited with 1.
error: script "start" exited with code 1 (SIGHUP)
npm install
. (via EleventyConfigError) [11ty] 2. Something went wrong installing the "sharp" module [11ty] [11ty] Cannot find module '../build/Release/sharp-linux-x64.node' [11ty] Require stack: [11ty] - /home/don/projects/web/test/node_modules/sharp/lib/sharp.js [11ty] - /home/don/projects/web/test/node_modules/sharp/lib/constructor.js [11ty] - /home/don/projects/web/test/node_modules/sharp/lib/index.js [11ty] - /home/don/projects/web/test/node_modules/@11ty/eleventy-img/img.js [11ty] - /home/don/projects/web/test/config/shortcodes/imagePlaceholder/index.js [11ty] - /home/don/projects/web/test/config/shortcodes/index.js [11ty] - /home/don/projects/web/test/.eleventy.js [11ty] - /home/don/projects/web/test/node_modules/@11ty/eleventy/src/Util/Require.js [11ty] - /home/don/projects/web/test/node_modules/@11ty/eleventy/src/TemplateConfig.js [11ty] - /home/don/projects/web/test/node_modules/@11ty/eleventy/src/EleventyExtensionMap.js [11ty] - /home/don/projects/web/test/node_modules/@11ty/eleventy/src/TemplateData.js [11ty] - /home/don/projects/web/test/node_modules/@11ty/eleventy/src/Eleventy.js [11ty] - /home/don/projects/web/test/node_modules/@11ty/eleventy/cmd.js [11ty] [11ty] Possible solutions: [11ty] - Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp" [11ty] - Install for the current linux-x64 runtime: "npm install --platform=linux --arch=x64 sharp" [11ty] - Consult the installation documentation: https://sharp.pixelplumbing.com/install (via Error) [11ty] [11ty] Original error stack trace: Error: [11ty] Something went wrong installing the "sharp" module [11ty] [11ty] Cannot find module '../build/Release/sharp-linux-x64.node' [11ty] Require stack: [11ty] - /home/don/projects/web/test/node_modules/sharp/lib/sharp.js [11ty] - /home/don/projects/web/test/node_modules/sharp/lib/constructor.js [11ty] - /home/don/projects/web/test/node_modules/sharp/lib/index.js [11ty] - /home/don/projects/web/test/node_modules/@11ty/eleventy-img/img.js [11ty] - /home/don/projects/web/test/config/shortcodes/imagePlaceholder/index.js [11ty] - /home/don/projects/web/test/config/shortcodes/index.js [11ty] - /home/don/projects/web/test/.eleventy.js [11ty] - /home/don/projects/web/test/node_modules/@11ty/eleventy/src/Util/Require.js [11ty] - /home/don/projects/web/test/node_modules/@11ty/eleventy/src/TemplateConfig.js [11ty] - /home/don/projects/web/test/node_modules/@11ty/eleventy/src/EleventyExtensionMap.js [11ty] - /home/don/projects/web/test/node_modules/@11ty/eleventy/src/TemplateData.js [11ty] - /home/don/projects/web/test/node_modules/@11ty/eleventy/src/Eleventy.js [11ty] - /home/don/projects/web/test/node_modules/@11ty/eleventy/cmd.js [11ty] [11ty] Possible solutions: [11ty] - Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp" [11ty] - Install for the current linux-x64 runtime: "npm install --platform=linux --arch=x64 sharp" [11ty] - Consult the installation documentation: https://sharp.pixelplumbing.com/install [11ty] at Object.2) with npm:
git clone https://github.com/madrilene/eleventy-excellent.git test_npm cd test_npm npm install npm start
[.... lots of startup logging ....]
[11ty] Watching… [11ty] Server at http://localhost:8080/ ^C
[website is up at localhost:8080....]
❯ npm version npm version { 'eleventy-excellent': '1.5.4', npm: '9.2.0', node: '19.3.0', v8: '10.8.168.21-node.8', uv: '1.44.2', zlib: '1.2.13', brotli: '1.0.9', ares: '1.18.1', modules: '111', nghttp2: '1.51.0', napi: '8', llhttp: '8.1.0', uvwasi: '0.0.13', openssl: '3.0.7+quic', cldr: '42.0', icu: '72.1', tz: '2022f', unicode: '15.0', ngtcp2: '0.8.1', nghttp3: '0.7.0' }
Also nice to have: the npm version command :)