R
Railwayโ€ข15mo 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โ€ข15mo ago
Project ID: 66d1dae6-5074-4f50-8a3b-03d95403b988
Spacemandev
SpacemandevOPโ€ข15mo 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โ€ข15mo ago
does prisma not work with bun yet? bunx prisma generate
Spacemandev
SpacemandevOPโ€ข15mo ago
it does not (atleast on railway)
luna
lunaโ€ข15mo ago
does that work locally?
Spacemandev
SpacemandevOPโ€ข15mo ago
yes works locally
luna
lunaโ€ข15mo 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
SpacemandevOPโ€ข15mo 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โ€ข15mo ago
i have the same problem
luna
lunaโ€ข15mo 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โ€ข15mo ago
This is odd, I don't think that's running an ARM image... Does it work if you remove binaryTargets?
Spacemandev
SpacemandevOPโ€ข15mo 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โ€ข15mo 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
SpacemandevOPโ€ข15mo ago
i had that before (see other thread), and it gave the SSL error https://discord.com/channels/713503345364697088/1150374587658403961/1152804112153444392
Ray
Rayโ€ข15mo ago
yikes what's your Prisma version?
Spacemandev
SpacemandevOPโ€ข15mo ago
5.3 i believe 5.3.1* to be exact
Ray
Rayโ€ข15mo 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
SpacemandevOPโ€ข15mo ago
thank you!
dott.bio/maus
dott.bio/mausโ€ข15mo 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โ€ข14mo ago
So to be exact node being used to generate prisma and then bun to run the files
dott.bio/maus
dott.bio/mausโ€ข14mo ago
Exactly. Then symlink the .so/.3-files to make the prisma driver work.
jr
jrโ€ข14mo ago
What are the errors that you get? I was able to do this no problem
dott.bio/maus
dott.bio/mausโ€ข14mo ago
Interesting! Under which section did you put the nixLibs? ๐Ÿ™‚
jr
jrโ€ข14mo ago
setup
dott.bio/maus
dott.bio/mausโ€ข14mo ago
I'll give it a go! ๐Ÿ‘ Wat: failed to create symbolic link '/etc/resolv.conf': Device or resource busy ๐Ÿ”
jr
jrโ€ข14mo ago
Link to build logs?
dott.bio/maus
dott.bio/mausโ€ข14mo 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โ€ข14mo 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โ€ข14mo 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โ€ข14mo ago
What happens if you add the nixLibs part? ๐Ÿ™‚
jr
jrโ€ข14mo ago
it is added by default now I don't see any errors
dott.bio/maus
dott.bio/mausโ€ข14mo ago
Oh! OK. ๐Ÿ‘ Let me try entirely w/o it then.
jr
jrโ€ข14mo ago
you shouldn't need any of the node stuff either
dott.bio/maus
dott.bio/mausโ€ข14mo 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โ€ข14mo 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โ€ข14mo ago
Hehey! ๐ŸŽ‰ Awesome work, jr, thanks a lot! ๐Ÿ™Œ
ClearMist
ClearMistโ€ข14mo 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โ€ข14mo 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โ€ข14mo 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โ€ข14mo ago
Yes you can just use a Dockerfile if you would like
Want results from more Discord servers?
Add your server