prisma: Incorrect platform for CloudLinux OS
Bug description
On a CloudLinux OS, in my understanding, prisma doesn’t use/download the correct engine. Hence, native target doesn’t match the systyem and we can’t generate client, nor launch prisma -v
Expected engine should be rhel-openssl-1.0.x, but debian-openssl-1.1.x is used.
I can tweak the files (rhel files named as debian ones) so that prisma -v works
(which confirms that rhel engine should be used)
But can’t find a way to make generate work, even with binaryTargets = ["rhel-openssl-1.0.x"]
in prisma.schema
(may be linked to the implicite native ? https://github.com/prisma/prisma/issues/12691)
Error logs :
prisma -v (see below for the working output)
Environment variables loaded from .env
Error: Command failed with exit code 127: /home/wufwjymd/nodevenv/drimex/14/lib/node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x --version
/home/wufwjymd/nodevenv/drimex/14/lib/node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
prisma generate
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Error: Unable to require(`/home/wufwjymd/nodevenv/drimex/14/lib/node_modules/prisma/libquery_engine-debian-openssl-1.1.x.so.node`)
/lib64/libc.so.6: version `GLIBC_2.18' not found (required by /home/wufwjymd/nodevenv/drimex/14/lib/node_modules/prisma/libquery_engine-debian-openssl-1.1.x.so.node)
How to reproduce
Can be reproduced every time in a Node.js environnement provided by Planethoster
Environment & setup
- OS: CloudLinux , kernel version leads to CloudLinux 7 (that’s why I tried the rhel engine)
- Node.js version: v14.17.3
Prisma Version
With files tweaked
Environment variables loaded from .env
prisma : 3.14.0
@prisma/client : 3.14.0
Current platform : debian-openssl-1.1.x
Query Engine (Node-API) : libquery-engine 2b0c12756921c891fec4f68d9444e18c7d5d4a6a (at ../nodevenv/drimex/14/lib/node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Migration Engine : migration-engine-cli 2b0c12756921c891fec4f68d9444e18c7d5d4a6a (at ../nodevenv/drimex/14/lib/node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core 2b0c12756921c891fec4f68d9444e18c7d5d4a6a (at ../nodevenv/drimex/14/lib/node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary : prisma-fmt 2b0c12756921c891fec4f68d9444e18c7d5d4a6a (at ../nodevenv/drimex/14/lib/node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash : 2b0c12756921c891fec4f68d9444e18c7d5d4a6a
Studio : 0.460.0
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 26 (8 by maintainers)
If you only need the Prisma client running on PlanetHoster, I ended up with a more convenient way by building the app (and most importantly generating Prisma client) outside of PlanetHoster with a matching node version, and running the app on it afterwards.
For that, before build you can add
binaryTargets = ["rhel-openssl-1.0.x"]
ingenerator client { }
of schema.prisma, and after the app is built (that means afterprisma generate
), you would have to rename innode_modules/.prisma/client
folderlibquery_engine-rhel-openssl-1.0.x.so.node
tolibquery_engine-debian-openssl-1.1.x.so.node
– The other workaround involved modifying builded/packed js files, that’s not clean, but in the files I mentioned in the previous message, the idea is to make the
getPlatform()
function directly returningrhel-openssl-1.0.x
. Download script isn’t present anymore, so same modification innodes_modules/@prisma/engines/dist/postinstall.js
, After that innodes_modules/@prisma/engines
folder, you would have to runnode scripts/postinstall.js
to download the appropriate engines.Thank you for the context. So far, Prisma seems to be running fine on CloudLinux with the default Debian client.
The cleanest fix / workaround: Needs a root access on the server, You can do that or ask your server administrator to do that for you. The reason of having that issue, because by default CloudLinux does not allow users to access
/etc/os-release
file, and these steps would give the access to users to read that file.nano /etc/cagefs/conf.d/os.cfg
File content should be:
Then run the following command to update CageFS rules:
cagefsctl --force-update
Now from the user account SSH, you can directly execute
npx prisma generate
, It will detect the OS as RHEL.OK, all good for me 👍 There is the expected fallback warning but It’s working now.
Thanks! I believe it would totally solve the issue (there was indeed a problem with OpenSSL version, but it has been fixed #14042). I’ll confirm when 4.14 will be released.
Edit: 4.14 is actually already released, I will soon confirm.
Thank for the additional details @Maxime-J and @jcubic!
So, as far as I understand, there are two separate things we can do here:
The way I circumvent that is not sustainable, a bit hacky, and might not suit every case. So I prefer not to share an exact process, it’s better to wait for an override platform detection feature.
Anyway, without the details, it involves editing prisma production files
nodes_modules\prisma\build\index.js
andnodes_modules@prisma\client\runtime\index.js
and download the appropriate engine innodes_modules\@prisma\engines
with the download script inside and the corresponding environment variable.Is that a problem with our current, existing implementation? Then this might be worth a new, separate issue where you explain just this problem and why this is undesirable.
I’ll fill a feature request 👍
Thanks for the info of how it works.
Concerning the detection, I bet the problem is specific to shared setups used by providers, where
/etc/os-release
isn’t accessible (saw that on PlanetHoster and o2switch), whereas it is on a simple CloudLinux setup.Given how prisma detects the distribution https://github.com/prisma/engines-wrapper/blob/main/packages/get-platform/src/getPlatform.ts#L110 a working way would be to check there the presence of
/usr/sbin/cloudlinux-selector
and returnrhel
.But maybe it’s better to rely on a platform override feature for these edge cases?
(and I finally manage to circumvent my issue with some tweaking 😃 )