prisma: Prisma CLI installation hangs indefinitely inside of docker (Kernel 5.10)

Bug description

@prisma/cli installation hangs indefinitely inside of docker

How to reproduce

REPRO: https://github.com/svelters/prisma-poc

Expected behavior

It should install without container discrimination

Prisma information

@prisma/cli version: “2.15.0”

Environment & setup

  • OS: Linux - Docker (alpine, debian etc…)
  • Database: doesn’t matter
  • Node.js version: 15.6.0 but it seems to fail on any version we tried
  • Prisma version: doesn’t matter as it fails because of the cli

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 18
  • Comments: 69 (24 by maintainers)

Most upvoted comments

With @prisma/client v2.24.0 I’m again experiencing yarn install hanging on docker at:

[5/5] Building fresh packages...

Anyone else facing the same?

I’m having a similar issue running npm i in a codebuild project… any official workaround?

I can reproduce this in a debian vm which I manually upgraded to linux kernal 5.10 on digitalocean. I can’t reproduce this on windows or mac so the kernel version hunch is correct.

image

Linux debian-s-1vcpu-1gb-intel-blr1-01 5.10.17-051017-generic #202102170631 SMP Wed Feb 17 11:37:41 UTC 2021 x86_64 GNU/Linux

This will need more investigation. @pimeys should look into this as @Jolg42 pointed out this might be build related.

Just checked and it appears we changed build images used to produce the binaries one day before that specific commit https://github.com/prisma/engine-images/commits/master Screen Shot 2021-02-24 at 17 44 01

Likely related I guess.

2.24.0 works for me as well!

2.24.0 worked for me. I did run into an issue but that was my fault. I should have done yarn upgrade @prisma/client@2.24.0 vs updating package.json then running yarn, then removing my yarn.lock file and rerunning yarn 😬.

uname -a

Linux 2ef0c037-7695-4298-81e5-1616836bacbf-ppkrl 5.10.25-flatcar #1 SMP Wed Mar 24 17:11:24 -00 2021 x86_64 Linux
    export DEBUG="prisma,prisma:*"

first time pnpm install --filter="{.}..." :

