GoogleCloudPlatform / node-red-contrib-google-cloud

Node-RED nodes for Google Cloud Platform
Apache License 2.0
90 stars 57 forks source link

Nodes not working on Raspberry Pi #11

Closed kolban-google closed 5 years ago

kolban-google commented 5 years ago

When we install the latest Node-RED on a Raspberry Pi and attempt to use the nodes, we get an error:

Error: Unable to detect a Project Id in the current environment. 
To learn more about authentication and Google APIs, visit: 
https://cloud.google.com/docs/authentication/getting-started
kolban-google commented 5 years ago

It turns out that a Linux environment that wants to connect with GCP must have the environment variable GOOGLE_CLOUD_PROJECT set to the project Id in order to work. In our tests, we then tested with:

export GOOGLE_CLOUD_PROJECT=<MyProjectId>
node-red

and all worked. Now we need to validate that we can set it in /etc/environment and it will work.

kolban-google commented 5 years ago

The story did NOT work by editing /etc/environment and this is because Node-RED on PI is commonly started with:

node-red-start

This is governed by systemctl command which forces its own environment variables. If we use this technique, then we must edit /lib/systemd/system/nodered.service and add a line that reads:

Environment="GOOGLE_CLOUD_PROJECT=[YOUR_PROJECT]"

within the [Service] section.

kolban-google commented 5 years ago

Documentation updated and pushed to branch dev. Will close once published.