Can't deploy Firebase functions (Failed to fetch Run service undefined)
Asked Answered
A

6

39

Can't deploy Firebase functions. I have two project aliases, it's working fine for the first project (dev), but not for the second (prod).
Whenever I write firebase deploy --only functions I get the following message

i deploying functions
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
i  artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled...
+  functions: required API cloudbuild.googleapis.com is enabled
+  artifactregistry: required API artifactregistry.googleapis.com is enabled
+  functions: required API cloudfunctions.googleapis.com is enabled
i  functions: preparing codebase default for deployment
!  functions: package.json indicates an outdated version of firebase-functions. Please upgrade 
using npm install --save firebase-functions@latest in your functions directory.
!  functions: Please note that there will be breaking changes when you upgrade.
i  functions: Loaded environment variables from .env.prod.
!  functions: You are using an old version of firebase-functions SDK (3.15.7). Please update 
firebase-functions SDK to >=3.20.0
i  functions: preparing functions directory for uploading...
i  functions: packaged E:\FlutterProjects\pegasus\functions (218.61 KB) for uploading

Error: Failed to fetch Run service undefined
Authoritarian answered 10/12, 2022 at 23:53 Comment(0)
J
58

I had the same issue and it was fixed for me when installed the latest firebase tools

npm install -g firebase-tools

Jasperjaspers answered 11/12, 2022 at 10:5 Comment(3)
This did the trick for me: sudo npm install -g firebase-tools --forcePregnant
If you've added firebase-tools to your ci/cd pipeline and it keeps failing with the same error, you just need to update the firebase-tools version being used in your pipeline. See cloud.google.com/build/docs/deploying-builds/deploy-firebase for moreGyrostatic
If you are stuck on a lower version (I was stuck on 11.1.0) then follow this https://mcmap.net/q/409549/-cannot-upgrade-or-remove-firebase-from-system to get to 11.18.0Closer
P
8

This was also fixed automatically by upgrading the version of firebase-tools using the command npm install -g firebase-tools.

You can add the --force flag if you encounter the below error

npm ERR! code EEXIST
npm ERR! path /usr/local/bin/firebase
npm ERR! EEXIST: file already exists
npm ERR! File exists: /usr/local/bin/firebase
Presuppose answered 13/12, 2022 at 7:8 Comment(0)
I
5

You may also need to re-source your terminal. I checked my version after npm i -g firebase-tools and it still wasn't 11.18.0 but did a source ~/.zshrc and it fixed the issue.

Involucel answered 14/12, 2022 at 22:22 Comment(1)
Or source ~/.bashrc depending upon your environment. Or simply close the terminal and reopen before attempting firebase deploy after updating firebase-tools.Champaigne
A
1

You need to update your firebase-tools. Run npm install -g firebase-tools.

Agency answered 12/12, 2022 at 23:40 Comment(0)
A
1

When you're using Firebase Tools with a version that is less than or equal to v11.18.0, you might encounter the following error:

Error: Failed to fetch Run service undefined

The first thing that you should take into consideration is to update to a version that is newer than or equal to v11.18.0. By the time I'm answering this question, the latest version is 11.20.0.

Furthermore, install the latest Firebase tools by using the following line of code in your terminal:

npm install -g firebase-tools --force
npm audit fix

P.S. It's also recommended to update Firebase Function to the latest available version which now it's 4.1.1.

Alasdair answered 9/1, 2023 at 7:33 Comment(0)
E
0

Make sure you execute npm install -g firebase-tools in the functions folder.

Episiotomy answered 28/12, 2022 at 5:40 Comment(1)
This installs the dependency globaly, not in the functions folder.Selves

© 2022 - 2025 — McMap. All rights reserved.