Open ahume opened 6 years ago
This has started working with the same version of the emulator, and unfortunately I don't know what I changed.
Environment
Steps to reproduce
googleapis
npm package:
const {google} = require("googleapis");
google.auth.getApplicationDefault((err, authClient, projectId) => {
//...
}
I'm encountering a problem where the environment variable GOOGLE_APPLICATION_CREDENTIALS
is not set while running the function emulator. This is a problem, because process.env.GOOGLE_APPLICATION_CREDENTIALS
is used to hold the default authentication credential information. I (currently) run the functions emulator using sudo
; however, I have confirmed by running a separate node.js file (console.log(process.env.GOOGLE_APPLICATION_CREDENTIALS);
) with sudo -E
(-E
preserves environment) that process.env.GOOGLE_APPLICATION_CREDENTIALS
is still set.
I'm not sure if I'm encountering the same issue as @ahume, but I figured it would be better to err on the side of safety and avoid prematurely opening a new issue.
I'm currently using a hack where I manually set process.env.GOOGLE_APPLICATION_CREDENTIALS
to the correct value (a path leading to my service-account.json
). This is non-optimal, because I would rather not have to remove this line every time I want to deploy a cloud function.
I have the same issue setting custom env vars. The only solution i was able to find is to stop the functions emulator
functions stop
set the new env var
export FOO=bar
then restart the emulator
functions start
At that point my locally executed cloud function is able to see the env var
Just for clarity i'm using
"dependencies": {
"@google-cloud/firestore": "^0.16.0"
}
even if version 0.17 is available but does produce an error with semver
Same issue. Need clear documentation
I've experienced the same issue. Rebooting clears it up.
I also noticed that emulator ignores --set-env-vars parameter of deploy command
Yes, unfortunately, emulator ignores --set-env-vars parameter of deploy command. Anyone can help in a workaround for this? I need to read some environment variables.
Our team experienced the same issue --set-env-file is not working.
Just a note: I found functions stop
wasn't actually stopping the emulator node process, keeping the environment variable exports from working.
Calling pkill node
, then exporting the variable, and restarting the emulator did work.
Environment details
Steps to reproduce
process.env.GCP_PROJECT
outside of main cloud function scopeI'm using
process.env.GCP_PROJECT
to load a specific environment file per project. This works when deploying the function to a project, but not to the emulator.I'm pretty sure it used to work, will attempt to get old versions and bisect.