Node-red-contrib-persist on DietPi : EACCES: permission denied, open '/root/data/persistence.json'

Hi guys,

many thanks for trying to work around this for the last 2 days. Let me try to help with DietPi, even if my knowledge on Node-Red is limited. Indeed the normal Node-Red installer is not working on DietPi. Therefore DietPi own software catalogue to be used.

root@DietPi3: bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

Diet-Pi detected - only going to add the  node-red-start, -stop, -log  commands.
Flow files and other things worth backing up can be found in the /mnt/dietpi_userdata/node-red directory.

Use the  dietpi-software  command to un-install and re-install Node-RED.
root@DietPi3:

All Node-Red data is stored in the following location: /mnt/dietpi_userdata/node-red

Node-red is executed as user nodered

root@DietPi3: ps -ef|grep nod
nodered    713     1  2 00:14 ?        00:00:05 node-red

Therefore it's logic to have permission issues on /root/data/persistence.json for Node-Red application.

I guess, persistence.json should be stored at /mnt/dietpi_userdata/node-red

1 Like

Excellent - that explains it.
@devifast - over to you.... does that node let you point the persistence to the nodered users directory as suggested ?

I was playing with it and it should be possible to specify storage location (e.g. full path). But I need to say, I really have no idea about Node-Red :smiley:

EDIT:
Yap working this way. Note-Red is writing down the file.

root@DietPi3: ls -la /mnt/dietpi_userdata/node-red |grep persis
-rw-r--r-- 1 nodered nodered    75 Jun 27 01:05 persistence.json
root@DietPi3:
1 Like

Hey guys, just got my attention on this.

@devifast
Little advice in general: When you face issues with software that was not installed via installers/methods of the developers/creators themselves, it is good to report the issue to the distribution maintainers first, in this case DietPi: https://github.com/MichaIng/DietPi
This allows us to check whether it is an issue with our implementation or with Node-RED in general and we can then forward it if required. If it is really an issue with Node-RED this would allow us implement a workaround until an upstream fix exists.
Similarly when you install a package via apt-get install and face an issue with issue with it, best is to report first to the Debian maintainers (okay on RPi its Raspbian, but they share 99,5% of implementations): https://www.debian.org/Bugs/

Okay but let me understand the underlying issue:

  • We install Node-RED via npm called as root.
  • The result should match exactly (besides moved data dir and systemd service) the official generic install method which calls sudo npm and this is what the RPi installer does as well.
  • Since after npm install on DietPi the node-red binary is first any only touched by the nodered user with /mnt/dietpi_userdata/node-red, why does the persist node choose /root/data as default storage while on Raspbian with installer it chooses /home/pi/data by default? I cannot find any part of the installer the assigns a different default dir somewhere :thinking:.
  • But generally, if Node-RED does not use the executing users home or current working dir for data/configs, is there a way to set the default data dir via script for all nodes?

Now I see we do not set the WorkingDirectory via systemd unit, probably this would help. Will do some tests as well.

1 Like