首页 > 解决方案 > 部署 Cloud Functions 时发生主机密钥验证失败

问题描述

问题

当我尝试部署云功能时,有时Host key verification failed.会发生。
它似乎发生在 GCP 中,因为我可以npm install在本地完成。

环境

当我更换我的 ssh 密钥时,它似乎有一段时间没问题,但它会重现。

我使用 gitlab 来管理源代码,一些常见的存储库在 gitlab 中。
尝试部署功能的项目对该公共存储库具有依赖性。

环境

节点 v10.17.0
npm v6.11.3
firebase v7.12.1

错误日志

⚠  functions[appv1(us-central1)]: Deployment error.
Build failed: {"error":{"buildpackId":"google.nodejs.npm","buildpackVersion":"0.9.0","errorType":2,"canonicalCode":2,"errorId":"b0ba1f57","errorMessage":"npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142\nnpm WARN deprecated sendgrid@1.9.2: Please see v6.X+ at https://www.npmjs.com/org/sendgrid\nnpm WARN deprecated core-js@2.6.11: core-js@\u003c3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.\nnpm WARN deprecated natives@1.1.6: This module relies on Node.js's internals and will break at some point. Do not use it, and update to graceful-fs@4.x.\nnpm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated\nnpm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated\nnpm ERR! Error while executing:\nnpm ERR! /usr/bin/git ls-remote -h -t ssh://git@gitlab.com/myrepos/my-rpc-client.git\nnpm ERR! \nnpm ERR! Host key verification failed.\nnpm ERR! fatal: Could not read from remote repository.\nnpm ERR! \nnpm ERR! Please make sure you have the correct access rights\nnpm ERR! and the repository exists.\nnpm ERR! \nnpm ERR! exited with error code: 128\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     /builder/home/.npm/_logs/2020-04-09T02_36_20_019Z-debug.log"},"stats":null}

代码

这是我的 package.json 的片段

{
  "name": "functions",
  "scripts": {
    "lint": "eslint \"src/**/*.ts\" --cache",
    "build": "tsc",
    "buildWatch": "tsc --watch",
    "serve": "npm run build && firebase emulators:start --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log",
    "test": "jest --coverage --verbose"
  },
  "dependencies": {
    "@google-cloud/firestore": "^3.7.3",
    "@google-cloud/logging": "^5.5.5",
    "my-rpc-client": "git+ssh://git@gitlab.com/myrepos/my-rpc-client.git#1.0.0",
  },
  "private": true
}

附加信息

我找到了一些文章并尝试将“忽略”选项设置为“package-lock.json”,还尝试使用节点 v8,但它不起作用。

https://github.com/firebase/firebase-functions/issues/446
https://github.com/firebase/firebase-functions/issues/607

有人有解决办法吗??

标签: firebasegoogle-cloud-functions

解决方案


推荐阅读