R
Railwayβ€’11mo ago
Spacemandev

OpenSSL error when using Bun + Prisma

Getting an error when using Bun and prisma together. Prisma requires node to work, so start command is npx prisma generate && bun run src/server.ts Also my nixpacks.toml has nodejs_18 in it via
[phases.setup]
nixPkgs = ['...', 'nodejs_18']
aptPkgs = ['...', 'libssl-dev']
[phases.setup]
nixPkgs = ['...', 'nodejs_18']
aptPkgs = ['...', 'libssl-dev']
No description
40 Replies
Percy
Percyβ€’11mo ago
Project ID: 66d1dae6-5074-4f50-8a3b-03d95403b988
Spacemandev
Spacemandevβ€’11mo ago
66d1dae6-5074-4f50-8a3b-03d95403b988 https://discord.com/channels/713503345364697088/1150374587658403961/1153088907349606460 looks like this might be a problem with node / bun having conflicts on libssl
luna
lunaβ€’11mo ago
does prisma not work with bun yet? bunx prisma generate
Spacemandev
Spacemandevβ€’11mo ago
it does not (atleast on railway)
luna
lunaβ€’11mo ago
does that work locally?
Spacemandev
Spacemandevβ€’11mo ago
yes works locally
luna
lunaβ€’11mo ago
then ditch the npm lock file and npm command and just use bun for the lot of it. you'll have less issues
Spacemandev
Spacemandevβ€’11mo ago
i removed the node requirements and instead generated the client locally and pushed it (generating debian binary target for railway as required) still getting libssl not found.
No description
No description
No description
Michael
Michaelβ€’11mo ago
i have the same problem
luna
lunaβ€’11mo ago
GitHub
Prisma generate doens't work in Docker Β· Issue #3827 Β· oven-sh/bun
What version of Bun is running? 0.7 What platform is your computer? Darwin 22.5.0 arm64 arm What steps can reproduce the bug? prisma generate appears to do nothing when run with bunx in docker. It ...
Ray
Rayβ€’11mo ago
This is odd, I don't think that's running an ARM image... Does it work if you remove binaryTargets?
Spacemandev
Spacemandevβ€’11mo ago
no it specifically tells me to add debian as a binary target if i remove it when you build prisma, it compiles, i got around building it in the cloud by not needing node and then just building it locally and then pushing but doing that required me to build both for native (my macbook so i can use it locally) and debian for the railway image then i pushed the compiled build into my repo hoping i could just use bun instead of "npx prisma generate && bun run..." because that comamnd was giving an libssl error which previously in the other thread had been mentioned as potentially coming from a mix of node/bun
Ray
Rayβ€’11mo ago
If you're open to trying this out: nixpacks.toml:
[phases.setup]
nixPkgs = ['...', 'nodejs_18']
[phases.setup]
nixPkgs = ['...', 'nodejs_18']
+ change start script to bunx prisma generate && bun run src/server.ts
Spacemandev
Spacemandevβ€’11mo ago
i had that before (see other thread), and it gave the SSL error https://discord.com/channels/713503345364697088/1150374587658403961/1152804112153444392
Ray
Rayβ€’11mo ago
yikes what's your Prisma version?
Spacemandev
Spacemandevβ€’11mo ago
5.3 i believe 5.3.1* to be exact
Ray
Rayβ€’11mo ago
I'll try to poke into this when time permits, sounds like an upstream issue though the jury's out on whether it's Bun/Prisma - but will keep you posted!
Spacemandev
Spacemandevβ€’11mo ago
thank you!
dott.bio/maus
dott.bio/mausβ€’11mo ago
Hey gang! Having this very same issue. Prisma will look in /usr/lib64 and /lib64 for libssl. However, there is no libssl there, even though you've installed it. Running openssl version -e in the container returns:
ENGINESDIR: "/nix/store/2kl52k9kclb82bg8nvf4paxb3v972c70-openssl-3.0.10/lib/engines-3
ENGINESDIR: "/nix/store/2kl52k9kclb82bg8nvf4paxb3v972c70-openssl-3.0.10/lib/engines-3
So I just think there's a missing symlink or $LD_LIBRARY_PATH missing somewhere. I don't have any experience with NixOS or Nixpacks, so would love some help here. πŸ™
/usr/lib/x86_64-linux-gnu/libssl.so.3
/usr/lib/x86_64-linux-gnu/libssl.so
/usr/lib/x86_64-linux-gnu/libssl.so.3
/usr/lib/x86_64-linux-gnu/libssl.so
That's where they exist RN. Will try to symlink. πŸ‘ I got it up and running: πŸŽ‰ Both with prisma generate and starting the server. This is my nixpacks.toml:
[phases.setup]
nixPkgs = ['...', 'nodejs']

[phases.build]
cmds = [
'...',
'bun run prisma generate',
'ln -s /usr/lib/x86_64-linux-gnu/libssl.so /lib/libssl.so',
'ln -s /usr/lib/x86_64-linux-gnu/libssl.so.3 /lib/libssl.so.3',
'ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so /lib/libcrypto.so',
'ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.3 /lib/libcrypto.so.3',
]

[start]
cmd = 'bun run start'
[phases.setup]
nixPkgs = ['...', 'nodejs']

