File node- not writing to file

I have Node Red on two systems- I am slowly moving my flows to the new Intel NUC from the Raspberry Pi.
One of the flows I want to move uses the file node to write to a log file. Works fine on the Raspberry Pi, but not on the NUC.

Here is the test flow (2 nodes, inject and file).


When I first run the flow, I get an error message:
Error: ENOENT: no such file or directory, open '/home/steve/Documents/Garden/mytest.txt'

Yet, on the NUC, I can cd /home/steve/Documents/Garden
The file is not there, so I try creating one with a touch command. But still, the file node won't write to it.

I also tried reading from a file in that folder by creating a file with one line of text. This generates a similar error:
Error: ENOENT: no such file or directory, open '/home/steve/Documents/Garden/mytest.txt'

So, any clues what's happening? is /home not /home on the NUC (running Ubuntu)?
Any tips would be appreciated.

What account does node-red run under? I'm guessing it runs as a service and probably doesn't have access to your personal files. Try putting files somewhere public with relaxed permissions.

Thanks, I am suspecting a permissions problem, so I set the folder and file permissions to 777. No difference.
It appears that root owns node-red.
But, can't root write to any folder regardless who owns it?

What do you mean by somewhere public?
Also, why is Node-Red giving a "file not found" error if it is a permissions problem?

Ownership is not the same as run time permissions. (i.e. root isn't running node-red (at least I hope not))

Accessible to all accounts.

Put a debug node on the output of the node, there may be an error message there.

I've set the folder ACL to nouser:nogroup and the permissions to 777. What else could I do to make it more public?

Thanks, but payload in == payload out. No other data but msg.payload

What happens if you don't specify a path (only file name). Check node-red folder. Also, add a catch node wired to a debug node set to show complete message.

You said you get the error when you first run the flow, do you mean that only happens the first time you hit the inject, but thereafter nothing happens?
My experiments suggest that if it is a permissions folder then you should get an error saying that.
I presume that you are running up to date node-red and nodejs.

I tried that- specifying only a filename. The file should be written to the root of Node-red, or to the user root, but who is the user when Node-Red is installed by Home Assistant in a container on the NUC running Ubuntu?

At any rate, I did, and a find search for the file:

sudo find / -name mytest.txt

Those files are inaccesible to me even as su.

Yes. The error shows only once. If I change anything but the filename and redeploy, I never get the error message again.

It is a recent install, less than a month. Node-Red version 6.2.0
node -v returns v8.10.0

Node-red is currently at version 1.0.6 or thereabouts

I guess you need to ask on HA forum about this.

On a straight node-red install, things are a bit more straight forward IMO.

You should have mentioned that you are running in a Docker container. If you want to write to the the host file system from a Docker container then you have to setup a Docker Volume to map the docker file out to the host (or there may be other ways, not sure). You can't just write to it, that is one of the main points of running in a container, it is constrained so it can't mess with your system.

Sorry- I am not well versed in docker, and this is the only container that I have ever used. I had no reason to believe that this could be the problem. I know that the docker IP address is different form the host IP address, but I had no clue that the file path was also hidden.

So, how do I make a docker volume and how do I map it to the real folder in Ubuntu?

Hi, @SteveMann. I was in the same boat a few days ago having never looked at Docker and finding that I have to use it for NR on my system. Though I find the page rather confusing (probably due to no Docker experience) I was able to do what you need to with the help from

A possible alternative may be not to use Docker.

Not sure this was directed to me but in my case I can't run native on Arch Linux because QT requires Libicu which in turn needs nodejs to be a later version than NR will run on... dll hell. Been there, tried that.

It was addressed to anyone who has problems with running in a container, I suppose. If you do have a good reason then that is what you have to do.

Not use docker? For two years people have been on my case for avoiding docker. I finally installed a project using docker, and the solution is to not use docker?

No wonder I'm confused.