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 establish a connection to query-engine-node-api library. It seems there is a problem with your OpenSSL installation! #14073

Closed
rootusrsystem32 opened this issue Jun 30, 2022 · 38 comments
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. tech/engines Issue for tech Engines. topic: cli topic: openssl topic: ssl

Comments

@rootusrsystem32
Copy link

rootusrsystem32 commented Jun 30, 2022

Bug description

Error: Get Config: Unable to establish a connection to query-engine-node-api library. It seems there is a problem with your OpenSSL installation!
Details: Unable to require(`/home/florian/zac-management/node_modules/.pnpm/prisma@4.0.0/node_modules/prisma/libquery_engine-debian-openssl-1.1.x.so.node`)
 libssl.so.1.1: cannot open shared object file: No such file or directory

How to reproduce

  1. run next dev and prisma generate will cause the issue

Environment & setup

  • OS: Ubuntu (WSL2)
  • Database: MySQL (Planetscale)
  • Node.js version: 16.15

Prisma Version

4.0.0
@rootusrsystem32 rootusrsystem32 added the kind/bug A reported bug. label Jun 30, 2022
@pimeys pimeys added team/client Issue for team Client. bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Jun 30, 2022
@mjpaquet
Copy link

mjpaquet commented Jul 1, 2022

Same type of error

Error: Get Config: Unable to establish a connection to query-engine-node-api library. It seems there is a problem with your OpenSSL installation!
Details: Unable to require(`/home/max/WWW-PROJECT/vendeurv3/node_modules/@prisma/engines/libquery_engine-debian-openssl-3.0.x.so.node`)
 /snap/core20/current/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /lib/x86_64-linux-gnu/libcrypto.so.3)

Prisma CLI Version : 4.0.0
Ubuntu 22.04 LTS
NodeJS 16.15.1
Database: MySQL (Planetscale)

@mjpaquet
Copy link

mjpaquet commented Jul 1, 2022

i have try an old version of my code that is actually in production on server. it was working on the same PC with the same config

npx prisma generate
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Error: Get config: Unable to establish a connection to query-engine-node-api library

Prisma CLI Version : 3.15.2

i don't understand what is going on

thx

@janpio
Copy link
Member

janpio commented Jul 1, 2022

@mjpaquet Your environment changed. See this issue and comment for your specific case: #13717 (comment)

@mjpaquet
Copy link

mjpaquet commented Jul 2, 2022

Thank @janpio it was the problem.

NodeJS was sandbox by Ubuntu Software (Snap)

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs

now everything is working

@rootusrsystem32
Copy link
Author

I m using fnm still the same issue.

@mjpaquet
Copy link

mjpaquet commented Jul 2, 2022

Have you try to manually install OpenSSL and glibC ?

on my case it was already done

@rootusrsystem32
Copy link
Author

Did some investigation. Ubuntu 22.04 has upgraded libssl to 3, and does not propose libssl1.1

@DePasqualeOrg
Copy link
Contributor

I'm also having this issue on Ubuntu 22.04.

@smithbm2316
Copy link

smithbm2316 commented Jul 10, 2022

If any of you still having this issue are using Homebrew on your machine, I found out through some very annoying debugging that apparently Homebrew had a higher precedence on my $PATH, and since I had installed other programs with it that depended on the OpenSSL 1.1 binary, my system was defaulting to that as the binary to use for OpenSSL instead of the default installed binary by Ubuntu (in my case Pop OS, a derivative of Ubuntu) in /usr/bin/openssl. Try running openssl version and if you get back OpenSSL 1.1.1p 21 Jun 2022 or something with 1.x in it, that may be your issue. By making sure that /usr/bin had precedence in my $PATH over my Homebrew install, my system used the proper binaries installed by apt (openssl, libssl-dev, and libc6). Very niche issue, but hope this might help save someone else 1+ hours of digging 😅. All of this was total user error as the way I had added Homebrew to my $PATH was not what I intended, so I mistakenly had given it higher precedence over all my default /usr system folders.

TLDR check and see if you have any other versions of OpenSSL installed on your system as a peer-dependency via something like Homebrew or another package manager, and make sure that version of OpenSSL is on version 3 or is not taking precedence over your system package manager's version of OpenSSL

@kapilsarma2002
Copy link

This solved my issue! Thanks very much.

@kaykhan
Copy link

kaykhan commented Jul 18, 2022

