nixpacks: Unable to get prisma 5 with nixpacks openssl

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Following up on the issue Prisma does support open ssl 3.0.x now. However, for some reason I’m still not able to use nixpack with Prisma. I tried installing libssl-dev in setup stage and got the same error.

To reproduce

After building i get the following error on trying to instantiate PrismaClient(): index.ts

import { PrismaClient} from '@prisma/client'
const prisma = new PrismaClient();

Error:

PrismaClientInitializationError: Unable to require(`/app/node_modules/.prisma/client/libquery_engine-debian-openssl-3.0.x.so.node`).

Prisma cannot find the required `libssl` system library in your system. Please install openssl-3.0.x and try again.

Details: libssl.so.3: cannot open shared object file: No such file or directory

at new e (/app/node_modules/@prisma/client/runtime/library.js:26:1871)

Noticed that it’s using libquery_engine-debian-openssl-3.0.x.so.node - shouldn’t be using ubuntu version not debian ?

Expected behavior

Able to build and deploy application using Prisma.

Environment

nixpacks.toml

[phases.setup]
aptPkgs = ["..."]
[phases.build]
cmds = ["...", "bunx prisma generate", "bunx prisma migrate deploy"]

package.json

 "dependencies": {
    "@prisma/client": "5.7.0",
  },

Bun: 1.0.17

I have no problems running locally.

About this issue

  • Original URL
  • State: open
  • Created 7 months ago
  • Reactions: 1
  • Comments: 19 (6 by maintainers)

Most upvoted comments

Bumping this as I’m getting the exact issue to @Maxim-Filimonov. Everything works locally, but deploying to railway is a journey of painful debugging.

@coffee-cup if you need some hard evidence, I would suggest running through these steps:

  1. fork this repo: https://github.com/amorriscode/elysia-starter
  2. "prisma": "5.7.1" and "@prisma/client": "5.7.1" (versions shouldn’t matter, but some devs reported having it fixed downgrading or upgrading… error was replicated with v5.3.x and v5.7.x on my side).
  3. cp this schema.prisma:

What’s your Prisma schema set-up Maxim ? This is mine:

datasource db {
    provider = "postgresql"
    url      = env("DATABASE_URL")
}

generator client {
    provider      = "prisma-client-js"
    output        = "./generated/client"
    binaryTargets = ["native", "linux-musl", "debian-openssl-3.0.x"]
}

nixpacks.toml:

[phases.setup]
nixPkgs = ['bun']

[phases.install]
cmds = ['bun install']

[phases.build]
cmds = ['bunx prisma generate', 
        'bunx prisma migrate deploy', 
        'bun build --target=bun ./src/index.ts --outdir ./build']

[start]
cmd = 'bun run src/index.ts'

Error:

PrismaClientInitializationError: Unable to require(`/app/prisma/generated/client/libquery_engine-debian-openssl-3.0.x.so.node`).
Prisma cannot find the required `libssl` system library in your system. Please install openssl-3.0.x and try again.
Details: libssl.so.3: cannot open shared object file: No such file or directory

Tried to add 'openssl_3_0_x to my nixPkgs = ['bun', 'openssl_3_0_x'] but that didn’t work.

Also, changing start cmd from bun run src/index.ts to bun run build/indexjs will produce error:

Server is running at localhost:5000
1 | __dirname
^
ReferenceError: Can't find variable: __dirname
at /app/build/index.js:1604:69
at processTicksAndRejections (:61:76)

@iloveitaly Nah, I that’s not it… I think nixpacks even detected that it needs openssl by default for my project.

Still, I tried to specifically tell it to add the openssl lib with the env NIXPACKS_PKGS=openssl

╔═══════════════ Nixpacks v1.20.0 ══════════════╗
║ setup │ openssl, nodejs_18, bun, openssl ║
║───────────────────────────────────────────────║
║ install │ bun install ║
║───────────────────────────────────────────────║
║ build │ bun build:chat-api ║
║───────────────────────────────────────────────║
║ start │ bun start:chat-api ║
╚═══════════════════════════════════════════════╝

The problem happens at runtime, on the docker when the app is running, on Prisma init, it says:

PrismaClientInitializationError: Unable to require(`/app/node_modules/.prisma/client/libquery_engine-debian-openssl-3.0.x.so.node`).

Prisma cannot find the required `libssl` system library in your system. Please install openssl-3.0.x and try again.

Details: libssl.so.3: cannot open shared object file: No such file or directory

at new e (/app/node_modules/@prisma/client/runtime/library.js:26:1871)

@iloveitaly where to add --libs openssl ?

My fix was to migrate to fly.io 😐

+1 couldn’t get it to work either