Post withdrawn ... ... ...
Actually, if memory serves me correctly, the version with the leading dash is, in fact, the correct version. I believe it tells systemd to ignore a missing file. Since most people won't have that file in that location, Node-RED would otherwise fail to start. Also, you couldn't have a leading tilde there anyway since systemd reads that at system startup when there is no user, the tilde represents the current user's home folder. That is why the file path starts with a / - e.g. the root of the Linux filing system.
Well I only noticed it because variables defined in the file were not available in Node-red, so it's not working.
It is not clear to me what you mean by referring to the filesystem root.
I do understand absolute and relative paths, hopefully! ![]()
I don't think so because aren't those required by the systemd script? Node-RED itself certainly does not need them. Also, I doubt the max_old_space is helpful on 99% of installs now anyway. In my view it should not be used unless you actually have a memory issue. This dates from much older versions of node.js.
Has this changed from previous versions? Remember that this is the working directory for the systemd script. I'm not actually sure if it does anything useful here.
The problem is that Node-RED cannot know of that file's existence unless is manually checks for it. The file is used by systemd, not directly by node.js/node-red. Though obviously the resulting environment variables are then available in Node-RED.
So actually, logging its presence might be as confusing as it is helpful.
Also worth noting that, from node.js v20, it supports .env files natively. Previously, you needed the dotenv package but that isn't needed any more.
Do you definitely have the file /home/pi/.node-red/environment? And you reloaded the systemd definition and restarted it? (or rebooted).
When we talk about "absolute" paths, they, by definition, start from the filesystem root folder, / in Linux. Windows can have multiple root paths, typically things like C:/, etc. Whereas UNIX-like OS's have a unified file system.
As I recall, I burned a fresh OS, installed NR4, edited .node-red/environment and added variables, it worked (the systemd script has a tilde).
Then I burned a fresh OS, installed NR5, edited .node-red/environment and added variables, it didn't work (the systemd script has a hyphen).
But I might have made a mistake, I often do.
I do have a vague memory of talking about hyphens and tildes in the past, maybe here, maybe not.
Thanks for all the hints and corrections.
For fear of getting into an argument I'll let it rest.