I am struggling with permission problems when I want to create/access files in my home directory using the file and sqlite nodes.
My system is a laptop running ubuntu 22/mint 21.1 and node-red version 3.0.2.
I guess it has to do with the fact that I am running node-red using the ubuntu snap store. This was not my preference, but for development the easiest solution.
I got the following error message when accessing the file system for creation and accessing of files in my ~/.mqtt directory.
failed to create file: Error: EACCES: permission denied, mkdir '/home/leo/.mqtt'
Similar error message when using the sqlite node.
I changed the permissions for this .mqtt directory as follows:
drwxrwxrwx 2 leo leo 4096 Sep 7 11:20 .mqtt/
So this directory has rwx permissions for the world. But this didn't help.
Any hint to solve or investigate this problem is appreciated.
It doesn't seem particularly easy. Running the pi install script (which is good for Ubuntu) is simple.
I think the problem is that the snap install does not have access to the file system. There is likely some option you have to set when you install it. My advise is to ditch it and use the pi script.
Indeed, I believe snap is a virtualisation wrapper, each snap is encapsulated and has its own file system doesn't it?
Thanks for your replies.
I forgot to mention that I had configured the snap as follows.
Given these settings it should be possible to access a file in the home directory.
I am wondering if there are other people using the snap version of node-red and do not have the problems I have now.
I will consider the given alternative using the pi script for installation. Does that script also install the latest version of node.js? If not then some of my nodes will not run, like the aedes mqtt broker.
It will ensure you have the latest version of the major version you ask for (your current major version by default). So it is easy to change versions.
I checked the node-red pi install info and it confirmed that if node.js is not installed it will install LT 16, not the latest but I guess sufficient for me. Ubuntu default install is LT 12.22.9 only.
There are parameters to tell it to use different versions. v18 is good at this time.
Thanks for your help and advice. I am in business again.
Saved my flows in text files, deleted node-red from snap store and executed the node-red shell pi script.
For some reason the script could not install node-red core, but installed node.js v20.6.1.
Rerun the script and installed node-red core successfully.
Started the node-red service and imported the saved flow files.
Everything is working well, and I can now access files in my home directory.