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:
2 Likes

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/

1 Like

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.

2 Likes


Now another problem. I make file named persistence.json with folowing comand:
touch persistence.json
but this error is displayed
"/mnt/dietpi_userdata/node-red/persistence.json: Unexpected end of JSON input"


It strikes me that I can see root root

Basically the file would be created by Node-Red automatically as soon as data are flowing in. Anyway you can change the owner of the file to nodered user. This will ensure that Node-Red is able to read/write the file.

The error Unexpected end of JSON input is as expected, because you have an empty file without anything in. This should change as soon as data are stored inside the file.


Not work!
Maybe I shouldn't create file as root?

did you changed file permission to nodered:nodered for persistence.json

2 Likes

How to do it?

The solution turned out to be quite simple.
I used the chmod command as follows:
chmod 666 persistence.json in directory shown to me by Joulinar
Before i use the comand I saw that
-rw-r--r-- 1 root root 0 Jul 7 20:19 persistence.json
after execute comand i saw that
-rw-rw-rw- 1 root root 0 Jul 7 20:19 persistence.json.
Thanks to everyone who joined this discussion to help. Thank you very much.
I am a beginner in the field of Linux and it is quite difficult for me, but thanks to responsive people like you, things are gradually taking shape.
I'm sorry for my bad English.
Thanks.
link: http://linuxcommand.org/lc3_lts0090.php

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.