What is the value of GCLOUD_PROJECT while running Firebase emulators?

610 views Asked by At

I run firebase emulators:start to test my functions locally.
In my functions I use the GCLOUD_PROJECT environment variable to initialize firebase-admin accordingly.
What is the value of GCLOUD_PROJECT while running the emulators?

1

There are 1 answers

0
Doug Stevenson On BEST ANSWER

According to this pull request, GCLOUD_PROJECT should work like this:

Manually tested:

firebase emulators:exec --project foo 'env | grep GCLOUD' correctly outputs GCLOUD_PROJECT=foo
firebase emulators:exec 'env | grep GCLOUD' gives nothing if firebase.json not present
firebase emulators:exec 'env | grep GCLOUD' uses project id from firebase.json if available

Also, in the documentation, it states:

There are environment variables that are automatically populated in the functions runtime and in locally emulated functions, including:

process.env.GCLOUD_PROJECT: Provides the Firebase project ID

If it doesn't work the way you expect, then I suggest filing an issue on the same repo.