.../node_modules/@prisma/engines postinstall$ node download/index.js
../..                                    | Progress: resolved 1017, reused 0, downloaded 1017, added 1017, done
.../nodemon@2.0.7/node_modules/nodemon postinstall$ node bin/postinstall || exit 0
.../nodemon@2.0.7/node_modules/nodemon postinstall: Done
.../node_modules/@prisma/engines postinstall: 2021-05-07T02:07:24.501Z prisma:download file /opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/@prisma+engines@2.23.0-6.cd459a60adc2f40ba38ed4cb1d6a5885e452c515/node_modules/@prisma/engines/query-engine-linux-musl does not exist and must be downloaded
.../node_modules/@prisma/engines postinstall: 2021-05-07T02:07:24.503Z prisma:download file /opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/@prisma+engines@2.23.0-6.cd459a60adc2f40ba38ed4cb1d6a5885e452c515/node_modules/@prisma/engines/migration-engine-linux-musl does not exist and must be downloaded
.../node_modules/@prisma/engines postinstall: 2021-05-07T02:07:24.503Z prisma:download file /opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/@prisma+engines@2.23.0-6.cd459a60adc2f40ba38ed4cb1d6a5885e452c515/node_modules/@prisma/engines/prisma-fmt-linux-musl does not exist and must be downloaded
.../node_modules/@prisma/engines postinstall: 2021-05-07T02:07:24.503Z prisma:download file /opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/@prisma+engines@2.23.0-6.cd459a60adc2f40ba38ed4cb1d6a5885e452c515/node_modules/@prisma/engines/introspection-engine-linux-musl does not exist and must be downloaded
.../node_modules/@prisma/engines postinstall: 2021-05-07T02:07:24.506Z prisma:download Downloading https://binaries.prisma.sh/all_commits/cd459a60adc2f40ba38ed4cb1d6a5885e452c515/linux-musl/query-engine.gz to /opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/@prisma+engines@2.23.0-6.cd459a60adc2f40ba38ed4cb1d6a5885e452c515/node_modules/@prisma/engines/query-engine-linux-musl
.../node_modules/@prisma/engines postinstall: 2021-05-07T02:07:24.536Z prisma:download Downloading https://binaries.prisma.sh/all_commits/cd459a60adc2f40ba38ed4cb1d6a5885e452c515/linux-musl/migration-engine.gz to /opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/@prisma+engines@2.23.0-6.cd459a60adc2f40ba38ed4cb1d6a5885e452c515/node_modules/@prisma/engines/migration-engine-linux-musl
.../node_modules/@prisma/engines postinstall: 2021-05-07T02:07:24.538Z prisma:download Downloading https://binaries.prisma.sh/all_commits/cd459a60adc2f40ba38ed4cb1d6a5885e452c515/linux-musl/introspection-engine.gz to /opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/@prisma+engines@2.23.0-6.cd459a60adc2f40ba38ed4cb1d6a5885e452c515/node_modules/@prisma/engines/introspection-engine-linux-musl
.../node_modules/@prisma/engines postinstall: 2021-05-07T02:07:24.539Z prisma:download Downloading https://binaries.prisma.sh/all_commits/cd459a60adc2f40ba38ed4cb1d6a5885e452c515/linux-musl/prisma-fmt.gz to /opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/@prisma+engines@2.23.0-6.cd459a60adc2f40ba38ed4cb1d6a5885e452c515/node_modules/@prisma/engines/prisma-fmt-linux-musl
.../node_modules/@prisma/engines postinstall: Done
.../node_modules/prisma preinstall$ node scripts/preinstall-entry.js
.../node_modules/prisma preinstall: Done
.../node_modules/prisma install$ node scripts/install-entry.js
.../node_modules/prisma install: Done
.../node_modules/@prisma/client postinstall$ node scripts/postinstall.js
.../node_modules/@prisma/client postinstall: 2021-05-07T02:07:26.832Z prisma:loadEnv project root found at /opt/atlassian/pipelines/agent/build/node/package.json
.../node_modules/@prisma/client postinstall: 2021-05-07T02:07:26.845Z prisma:tryLoadEnv Environment variables not found at null
.../node_modules/@prisma/client postinstall: 2021-05-07T02:07:26.845Z prisma:tryLoadEnv Environment variables not found at undefined
.../node_modules/@prisma/client postinstall: 2021-05-07T02:07:26.846Z prisma:tryLoadEnv No Environment variables loaded
.../node_modules/@prisma/client postinstall: 2021-05-07T02:07:26.847Z prisma:engines using NAPI: false
.../node_modules/@prisma/client postinstall: 2021-05-07T02:07:26.848Z prisma:engines binaries to download query-engine, migration-engine, introspection-engine, prisma-fmt
.../node_modules/@prisma/client postinstall: prisma:warn The postinstall script automatically ran `prisma generate` and did not find your `prisma/schema.prisma`.
.../node_modules/@prisma/client postinstall: If you have a Prisma schema file in a custom path, you will need to run
.../node_modules/@prisma/client postinstall: `prisma generate --schema=./path/to/your/schema.prisma` to generate Prisma Client.
.../node_modules/@prisma/client postinstall: If you do not have a Prisma schema file yet, you can ignore this message.
.../node_modules/@prisma/client postinstall: 2021-05-07T02:07:27.697Z prisma:cli Error: Could not find a schema.prisma file that is required for this command.
.../node_modules/@prisma/client postinstall: You can either provide it with --schema, set it as `prisma.schema` in your package.json or put it into the default location ./prisma/schema.prisma https://pris.ly/d/prisma-schema-location
.../node_modules/@prisma/client postinstall:     at Object.getSchema3 (/opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/prisma@2.23.0-dev.7/node_modules/prisma/build/index.js:10136:13)
.../node_modules/@prisma/client postinstall:     at async main (/opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/prisma@2.23.0-dev.7/node_modules/prisma/build/index.js:109780:22)
.../node_modules/@prisma/client postinstall: Done

after:

rm -rf node_modules ../../node_modules &&
     rm -rf /root/.cache/prisma &&
     pnpm install --no-optional --prod --filter="{.}..."