smithbm2316

This is not a good solution because you will cause other programs that have been installed via homebrew to break. if i set /usr/bin in my zshrc to be before homebrew bin directory. It breaks other things i installed via homebrew

@kaykhan
Copy link

kaykhan commented Jul 18, 2022

Did some investigation. Ubuntu 22.04 has upgraded libssl to 3, and does not propose libssl1.1

What was your solution?

@wilgnerl
Copy link

wilgnerl commented Jul 25, 2022

Guys, I had this problem here and I found out that anaconda (which uses python) had the openssl version in 1.1.0, even though I updated the openssl version for my machine in 3.0.2 zsh just couldn't find this version the anaconda. What I did was put the version of my machine as the main version of the system, with this change prisma started working again !!

@DePasqualeOrg
Copy link
Contributor

What I did was put the version of my machine as the main version of the system

Can you be more specific?

@wilgnerl
Copy link

My computer had two versions of openssl: an anaconda version 1.1.0 and a 3.0.2 version downloaded from ubuntu. The problem was that Prisma was using the version of anaconda that was out of date and not the latest version that was installed. I solved the problem by taking out the anaconda version and using only the updated version

@DePasqualeOrg
Copy link
Contributor

I meant: Can you be more specific about the steps you took to remove Conda's version of OpenSSL? I see that Conda has installed OpenSSL on my system, but when I run conda uninstall openssl, it wants to uninstall Conda and fails.

@wilgnerl
Copy link

Now I get it. Well I found out that openssl was the one for anaconda using the command which openssl which returned the path of the anaconda version. With that I opened the .zshrc (nano .zshrc) and commented out everything I had of anaconda reference. To confirm I used the command which openssl again and now it pointed to the path of the most current version

@haysclark
Copy link

For folks running Prisma on K8 environments (like GKE, etc) in a container, you will want to use node:16-bullseye-slim (or a similar base image with Debian included) instead of just something like node:16-slim.

@SebasG22
Copy link

SebasG22 commented Oct 6, 2022

Now I get it. Well I found out that openssl was the one for anaconda using the command which openssl which returned the path of the anaconda version. With that I opened the .zshrc (nano .zshrc) and commented out everything I had of anaconda reference. To confirm I used the command which openssl again and now it pointed to the path of the most current version

I can confirm the anaconda installation is having issues with openssl. Now works as a charm.
Thanks

@janpio
Copy link
Member

janpio commented Oct 6, 2022

Anaconda = https://www.anaconda.com/? Can you describe the setup a bit how you get into this situation?

@greendesertsnow
Copy link

I installed OpenSSL.Light and the problem is gone.
Env: Node 16 LTS, Windows 11.

@Princekrampah
Copy link

If you have conda running on base, just go ahead and deactivate it conda deactivate then run npx prisma studio

@victorkurauchi
Copy link

I had the same issue when running my nodejs+prisma app with Docker.

I was initially using FROM node:16-alpine and after changing to FROM node:16-bullseye-slim it was working again.

@zackdotcomputer
Copy link

For @victorkurauchi and others getting this issue on Alpine Linux (especially in Docker), this comment in another issue pointed out that the latest Alpine strips out legacy OpenSSL APIs. This caused this issue to start occurring for me recently. I was able to fix it without downgrading or cross-grading to bullseye or buster by adding this line to my dockerfile before the npm install command:

RUN apk add --update --no-cache openssl1.1-compat

@filipefborba
Copy link

@zackdotcomputer solution worked for me! Just added this line of code to my Dockerfile and was good to go.
If you divide your dockerfile into different steps (like builder and runner), don't forget to add this line to all of them.

Thank you all!

@AskAlice
Copy link

AskAlice commented Dec 13, 2022

I had the same issue when running my nodejs+prisma app with Docker.

I was initially using FROM node:16-alpine and after changing to FROM node:16-bullseye-slim it was working again.

Just curious, does anyone know what changed that could have caused this to be come an issue? Our docker image was using a pinned version (ie: 16.x.x-alpine) and it started having this issue sometime within the past few days.

edit: alpine pushed a new version out that bumped openssl up to 3.0, and the alpine version isn't pinned in that package name.

@rgaume-delfingen
Copy link

Hello,
it doesn't work me

I have switched from FROM node:lts-alpine to FROM node:16-bullseye-slim and stil have this error :

