Keval Tank
Keval Tank

Reputation: 41

Unable to deploy firebase cloud functions to any firebase project from my machine (but it works perfectly fine on my colleague's machine)

Mac-mini configuration

This is my mac-mini M1 configuration and I'm trying to deploy firebase functions but it is not allowing me to deploy and every time shows me this error.

When I run this command it throws an error :

me@-Mac-mini demo % firebase deploy --only functions:helloWorld



=== Deploying to 'demo'...

i  deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run build

> build
> tsc

✔  functions: Finished running predeploy script.
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔  functions: required API cloudfunctions.googleapis.com is enabled
✔  functions: required API cloudbuild.googleapis.com is enabled
i  functions: preparing codebase default for deployment
i  functions: preparing functions directory for uploading...
i  functions: packaged /Users/me/Documents/work/workspace/demo/functions (56.87 KB) for uploading
✔  functions: functions folder uploaded successfully
i  functions: creating Node.js 16 function helloWorld(us-central1)...
⚠  functions: failed to create function projects/demo/locations/us-central1/functions/helloWorld
Failed to create function projects/demo/locations/us-central1/functions/helloWorld

Functions deploy had errors with the following functions:
        helloWorld(us-central1)
i  functions: cleaning up build files...
⚠  functions: Unhandled error cleaning up build images. This could result in a small monthly bill if not corrected. You can attempt to delete these images by redeploying or you can delete them manually at https://console.cloud.google.com/artifacts/docker/demo/us-central1/gcf-artifacts

Error: There was an error deploying functions

The actual log of the error :

{"@type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{"code":7,"message":"Cloud Functions uses Artifact Registry to store function docker images. Artifact Registry API is not enabled in your project. To enable the API, use the gcloud command 'gcloud services enable artifactregistry.googleapis.com' then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."}

Other versions info :

   NPM version : 8.11.0
   Firebase version : 11.2.0
   Node version : 16.15.1

Firebase package.json

{
  "name": "functions",
  "scripts": {
    "build": "tsc",
    "build:watch": "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"
  },
  "engines": {
    "node": "16"
  },
  "main": "lib/index.js",
  "dependencies": {
    "firebase-admin": "^10.2.0",
    "firebase-functions": "^3.21.0"
  },
  "devDependencies": {
    "typescript": "^4.6.4"
  },
  "private": true
}

Deploying from MacBook-pro-2014 Deploying from MacBook-pro-2014 Deploying from Mac-mini-m1 Deploying from Mac-mini-m1

Why I am unable to deploy cloud functions from my machine and why is my colleague able to deploy the same cloud functions to same Firebase project from his machine even without enabling Artifacts Registry?

Upvotes: 2

Views: 2030

Answers (1)

John Hanley
John Hanley

Reputation: 81454

The Artifact Registry API is not enabled in your project.

The solution requires that billing is enabled for your project.

Provided that the CLI has permission to enable services, run this command:

gcloud services enable artifactregistry.googleapis.com

Or use the Google Cloud Console UI

More information is available in the Artifact Registry Documentation:

Upvotes: 3

Related Questions