执行prisma db push 报错 Downloading Prisma engines for Node-API for rhel-openssl-1.1.x []0%Error

YoungJeff
·发布于 8 个月前·
28 人看过
  1. 这个问题,在https://github.com/prisma/prisma/discussions/18744中已经有解决过

  2. 但需要注意如果prisma版本在5.0.0后,因为PRISMA_MIGRATION_ENGINE_BINARY环境变量已被弃用(https://www.prisma.io/docs/orm/reference/environment-variables-reference),所以,需要PRISMA_SCHEMA_ENGINE_BINARY进行替换,PRISMA_SCHEMA_ENGINE_BINARY的下载路径,

    wget https://binaries.prisma.sh/all_commits/659ef412370fa3b41cd7bf6e94587c1dfb7f67e7/rhel-openssl-1.1.x/schema-engine.gz
    
  1. 如果第2步没有正确设置,prisma db push执行或许解决了,但是到build项目的时候,可能导致另外一个问题: https://github.com/prisma/prisma/issues/20721 (我就是因为第2步设置错了,在引出了新的问题上卡了好久)

完整解决路径

  1. 下载引擎,先cd到你想放的目录(比如我的是/root/wget),然后执行

    注:引擎地址的路径https://binaries.prisma.sh/all_commits/659ef412370fa3b41cd7bf6e94587c1dfb7f67e7/rhel-openssl-1.1.x根据你自己的报错地址更改

    wget https://binaries.prisma.sh/all_commits/659ef412370fa3b41cd7bf6e94587c1dfb7f67e7/rhel-openssl-1.1.x/libquery_engine.so.node.gz
    wget https://binaries.prisma.sh/all_commits/473ed3124229e22d881cb7addf559799debae1ab/rhel-openssl-1.1.x/schema-engine.gz
    wget https://binaries.prisma.sh/all_commits/473ed3124229e22d881cb7addf559799debae1ab/rhel-openssl-1.1.x/prisma-fmt.gz
    wget https://binaries.prisma.sh/all_commits/473ed3124229e22d881cb7addf559799debae1ab/rhel-openssl-1.1.x/query-engine.gz
    
  1. 解压引擎文件

    gzip -d libquery_engine.so.node.gz
    gzip -d schema-engine.gz
    gzip -d prisma-fmt.gz
    gzip -d query-engine.gz
    
  1. 授权schema-engine执行权限

    chomd +x schema-engine
    
  1. 设置环境变量(以mac为例)

    执行 vim ~/.zshrc

    添加

    # wget
    export WGET_DIR="$HOME/wget"
    ENGINE_DIR="${WGET_DIR}"
    export PRISMA_QUERY_ENGINE_LIBRARY="${WGET_DIR}/libquery_engine.so.node"
    export PRISMA_QUERY_ENGINE_BINARY="${WGET_DIR}/query-engine"
    export PRISMA_SCHEMA_ENGINE_BINARY="${WGET_DIR}/schema-engine"
    export PRISMA_FMT_BINARY="${WGET_DIR}/prisma-fmt"
    

    变量解释:

    WGET_DIR:因为我把引擎下载到/root/wget,而$HOME代表root

  2. 执行source ~/.zshrc,使配置即刻生效

再次执行prisma db push就没问题了

Next.js
Prisma
$ cd ..