.../node_modules/@prisma/engines postinstall$ node download/index.js
.../node_modules/@prisma/engines postinstall: 2021-05-07T02:07:54.058Z prisma:download file /opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/@prisma+engines@2.23.0-6.cd459a60adc2f40ba38ed4cb1d6a5885e452c515/node_modules/@prisma/engines/migration-engine-linux-musl does not exist and must be downloaded
.../node_modules/@prisma/engines postinstall: 2021-05-07T02:07:54.060Z prisma:download file /opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/@prisma+engines@2.23.0-6.cd459a60adc2f40ba38ed4cb1d6a5885e452c515/node_modules/@prisma/engines/introspection-engine-linux-musl does not exist and must be downloaded
.../node_modules/@prisma/engines postinstall: 2021-05-07T02:07:54.060Z prisma:download file /opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/@prisma+engines@2.23.0-6.cd459a60adc2f40ba38ed4cb1d6a5885e452c515/node_modules/@prisma/engines/query-engine-linux-musl does not exist and must be downloaded
.../node_modules/@prisma/engines postinstall: 2021-05-07T02:07:54.060Z prisma:download file /opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/@prisma+engines@2.23.0-6.cd459a60adc2f40ba38ed4cb1d6a5885e452c515/node_modules/@prisma/engines/prisma-fmt-linux-musl does not exist and must be downloaded
.../node_modules/@prisma/engines postinstall: 2021-05-07T02:07:54.063Z prisma:download Downloading https://binaries.prisma.sh/all_commits/cd459a60adc2f40ba38ed4cb1d6a5885e452c515/linux-musl/query-engine.gz to /opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/@prisma+engines@2.23.0-6.cd459a60adc2f40ba38ed4cb1d6a5885e452c515/node_modules/@prisma/engines/query-engine-linux-musl
.../node_modules/@prisma/engines postinstall: 2021-05-07T02:07:54.101Z prisma:download Downloading https://binaries.prisma.sh/all_commits/cd459a60adc2f40ba38ed4cb1d6a5885e452c515/linux-musl/introspection-engine.gz to /opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/@prisma+engines@2.23.0-6.cd459a60adc2f40ba38ed4cb1d6a5885e452c515/node_modules/@prisma/engines/introspection-engine-linux-musl
.../node_modules/@prisma/engines postinstall: 2021-05-07T02:07:54.103Z prisma:download Downloading https://binaries.prisma.sh/all_commits/cd459a60adc2f40ba38ed4cb1d6a5885e452c515/linux-musl/migration-engine.gz to /opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/@prisma+engines@2.23.0-6.cd459a60adc2f40ba38ed4cb1d6a5885e452c515/node_modules/@prisma/engines/migration-engine-linux-musl
.../node_modules/@prisma/engines postinstall: 2021-05-07T02:07:54.105Z prisma:download Downloading https://binaries.prisma.sh/all_commits/cd459a60adc2f40ba38ed4cb1d6a5885e452c515/linux-musl/prisma-fmt.gz to /opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/@prisma+engines@2.23.0-6.cd459a60adc2f40ba38ed4cb1d6a5885e452c515/node_modules/@prisma/engines/prisma-fmt-linux-musl
.../node_modules/@prisma/engines postinstall: Done
.../node_modules/prisma preinstall$ node scripts/preinstall-entry.js
.../node_modules/prisma preinstall: Done
.../node_modules/prisma install$ node scripts/install-entry.js
.../node_modules/prisma install: Done
.../node_modules/@prisma/client postinstall$ node scripts/postinstall.js
.../node_modules/@prisma/client postinstall: 2021-05-07T02:07:58.155Z prisma:loadEnv project root found at /opt/atlassian/pipelines/agent/build/node/package.json
.../node_modules/@prisma/client postinstall: 2021-05-07T02:07:58.171Z prisma:tryLoadEnv Environment variables not found at null
.../node_modules/@prisma/client postinstall: 2021-05-07T02:07:58.171Z prisma:tryLoadEnv Environment variables not found at undefined
.../node_modules/@prisma/client postinstall: 2021-05-07T02:07:58.171Z prisma:tryLoadEnv No Environment variables loaded
.../node_modules/@prisma/client postinstall: 2021-05-07T02:07:58.173Z prisma:engines using NAPI: false
.../node_modules/@prisma/client postinstall: 2021-05-07T02:07:58.173Z prisma:engines binaries to download query-engine, migration-engine, introspection-engine, prisma-fmt
.../node_modules/@prisma/client postinstall: prisma:warn The postinstall script automatically ran `prisma generate` and did not find your `prisma/schema.prisma`.
.../node_modules/@prisma/client postinstall: If you have a Prisma schema file in a custom path, you will need to run
.../node_modules/@prisma/client postinstall: `prisma generate --schema=./path/to/your/schema.prisma` to generate Prisma Client.
.../node_modules/@prisma/client postinstall: If you do not have a Prisma schema file yet, you can ignore this message.
.../node_modules/@prisma/client postinstall: 2021-05-07T02:07:59.323Z prisma:cli Error: Could not find a schema.prisma file that is required for this command.
.../node_modules/@prisma/client postinstall: You can either provide it with --schema, set it as `prisma.schema` in your package.json or put it into the default location ./prisma/schema.prisma https://pris.ly/d/prisma-schema-location
.../node_modules/@prisma/client postinstall:     at Object.getSchema3 (/opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/prisma@2.23.0-dev.7/node_modules/prisma/build/index.js:10136:13)
.../node_modules/@prisma/client postinstall:     at async main (/opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/prisma@2.23.0-dev.7/node_modules/prisma/build/index.js:109780:22)
.../node_modules/@prisma/client postinstall: Done

