EACCESS for reading text file

Hi,
I installed node-red as snap on my Ubuntu Mate notebook and tried to read a file in my home-directory (/home/kzerbe) with the file-in node.
As documented I used an absolute file name: /home/kzerbe/mytext.txt.
After getting an EACCESS error, ich first did a chmod to 666 (rw-rw-rw) and then even 777 with no success.

Do I need an additional group membership or something else to be able to get access to files with node-red ?

Hi, can I ask why you used SNAP? There are lots of posts of issues for SNAP installs (though I am sure it works for many).

the preference on ubuntu systems is to use the install script as described in the documentation.

If you are sticking with SNAP, I cant help - but someone else might be able to (or search this forum for SNAP)

Thank you for your support !
I've chosen Snap since I've already using other NodeJS releases for projects and can switch them with NVM (nodes version manager- similar to Python virtual environments). Your preferred installation does not work well with nvm (it is possible, if you call 'nvm use' with the nodejs version number that the preferred installion installs, but you can't enable node-red as a service in that case).

So the snap installation is also some kind of "virtualization" / isolation and that can be the reason for making "outside" files inaccessible. So I dumped nvm and installed node-red with the preferred installation, got a little bit older nodejs, but it works now.

As I understand it, SNAPs are lightweight virtual environments. So as with Docker, you need to take into account access from the VM to the actual OS. Not used them though so I can't say more than that I'm afraid.

Was nodejs installed (outside of SNAP) before you ran the script?

what version of nodejs is reported if you enter node -v in a terminal?

I would probably apt remove nodejs and run the install script once more to get latest supported nodejs installed.

With nvm I used to switch between different nodejs versions. Now node-red installed version 12.20, which should match most of my other projects when I rebuild them.

NVM installs all nodejs environs below the local directory ~/.nvm/version/xxxxx and you can switch between them via "nvm use xxxx". Doing the preferred installation on a nvm- using system, you won't find any node- version anymore - until you enable one with "nvm use".

That just a hint for other developers needing multiple installations of nodejs. Of course you cannot have node-red as a service anymore - you must start node-red manually in your local environment.

Yeah, i understand nvm - i was querying it because you said "got a little bit older nodejs, but it works now" - so I asked "Was nodejs installed (outside of SNAP) before you ran the script?"

but no matter - you seem to have a handle on this & v12 is good for now. (If you were on 8 or 10 I would have said definitely update.)

PS, i do remember seeing some issues on the forum around the use of NVM (but I forget what now) - perhaps it is related to the service issue you mention.

The issue with nvm is that is its shell extension so yes it doesn't play nice with services. I think you can set nvm to use the underlying nodejs if you like... then run the script to get us installed - then change versions with nvm for any of your other apps. But yes all a bit fraught and best avoided.

And yes snaps are tightly sandboxed so can't see out of their environment unless blessed to run in "classic" mode - aka unsecure... so yes Node-RED in a snap is not a great thing.

2 Likes

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