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

Unable to get prisma 5 with nixpacks openssl #1030

Open
1 task done
Maxim-Filimonov opened this issue Dec 14, 2023 · 19 comments
Open
1 task done

Unable to get prisma 5 with nixpacks openssl #1030

Maxim-Filimonov opened this issue Dec 14, 2023 · 19 comments
Labels
bug Something isn't working community

Comments

@Maxim-Filimonov
Copy link

Maxim-Filimonov commented Dec 14, 2023

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.

@Maxim-Filimonov Maxim-Filimonov added the bug Something isn't working label Dec 14, 2023
Copy link
Contributor

Hello, @Maxim-Filimonov! Thanks for your submission.

Our team will respond soon. If you need more immediate help, try our Forum or our Discord. Thanks!

@coffee-cup
Copy link
Contributor

We have an example that builds and runs no problem using Prisma 5 and bun https://github.com/railwayapp/nixpacks/tree/main/examples/node-bun-prisma.

I can check this out further, but there is evidence of both working so I am not sure what is going on with your specific repo. Do you have a sample repo that doesn't work with Bun?

@Maxim-Filimonov
Copy link
Author

Maxim-Filimonov commented Dec 15, 2023

@coffee-cup I tried using linked example and it fails with different error for some reason.



$ bunx prisma migrate deploy

Prisma schema loaded from prisma/schema.prisma

Datasource "db": PostgreSQL database "railway", schema "public" at "roundhouse.proxy.rlwy.net:17360"

Error: P1001: Can't reach database server at `roundhouse.proxy.rlwy.net`:`17360`

Please make sure your database server is running at `roundhouse.proxy.rlwy.net`:`17360`.

error: script "start" exited with code 1 (SIGHUP)

$ bunx prisma migrate deploy

I did add shared variable DATABASE_URL.
Project on railway -> https://railway.app/project/f43b6f45-bce0-4138-bb1f-4dedca53ed97
Tried recreating postgres service - no luck.

Also tried using PRIVATE_DATABASE_URL from pg got this instead:

Error: P1001: Can't reach database server at `postgres.railway.internal`:`5432`

Please make sure your database server is running at `postgres.railway.internal`:`5432`.

@thomas779
Copy link

thomas779 commented Dec 25, 2023

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)

@imadbz
Copy link

imadbz commented Jan 23, 2024

+1 couldn't get it to work either

@baptisteArno
Copy link

I have the exact same error when trying to deploy an Elysia app. Has anyone found a fix?

@Maxim-Filimonov
Copy link
Author

Maxim-Filimonov commented Feb 6, 2024

My fix was to migrate to fly.io :|

@iloveitaly
Copy link
Contributor

--libs openssl will fix the issue, or we can get this PR merged :)

#1054

@Maxim-Filimonov
Copy link
Author

@iloveitaly where to add --libs openssl ?

@baptisteArno
Copy link

@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
Copy link
Contributor

You need it as a lib, not as a package. Without this the ENV config is not changed. Take a look at the linked PR: #1054

@GautierT
Copy link

Hey !
I did not quite understand the latest message. What is the solution to avoid this error : Unable to require(/app/node_modules/.prisma/client/libquery_engine-debian-openssl-3.0.x.so.node). 2024-03-13T14:39:50.020131817Z Prisma cannot find the required libssl system library in your system. Please install openssl-3.0.x and try again.

Thanks !

@ksaitor
Copy link

ksaitor commented Mar 26, 2024

Even on the latest prisma@^5.11.0 still getting this error on Nixpacks (running inside Coolify)

╔═════════════ Nixpacks v1.21.2 ═════════════╗
║ setup │ nodejs_21, bun, openssl ║
║────────────────────────────────────────────║
║ install │ bun i --no-save ║
║────────────────────────────────────────────║
║ build │ echo Skip build process ║
║────────────────────────────────────────────║
║ start │ bun run worker/main.worker.ts ║
╚════════════════════════════════════════════╝
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.

@ksaitor
Copy link

ksaitor commented Mar 26, 2024

--libs openssl

where do you add --libs openssl ? @iloveitaly

@Maxim-Filimonov were you able to resolve this?

@Maxim-Filimonov
Copy link
Author

@ksaitor I haven't tried since it wasn't working when I needed it for initial launch. It works pretty well on fly I don't really see a reason why try to move it back to railway TBH.

@JakeCooper
Copy link
Contributor

Fixable by simply specifying binaryTargets

amorriscode/elysia-starter#2 (comment)

@ksaitor
Copy link

ksaitor commented Mar 26, 2024

added NIXPACKS_LIBS=openssl and it worked!
notice: not NIXPACKS_PKGS

cc @baptisteArno check it out

@JakeCooper
Copy link
Contributor

@ksaitor Could you link the Railway project where it works or a repo with it working so that we can fix it at the nixpacks level?

@ksaitor
Copy link

ksaitor commented Mar 27, 2024

@ksaitor Could you link the Railway project where it works or a repo with it working so that we can fix it at the nixpacks level?

@JakeCooper I'm not on Railway. I'm on Coolify, that's using Nixpacks under the hood. Nixpacks v1.21.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working community
Projects
None yet
Development

No branches or pull requests

9 participants