and then the kicker: pnpx prisma generate

2021-05-07T02:08:00.429Z prisma:loadEnv project root found at /opt/atlassian/pipelines/agent/build/node/Services/service-xxxxxxxxxx/package.json
2021-05-07T02:08:00.442Z prisma:tryLoadEnv Environment variables not found at null
2021-05-07T02:08:00.443Z prisma:tryLoadEnv Environment variables not found at undefined
2021-05-07T02:08:00.443Z prisma:tryLoadEnv No Environment variables loaded
2021-05-07T02:08:00.445Z prisma:engines using NAPI: false
2021-05-07T02:08:00.445Z prisma:engines binaries to download query-engine, migration-engine, introspection-engine, prisma-fmt
Prisma schema loaded from prisma/schema.prisma
2021-05-07T02:08:01.684Z prisma:download copying /root/.cache/prisma/master/cd459a60adc2f40ba38ed4cb1d6a5885e452c515/linux-musl/query-engine to /opt/atlassian/pipelines/agent/build/node/node_modules/.pnpm/prisma@2.23.0-dev.7/node_modules/prisma/query-engine-linux-musl

Entrypoint for node download/index.js

@prisma/fetch-engine “prisma:download copying … to …”

Perhaps copy or getHash never return?

I have managed to get past it by calling rm -rf /root/.cache/prisma/ before each npm install / pnpx prisma generate

Hey sorry for the delay here. I was busy with my exams. I will look into this today 😃

in order to reproduce the issue, you have to use a 5+ linux kernel. It doesn’t surprise me it works fine on mac as the hypervisor does a different job.

My network is quiet normal, no special stuff going on. The issue is just the same at work too.

Regarding the logs, there isn’t much more going on.

Could someone at prisma try with a debian “unstable” VM?

This is the one I used to pinpoint the kernel issue: https://cdimage.debian.org/cdimage/weekly-builds/amd64/iso-cd/debian-testing-amd64-netinst.iso

Thank’s for the notes, good to know!

Can you try with 2.24.0 @desaiuditd? If this does not work, we have to keep this issue open or create a new one 😦

Can all the other people who participated in the issue maybe also try the new release and let us know if it works? Thanks!

All good. I also had to bump prisma package along with @prisma/client. It’s working now.

On this debian 10.9 machine I noticed that using <= node:13-alpine works:

  • node:10-alpine: ok
  • node:12-alpine: ok
  • node:13-alpine: ok
  • node:14-alpine: bad
  • node:15-alpine: bad

With Debian Buster based images:

  • node:10-buster: ok
  • node:12-buster: bad
  • node:14-buster: bad
  • node:15-buster: bad

Yes it does but it shouldn’t be needed.

@alechp

  1. Nice find, the latest working version is the 10.0.0 The 10.0.1 is the culprit! @Jolg42 https://github.com/prisma/prisma/commit/ad8506c1e01d52f574484461055aeb4599c2b929 It seems indeed related to the @prisma/engine

  2. Yup but I am only at the bootstrap stage so far on my project (looking into authentication workflow with nexus)

@Jolg42 Would it be possible to include this issue in the 2.18.0 Milestone?

the repro has been updated and still failing on 2.17.0.

Both prisma (cli) and @prisma/client have been updated.

just tried it, it’s still broken.

I’ve updated the repro though.

It’s the same by using the prisma package btw

2.24.0 is out 👍

2.24.0-dev.34 did not work for me. I tried to do yarn install for a repo where "@prisma/client": "^2.24.0-dev.34" is included in its package.json file. I used node:15.14.0-alpine3.13 docker image for this. And yarn install still continues to hang forever. I’m using Docker Desktop 3.3.3.

@janpio The workaround release works for me! Upgraded docker desktop back up to 3.3.3. Thanks so much!

Having the same issue inside an Ubuntu container (tried debian, alpine, too) in an Ubuntu VM with Linux 5.8 (for Gitlab CI) …

jcde@fridge:~$ uname -r
5.8.0-53-generic

Example:

