How can I set environment variables that can be referenced from Node-RED?
I can add them to /etc/profile
or ~/.profile
and they show up as expected if I printenv
from the ssh command line, but I can’t seem to get them to work from Node-RED?
How can I set environment variables that can be referenced from Node-RED?
I can add them to /etc/profile
or ~/.profile
and they show up as expected if I printenv
from the ssh command line, but I can’t seem to get them to work from Node-RED?
The node-red daemon doesn’t load a profile so that is why the /etc/profile doesn’t work. You probably want to add your export to /etc/environment, you may need to create this file if it doesn’t exist and then restart the node-red daemon.
@philip That seemed to do the trick regarding access from Node-RED, but they don’t show up from the command line using a printenv
or echo $ENV_VAR
which seems odd?
I’m not sure why, I see that on mine as well.
Edit: There doesn’t seem to be a universal way to set environment variables that load for shells and for daemon/services that I can find. Anyone else know of a way?
Also the /etc/environment is not a script file, but a configuration file so entries should just be variable=value on each line without an export statement.
Also the /etc/environment is not a script file, but a configuration file so entries should just be variable=value on each line without an export statement.
Thanks for the info… I didn’t know this and I used export
initially and it worked that way too.
After reading your reply I went ahead and removed export
and it worked too… so I guess it works either way?
I found the same. Must be a very lenient parser.