Error: Get config: Unable to establish a connection to query-engine-node-api library

I am looking on a way to fix my Dockerfile, in the meantime if someone has a fix ... Thanks !

@mkhmylife
Copy link

I switched from FROM node:16-alpine to FROM node:16-alpine3.16 and it works for me. It's not a "fix", but it will work for me now.

@mlerman-stratuscent
Copy link

Looks like something is happening with the library: openssl1.1-compat it is now switched to "dev" status: https://pkgs.alpinelinux.org/contents?file=libssl.so&path=&name=&branch=&arch=

Probably switching between images is an intermediate solution...

Adding line below helped to build the image:

RUN apk add --no-cache libc6-compat
RUN apk add --no-cache openssl1.1-compat-dev

Here is the full docker file:

## Docker file from here: https://github.com/prisma/prisma/issues/12417#issuecomment-1238242374

##########
## DEPS ##
##########
FROM node:lts-alpine AS deps
RUN apk add --no-cache libc6-compat
RUN apk add --no-cache openssl1.1-compat-dev

WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
    if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
    elif [ -f package-lock.json ]; then npm ci; \
    elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; \
    else echo "Lockfile not found." && exit 1; \
    fi

COPY prisma ./prisma
RUN pnpm prisma generate

#############
## BUILDER ##
#############
FROM node:lts-alpine  AS builder
RUN apk add --no-cache libc6-compat

WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app .
COPY . .

RUN npm run build

############
## RUNNER ##
############
FROM node:lts-alpine  AS runner

WORKDIR /app

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./
USER nextjs

CMD ["node", "./main.js"]

@garth
Copy link

garth commented Dec 14, 2022

I switched from FROM node:16-alpine to FROM node:16-alpine3.16 and it works for me. It's not a "fix", but it will work for me now.

For node v18 the docker tag node:18.12-alpine3.16 also "fixes" the issue.

@jkomyno
Copy link
Contributor

jkomyno commented Dec 15, 2022

Hey everyone, Alberto from Prisma here. For anyone getting this error on Linux Alpine (e.g., on node:alpine or node:lts-alpine), please refer to #16553 (comment)

@simonjcarr
Copy link

I was using node:18-alpine in a VS Code dev container and getting this error. My solution was to switch to node:18, and rebuild the container.

@pimeys pimeys added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Dec 20, 2022
@filipedev6
Copy link

Instalei o OpenSSL.Light e o problema acabou. Ambiente: Nó 16 LTS, Windows 11.

❤️👌

@diaraujo13
Copy link

Even with OpenSSL installed on my machine (I have installed it through Brew), that's what solved for me (Ubuntu 22.04):
https://stackoverflow.com/a/72633324/1747282

@jkomyno
Copy link
Contributor

jkomyno commented Dec 28, 2022

Hey @diaraujo13, would you happen to have a Dockerfile describing your machine state? If not, would you able to tell us which exact steps you've followed for installing brew and openssl? We're aware of OpenSSL detection issues on Ubuntu when using Homebrew, but were unable to reproduce them. Please see this comment for an example.

EwanLyon added a commit to ausspeedruns/ausspeedruns-keystone that referenced this issue Jan 6, 2023
schoblaska added a commit to schoblaska/jotrecipes that referenced this issue Mar 24, 2023
schoblaska added a commit to schoblaska/jotrecipes that referenced this issue Mar 24, 2023
@aqrln
Copy link
Member

aqrln commented Mar 28, 2023

There's a few different issues in this thread, but all or most of them seem to be fixed already. OpenSSL version detection when Homebrew or Anaconda is installed should be fixed as of Prisma 4.9.0, and support for OpenSSL 3 on Alpine was added in Prisma 4.8.0. One thing I'm not quite sure about and need to check is @mjpaquet's report of Prisma not working with Node.js installed via snap — but this is a completely different problem than the other ones in this GitHub issue and needs to be extracted to a separate issue since it's not trackable as a comment here.

I'm going to go ahead and close this issue, please let us know if I missed something and it needs to be reopened, or open a new issue if you run into any problems!

@aqrln aqrln closed this as completed Mar 28, 2023
@devHaitham481
Copy link

fixed by running npm remove prisma and then npm install prisma problem solved 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. tech/engines Issue for tech Engines. topic: cli topic: openssl topic: ssl
Projects
None yet
Development

No branches or pull requests