$ yarn --frozen-lockfile --production
yarn install v1.22.10
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@2.3.2: The platform "linux" is incompatible with this module.
info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[removed because it's irrelevant]
[4/4] Building fresh packages...
Done in 106.49s.       <===== After I ran  "rm -rf /root/.cache/prisma/, takes only 12 secs on my laptop

yarn install hangs until I manually remove /root/.cache/prisma/, which is pretty annoying. I wasted a whole day trying to find the problem (until I found this issue).

The exact same thing works on my laptop running Arch Linux

❯ uname -r
5.12.0-zen1-1-zen-g14

Hope this gets resolved soon.

@JacobMuchow

Did you try adding rm -rf /root/.cache/prisma/ before

both:

  • yarn, and
  • npx prisma generate

You should be finding that:

  • The 1st time, yarn / prisma / post-install … downloads
  • The 2nd time, prisma generate … does a COPY.

It’s the COPY, that is falling over.

@ywada526 you should run uname in your container. As far as I know docker containers run in a virtualized linux on macos

Hi all,

I’m reproducing the issue on a debian 10.9 machine. I’m using the latest version of the reproduction https://github.com/svelters/prisma-poc/commit/a21cf21b1172670c0222b5130c69428c7438e04d . Removing -T does not work for me.

Linux 5.10.0-0.bpo.4-amd64 #1 SMP Debian 5.10.19-1~bpo10+1 (2021-03-13) x86_64 GNU/Linux

docker-compose run api yarn install is stuck and here is what’s happening in the container:

% docker exec -it --user 0 cf9d941a9677 sh -c 'apk add procps; ps auxf | cat'
...
node         1 12.9  0.3 366632 124192 pts/0   Ssl+ 21:42   0:19 node /opt/yarn-v1.22.5/bin/yarn.js install --verbose
node        65  0.0  0.1 280304 33532 ?        Ssl  21:43   0:00 /usr/local/bin/node scripts/postinstall.js
node        76  100  0.2 345176 69076 ?        Sl   21:43   2:20  \_ /usr/local/bin/node /app/node_modules/prisma/build/index.js generate --postinstall "yarn install --verbose"

Notice 100% cpu, strace shows 0 syscall activity.


The exact same thing works on another Arch Linux machine (updated ~a week ago).

Linux 5.11.13-arch1-1 #1 SMP PREEMPT Sat, 10 Apr 2021 20:47:14 +0000 x86_64 GNU/Linux

very weird

Same issue while running prisma generate in a node:lts-alpine container. It works on the first build in a node:lts container, but fails with the next one

I have a good workaround:

https://github.com/svelters/prisma-poc/commit/a21cf21b1172670c0222b5130c69428c7438e04d

It seems like the problem is tty related.

I added the candidate label so we don’t forget about it, I think @pantharshit00 has this on his list to try but I think he’s quite busy right now. 🤞

I’m noticing the same (or related) issue. Hopefully helpful context:

  • I currently have a successfully deployed prisma@2.6.1 service running in the wild. Works locally (both node & docker), passes CI/CD build step and is successfully running in production (docker)

  • I have a new prisma service that runs locally (both node & docker), but fails when compiling in GitHub Actions

These services are very similar.

  • Both work perfectly when run locally (in either raw nodeJS or inside docker)
  • Both have identical Dockerfiles
  • Both are using the same CI/CD pipeline (ie. Identical GitHub Actions script, both using Docker Hub, both being deployed to the same Gateway on k8s, same secret management, etc.)

The only differences:

  • new service fails to deploy using the same GitHub Actions script
  • new service is running prisma 2.17.0 (2.16.1 fails as well) instead of the older 2.6.1
  • new service is using Nexus with prisma
  • new service is using the express Apollo Server along with the vanilla express package

My local environment is a mac The GitHub Actions environment where this fails is a Linux box

Ok, so the issue comes from the kernel version used.

  • No issue on a debian stretch VM using version 4.19.0-13.
  • The issue is present on version 5.10.0-2. As is it linked to the kernel, it does affect any linux distribution.

I can confirm the culprit is https://github.com/prisma/prisma/blob/master/src/packages/client/scripts/postinstall.js

Thank you @dickfickling

  try {
    if (localPath) {
      await run('node', [
        localPath,
        'generate',
        '--postinstall',
        doubleQuote(getPostInstallTrigger()),
      ])
      return
    }

I spent a lot of time trying to pinpoint the issue.

Maybe someone working on @prisma/cli could take a look?

Maybe worth trying docker-compose build --no-cache ?