Node red snap: Location of flows.json file

When I start the node red snap, it says the flows file is located in /root/snap/node-red/599/flows.json but I couldn’t find it in that location.

Could anyone help me find this file?

i think this should be:

/root/snap/node-red/current/.node-red/

(though note that i run the node-red-rpi snap here which is a bit advanced over the upstream version, but i think the storage locations should still be identical)

I have the node-red-rpi snap installed as well but I don’t see .node-red directory in /root/snap/node-red/current.

These are what’s inside that folder.

drwxr-xr-x 2 root root    86 Jun 11 03:23 bin
-rw-r--r-- 1 root root 52385 Apr 12 05:52 CHANGELOG.md
drwxr-xr-x 3 root root    71 Jun 11 03:22 etc
drwxr-xr-x 3 root root    27 Jun 11 03:22 include
drwxr-xr-x 4 root root    99 Jun 11 03:22 lib
-rw-r--r-- 1 root root 68764 Apr 12 05:52 LICENSE
drwxr-xr-x 3 root root    43 Jun 11 03:23 meta
-rw-r--r-- 1 root root 26749 Apr 12 05:52 README.md
drwxr-xr-x 5 root root    54 Jun 11 03:22 share
drwxr-xr-x 3 root root    79 Jun 11 03:23 snap
drwxr-xr-x 6 root root    74 Jun 11 03:22 usr

One thing I noticed when I start the snap, the log says:

> Jul 17 10:30:48 raspberrypi node-red.node-red[26742]: 17 Jul 10:30:48 - [info] Flows file     : /root/snap/node-red/599/flows.json
> Jul 17 10:30:48 raspberrypi node-red.node-red[26742]: 17 Jul 10:30:48 - [warn]z
> Jul 17 10:30:48 raspberrypi node-red.node-red[26742]: ---------------------------------------------------------------------
> Jul 17 10:30:48 raspberrypi node-red.node-red[26742]: Your flow credentials file is encrypted using a system-generated key.
> Jul 17 10:30:48 raspberrypi node-red.node-red[26742]: If the system-generated key is lost for any reason, your credentials
> Jul 17 10:30:48 raspberrypi node-red.node-red[26742]: file will not be recoverable, you will have to delete it and re-enter
> Jul 17 10:30:48 raspberrypi node-red.node-red[26742]: your credentials.
> Jul 17 10:30:48 raspberrypi node-red.node-red[26742]: You should set your own key using the 'credentialSecret' option in
> Jul 17 10:30:48 raspberrypi node-red.node-red[26742]: your settings file. Node-RED will then re-encrypt your credentials
> Jul 17 10:30:48 raspberrypi node-red.node-red[26742]: file using your chosen key the next time you deploy a change.
> Jul 17 10:30:48 raspberrypi node-red.node-red[26742]: ---------------------------------------------------------------------
> Jul 17 10:30:48 raspberrypi node-red.node-red[26742]: 17 Jul 10:30:48 - [info] Starting flows
> Jul 17 10:30:48 raspberrypi node-red.node-red[26742]: 17 Jul 10:30:48 - [info] Started flows
> Jul 17 10:30:48 raspberrypi node-red.node-red[26742]: 17 Jul 10:30:48 - [info] Server now running at http://127.0.0.1:1880/

Does this mean the flows file is encrypted and stored somewhere else?

Thanks

this looks rather like /snap not /root/snap

note that the snap actually runs as the root user which is why its home directory is /root/snap/<snapname>/current

no, the flows file itself should be plain text, this is about the “key file” sitting next to it …

for the latest node-red-rpi in the edge channel which i’m currently running my flows are here:

ogra@localhost:~$ sudo ls -l /root/snap/node-red-rpi/current/.node-red/
total 392
-rw-r--r--   1 root root  23203 Jul 16 16:47 flows_localhost.json
-rw-r--r--   1 root root     44 Jul 13 14:03 flows_localhost_cred.json
...

You are 100% right. I was in the wrong directory. Thank you for pointing that out.

Now, let’s say if I wanted to build a snap and needed to include a custom flow that comes with the snap, how could I do that in the snapcraft.yaml file? Ideally, I’d release new versions of the snap with the flow already included in it.

Since the projects feature can’t be enabled in the snap version of node-red, I need to find a way to update flows remotely.

for now, you’d probably have to build your own node-red snap and ship the flow in it … then copy it into $SNAP_USER_DATA (which translates to the above dir) before the service starts …

i just managed to enable the palette editor with the latest node-red-rpi in edge (and also bumped it to 1.1.2) … once i have all bits and pieces regarding palettes in order i’ll take a look at the projects feature as well …

How would you do this? My understanding is that I’d copy the flows file into the build container (LXD) and then in the yaml file, I’d copy it to a certain directory which I’m not certain of at this point.

Is there any way I don’t have to do this? This defeats the purpose of remote updating.

Thanks for your help

the latest node-red-rpi in the edge channel (currently building) should have all bits and pieces included to use the projects feature … you still need to enable it in:

/root/snap/node-red-rpi/current/.node-red/settings.js

at the very end of the file … and indeed cofigure your git settings in the editor …