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

**URL:** https://discourse.nodered.org/t/node-red-contrib-persist-on-dietpi-eacces-permission-denied-open-root-data-persistence-json/28911
**Category:** General
**Created:** [24 June 2020 19:09 UTC](https://discourse.nodered.org/t/node-red-contrib-persist-on-dietpi-eacces-permission-denied-open-root-data-persistence-json/28911 "2020-06-24T19:09:19Z")
**Posts on this page:** 13
**Page:** 3

<div class="post-metadata">

### Author: ![Joulinar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/joulinar/32/24713_2.png) [@Joulinar](https://discourse.nodered.org/u/Joulinar)
#### Post date: [26 June 2020 22:23 UTC](https://discourse.nodered.org/t/node-red-contrib-persist-on-dietpi-eacces-permission-denied-open-root-data-persistence-json/28911/41 "2020-06-26T22:23:29Z")

</div>

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.

```auto
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`

```auto
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`

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [26 June 2020 22:36 UTC](https://discourse.nodered.org/t/node-red-contrib-persist-on-dietpi-eacces-permission-denied-open-root-data-persistence-json/28911/42 "2020-06-26T22:36:32Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Joulinar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/joulinar/32/24713_2.png) [@Joulinar](https://discourse.nodered.org/u/Joulinar)
#### Post date: [26 June 2020 22:46 UTC](https://discourse.nodered.org/t/node-red-contrib-persist-on-dietpi-eacces-permission-denied-open-root-data-persistence-json/28911/43 "2020-06-26T22:46:41Z")

</div>

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 😃

 ![picture](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/7/47a4414ed736e72144cec7efe923ee0aa0e616d3.png)

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

```auto
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:

```

---

<div class="post-metadata">

### Author: ![MichaIng](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/michaing/32/24824_2.png) [@MichaIng](https://discourse.nodered.org/u/MichaIng)
#### Post date: [29 June 2020 00:02 UTC](https://discourse.nodered.org/t/node-red-contrib-persist-on-dietpi-eacces-permission-denied-open-root-data-persistence-json/28911/44 "2020-06-29T00:02:19Z")

</div>

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](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/](https://www.debian.org/Bugs/)

---

<div class="post-metadata">

### Author: ![MichaIng](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/michaing/32/24824_2.png) [@MichaIng](https://discourse.nodered.org/u/MichaIng)
#### Post date: [29 June 2020 00:03 UTC](https://discourse.nodered.org/t/node-red-contrib-persist-on-dietpi-eacces-permission-denied-open-root-data-persistence-json/28911/45 "2020-06-29T00:03:33Z")

</div>

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](https://nodered.org/docs/getting-started/local) which calls `sudo npm` and this is what the [RPi installer](https://github.com/node-red/linux-installers/blob/master/deb/update-nodejs-and-nodered) 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 🤔.
- 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.

---

<div class="post-metadata">

### Author: ![devifast](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@devifast](https://discourse.nodered.org/u/devifast)
#### Post date: [7 July 2020 11:54 UTC](https://discourse.nodered.org/t/node-red-contrib-persist-on-dietpi-eacces-permission-denied-open-root-data-persistence-json/28911/46 "2020-07-07T11:54:23Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/b/3b3e9b67f566ea1323d5849bfa5202c239bbeb0d.png)  
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"

---

<div class="post-metadata">

### Author: ![devifast](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@devifast](https://discourse.nodered.org/u/devifast)
#### Post date: [7 July 2020 12:06 UTC](https://discourse.nodered.org/t/node-red-contrib-persist-on-dietpi-eacces-permission-denied-open-root-data-persistence-json/28911/47 "2020-07-07T12:06:48Z")

</div>

> [@Joulinar](#):
>
> `ls -la /mnt/dietpi_userdata/node-red |grep persis`

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/a/baf7d787bfefe35dbf03f67be82f680e4e4d5711.png)  
It strikes me that I can see root root  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/f/1f6df82b3a4663d3f711a94d37851367b5af346a.png)

---

<div class="post-metadata">

### Author: ![Joulinar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/joulinar/32/24713_2.png) [@Joulinar](https://discourse.nodered.org/u/Joulinar)
#### Post date: [7 July 2020 12:53 UTC](https://discourse.nodered.org/t/node-red-contrib-persist-on-dietpi-eacces-permission-denied-open-root-data-persistence-json/28911/48 "2020-07-07T12:53:46Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![devifast](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@devifast](https://discourse.nodered.org/u/devifast)
#### Post date: [7 July 2020 13:14 UTC](https://discourse.nodered.org/t/node-red-contrib-persist-on-dietpi-eacces-permission-denied-open-root-data-persistence-json/28911/49 "2020-07-07T13:14:44Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/a/2af970526768204ea1a837dae8a49cd74195cb4a.png)  
Not work!  
Maybe I shouldn't create file as root?

---

<div class="post-metadata">

### Author: ![Joulinar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/joulinar/32/24713_2.png) [@Joulinar](https://discourse.nodered.org/u/Joulinar)
#### Post date: [7 July 2020 13:59 UTC](https://discourse.nodered.org/t/node-red-contrib-persist-on-dietpi-eacces-permission-denied-open-root-data-persistence-json/28911/50 "2020-07-07T13:59:44Z")

</div>

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

---

<div class="post-metadata">

### Author: ![devifast](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@devifast](https://discourse.nodered.org/u/devifast)
#### Post date: [7 July 2020 14:48 UTC](https://discourse.nodered.org/t/node-red-contrib-persist-on-dietpi-eacces-permission-denied-open-root-data-persistence-json/28911/51 "2020-07-07T14:48:59Z")

</div>

How to do it?

---

<div class="post-metadata">

### Author: ![devifast](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@devifast](https://discourse.nodered.org/u/devifast)
#### Post date: [7 July 2020 18:43 UTC](https://discourse.nodered.org/t/node-red-contrib-persist-on-dietpi-eacces-permission-denied-open-root-data-persistence-json/28911/52 "2020-07-07T18:43:34Z")

</div>

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](https://discourse.nodered.org/u/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](http://linuxcommand.org/lc3_lts0090.php)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [21 July 2020 18:43 UTC](https://discourse.nodered.org/t/node-red-contrib-persist-on-dietpi-eacces-permission-denied-open-root-data-persistence-json/28911/53 "2020-07-21T18:43:42Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/node-red-contrib-persist-on-dietpi-eacces-permission-denied-open-root-data-persistence-json/28911.md?page=2)
