Permission problems

I have installed node-red at a Ubuntu machine, logged as an user with sudo priviledges, and I have run the pi script, not using "sudo". This machine will be remotely accessed by students, which do not have sudo priviledges. When I run "node-red" in my sudo account, it works normally, but when I try to run it as a non-sudo user, I get the following message:

cannot open path of the current working directory: Permission denied

I am using node-red version 2.0.5 with Node.js 12.22.5.

How do I correct this so my students can use node-red when logged into their accounts?

Thanks in advance

Do you want everyone using the same instance of the node-red server or do you want them to have an instance each (with their own flow files and so on).

Every student may need to access different MQTT topics, so it is better if every student has his or her own instance.

If that is unfeasible, they could run same instance, but I would have to add a text input for the topics so the student can type his or her topic for the dashboard controls.

That is no problem. If you run
node-red -h
it will show you the options on the node-red command. In particular if a user runs
node-red -u ~ -p 1881
that will tell it to start node red in the users home folder (~) with the server listening on port 1881. The first time that is run it will create a folder .node-red in the users home folder and start with an empty flows file. Make sure each user uses a different port. After running it the first time you could edit the settings.js file it makes in that folder and force the port to 1881 (or whatever) so that the -p parameter would no longer be necessary.

Thanks for the reply. Actually I expect only one student to be logged at any given time, so I suppose that the port parameter is not necessary. Anyway I tried to run the command with the "-u ~" option, but the same error shows up. I created the ".node-red" directory manually, and same thing happens. Maybe something in configuration needs to be changed so node-red will use the user folder instead of a fixed, unaccessible one.

Well it works for me. Exactly how did you install node red?

Edit: Also what happens if you explicitly put in the path of the current logged in user, so something like
node-red -u /home/theusername
and what about
touch /home/theusername/tempfile
and
touch ~/tempfile

Further edit. If you run the node-red -u ~ command as a user with sudo privileges does it work? Check the startup message to make sure it has picked the files up from the right folder.

When you say you created the .node-red directory manually, which user did you do that as ? It must be as the user that will be running

node-red install was made by the Pi script, choosing "no" for Pi-specific nodes.

if I try "node-red -u /home/theusername", same error happens

"touch /home/theusername/tempfile" gives me "file or directory does not exist". However "touch ~/tempfile" does not give me any message.

When I run node-red as an user with sudo priviledges, I do not even need the "-u" option. It runs seamelessly. Startup messages concerning files say:

Settings file : /home/lquevedo/.node-red/settings.js
User directory : /home/lquevedo/.node-red
Flows file : /home/lquevedo/.node-red/flows.json

If I run as a non-sudo user, I do not get any message besides the error.

I created the directory manually as the non-admin user, which is the one that cannot run.

did you actually use theusername? that should be the nme of the user, like
node-red -u /home/pi

I meant you to put the actual user name in.

@dceejay do you know if anyone has tried running node red in this way as a non sudo user? I can't test it as I am away from home.

Yes I used the actual username, instead of "theusername".

That's ridiculous, they are the same directory (assuming you are in the users home directory when you run it, which I assume you were).

I thought the same, however that's what I got. I ran at the non-sudo user which is supposed to get access.
Maybe one better option would be to use one of the cloud implementations of node-red, but I would relly like it to work locally.

Sounds like the user which node-red runs as does not have a /home/username directory, in which case ~/tempfile resolves to /tempfile?

What does pwd show when logged in as that user? If it does not show /home/username then that is the problem.

Edit: Also what does this show

cd ~
pwd 

"pwd" gives me:
/net/nfs1.<facultydomain>/export/vol1/home/<department>/<username>

where <facultydomain> is the address domain of the faculty I work at inside the university; <department> is the department I work at, and <username> is the non-sudo username

after using cd ~, pwd returns the same.

The machine has virtual directories so I can have access to my files regardless the machine I log in. Maybe that is the problem.

Admin Edit: Added backticks round the lines with special characters to prevent the forum from interpreting them as markdown.

So exactly what command are you running to start node-red for that user?

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