Firebase Cloud Functions : Failed to read credentials from file
Asked Answered
S

3

18

Due to new Firebase Cloud Functions (version > 1.0). I only need to call

admin.initializeApp();

Without any parameters.

However when I did like that then run firebase deploy --only functions , this error occurred :

Failed to read credentials from file G:\projects\ANOTHER_PROJECT\ANOTHER_PROJECT.json: Error: ENOENT: no such file or directory, open 'G:\projects\ANOTHER_PROJECT\ANOTHER_PROJECT.json'

Surtout answered 15/2, 2019 at 14:6 Comment(3)
You're going to have to give more information about how you're running the code. Please give the exact steps that anyone can use to reproduce the problem.Encumber
I ran the app by using firebase deploy --only functionsSurtout
When doing the mandatory upgrade from Node 6 to Node 8 I am running into the same issue.Booking
W
37

I found out the issue was that i had GOOGLE_APPLICATION_CREDENTIALS environment variable defined which was pointing to json file which did not exist and i had long deleted.

I deleted the GOOGLE_APPLICATION_CREDENTIALS env variable. Restarted the terminal and then firebase deploy --only functions worked flawlessly.

Wetmore answered 25/4, 2019 at 18:26 Comment(2)
How did you deleted it ?Enclasp
Never mind, I just saw it's shell. Just need to use unset VAR_NAMEEnclasp
T
6

If you have set the GOOGLE_APPLICATION_CREDENTIALS env variable right then just close the terminal and open a new one since the changes you have applied are not always taken into consideration in the current terminal

Tutor answered 21/4, 2020 at 20:5 Comment(1)
For local dev: this plus using a full path instead of relative path was the answer for me.Delciedelcina
C
5

In my case, I was adding the " in the path, I was using the windows terminal.

I hope it works for someone.

Coparcener answered 21/5, 2020 at 2:46 Comment(1)
where did you add what exactly?Obit

© 2022 - 2024 — McMap. All rights reserved.