[phases.build]
cmds = [
'...',
'bun run prisma generate',
'ln -s /usr/lib/x86_64-linux-gnu/libssl.so /lib/libssl.so',
'ln -s /usr/lib/x86_64-linux-gnu/libssl.so.3 /lib/libssl.so.3',
'ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so /lib/libcrypto.so',
'ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.3 /lib/libcrypto.so.3',
]

[start]
cmd = 'bun run start'
I'm not sure if this is a good idea, but it works. πŸ‘ Explanation: - Prisma will look in /lib for libssl.so.3 and libcrypto.so.3, so we symlink them there. - It needs to be /lib since prisma will use $LD_LIBRARY_PATH when searching, and only /lib is included by default - You can run prisma generate by including nodejs in your container (you can remove it after running it) - Also: OpenSSL is already included in the container by default (no need to add it!) I have also tried using nixLibs = ['...', 'openssl'] in both [start] and [phases.build]. But I get super weird errors. I believe this is a better solution, for sure, if it would work.
ClearMist
ClearMistβ€’11mo ago
So to be exact node being used to generate prisma and then bun to run the files
dott.bio/maus
dott.bio/mausβ€’10mo ago
Exactly. Then symlink the .so/.3-files to make the prisma driver work.
jr
jrβ€’10mo ago
What are the errors that you get? I was able to do this no problem
dott.bio/maus
dott.bio/mausβ€’10mo ago
Interesting! Under which section did you put the nixLibs? πŸ™‚
jr
jrβ€’10mo ago
setup
dott.bio/maus
dott.bio/mausβ€’10mo ago
I'll give it a go! πŸ‘ Wat: failed to create symbolic link '/etc/resolv.conf': Device or resource busy πŸ”
jr
jrβ€’10mo ago
Link to build logs?
dott.bio/maus
dott.bio/mausβ€’10mo ago
Railway
404 - Page not found
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
dott.bio/maus
dott.bio/mausβ€’10mo ago
Funky, huh? If you cannot see the nixpacks.toml, this is it:
[phases.setup]
nixPkgs = ['...', 'imagemagick', 'nodejs', 'openssl']
nixLibs = ['...', 'openssl']

[phases.build]
cmds = [
'...',
'bun run checkdeps',
'bun run get-chrome',
'bun run prisma generate',
'rm -f /usr/bin/node',
]

[start]
cmd = 'bun run start'
[phases.setup]
nixPkgs = ['...', 'imagemagick', 'nodejs', 'openssl']
nixLibs = ['...', 'openssl']

[phases.build]
cmds = [
'...',
'bun run checkdeps',
'bun run get-chrome',
'bun run prisma generate',
'rm -f /usr/bin/node',
]

[start]
cmd = 'bun run start'
jr
jrβ€’10mo ago
ya very strange. I am not able to reproduce using latest nixpacks version. I have this nixpacks.toml
[phases.setup]
nixPkgs = ['...', 'imagemagick']

[phases.build]
cmds = [
'...',
'bun run prisma generate',
]

[start]
cmd = 'bun run start'
[phases.setup]
nixPkgs = ['...', 'imagemagick']

[phases.build]
cmds = [
'...',
'bun run prisma generate',
]

[start]
cmd = 'bun run start'
Nixpacks will include nodejs when bun is found now. And the openssl lib will be added I am able to prisma generate no problem
dott.bio/maus
dott.bio/mausβ€’10mo ago
What happens if you add the nixLibs part? πŸ™‚
jr
jrβ€’10mo ago
it is added by default now I don't see any errors
dott.bio/maus
dott.bio/mausβ€’10mo ago
Oh! OK. πŸ‘ Let me try entirely w/o it then.
jr
jrβ€’10mo ago
you shouldn't need any of the node stuff either
dott.bio/maus
dott.bio/mausβ€’10mo ago
There's soon going to be nothing left of my nixpacks.toml at this rate. Did you push some new stuff, or have I been hallucinating all these errors from before? 🫠 πŸ˜‚ It works great now, either way. Thanks for all the help! πŸ™Œ
jr
jrβ€’10mo ago
I pushed a glibc fix and we now better handle Bun with node. Glad it is working now πŸ˜„
dott.bio/maus
dott.bio/mausβ€’10mo ago
Hehey! πŸŽ‰ Awesome work, jr, thanks a lot! πŸ™Œ
ClearMist
ClearMistβ€’10mo ago
oh railway uses toml files for configuration? I haven't used railway yet, I'm thinking of using it in the future but I've to make sure that I can use bun and node in the same environment at the same time, seems like you got that working Though I've opened an issue on the Prisma side to have a look into it incase it's an "issue" on their end being dependant on node
dott.bio/maus
dott.bio/mausβ€’10mo ago
Indeed, it uses nixpacks. It supports JSON too, though! Basically the configuration specifies what to include in your container, and how to build your app.
ClearMist
ClearMistβ€’10mo ago
oh I see, can we use images as well to specify this? I got this from the community that had similar issue
ENV NODE_VERSION=18.17.1
RUN apt update
RUN apt install -y curl
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
ENV NVM_DIR=/root/.nvm
RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
RUN node --version
RUN npm --version
ENV NODE_VERSION=18.17.1
RUN apt update
RUN apt install -y curl
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
ENV NVM_DIR=/root/.nvm
RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
RUN node --version
RUN npm --version
jr
jrβ€’10mo ago
Yes you can just use a Dockerfile if you would like