Hi everyone,
I am trying to use playerctl through the exec node, but the commands are returning an error:
Command failed: playerctl pause Could not connect to players: Cannot autolaunch D-Bus without X11 $DISPLAY
I suspect the exec node is running all commands with sudo as this error only appears in the terminal when I attempt to run it with sudo.
Is there a way to run commands on the exec node without sudo? e.g. just as my user profile?
Are you running node-red as sudo?
Are you running node-red under docker? or snap?
Try starting your command with DISPLAY=:0
1 Like
I tried 'DISPLAY=:0 playerctl pause' and got
Error spawning command line âdbus-launch --autolaunch=4a6306b2731d448daedf11f8f399f8de --binary-syntax --close-stderrâ: Child process exited with code 1
node-red likely to be running in sudo, but I'm not sure how to check
Colin
13 March 2021 20:54
6
I don't think that is the case, unless you installed node-red in an unusual way. What OS are you running on and how did you install node-red?
What folder is the flows file in? It tells you that when you start node-red.
Add debug to all three outputs of the exec node, set them to show Complete Message and see if you get any more information.
Been a while since i installed node red, but I'm pretty sure I just followed this tutorial -
https://nodered.org/docs/getting-started/raspberrypi
This is my OS:
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
It's possible I've misdiagnosed the issue...?
Colin
13 March 2021 21:09
8
So what is the folder and do you see anything helpful in the debug nodes that I suggested?
I think so.
Also can you show us how you have configured the exec node?
The flows are stored in - /home/pi/.node-red/flows_raspberrypi.json
The error messages that I have been posting so far come from the debug node, no further details given:
Command failed: playerctl pause Could not connect to players: Cannot autolaunch D-Bus without X11 $DISPLAY
Error spawning command line âdbus-launch --autolaunch=4a6306b2731d448daedf11f8f399f8de --binary-syntax --close-stderrâ: Child process exited with code 1
And the exec node is configured like this:
Colin
13 March 2021 21:51
10
As you are running node-red as the user pi
then it won't be running as root.
You haven't got the DISLAY=:0 setting. You need that. That is why it is saying that it cannot autolaunch without a configured display.
Has your Pi got a display fitted and is it the full raspbian that you installed and is the GUI enabled?
If you connect to the pi via an ssh shell and run the command does it work? You will need the DISPLAY set there too.
Have you got the debug nodes on all three outputs and are they configured to show Complete Message?
I could connect the RPI to a monitor but I have been using it headlessly for a awhile now.
The weird part is that the commands (without DISPLAY) work find in an SSH terminal, but the same commands don't work in exec.
But when I run the commands in SSH with sudo, I get the same output as what I see in node red. Which is why I thought that was the issue.
I'll look into getting the complete log
I've attached all three outputs to an output node, and it just produces
{"code":1,"message":"Command failed: DISPLAY=:0 playerctl -l\nError spawning command line âdbus-launch --autolaunch=4a6306b2731d448daedf11f8f399f8de --binary-syntax --close-stderrâ: Child process exited with code 1\n"}
when I do DISPLAY=:0 playerctl -l. I'm not sure what you mean by 'configured to show Complete Message'? Where is that setting?
DISPLAY=:0 playerctl -l does work in my ssh terminal though.
Colin
14 March 2021 07:31
13
In the drop-down in the debug node.
Here are the three outputs of the complete message, looks like it is the same thing?
{"_msgid":"6a838666.05aa58","topic":"","payload":"","rc":{"code":1,"message":"Command failed: DISPLAY=:0 playerctl -l\nError spawning command line âdbus-launch --autolaunch=4a6306b2731d448daedf11f8f399f8de --binary-syntax --close-stderrâ: Child process exited with code 1\n"}}
{"_msgid":"6a838666.05aa58","topic":"","payload":"Error spawning command line âdbus-launch --autolaunch=4a6306b2731d448daedf11f8f399f8de --binary-syntax --close-stderrâ: Child process exited with code 1\n","rc":{"code":1,"message":"Command failed: DISPLAY=:0 playerctl -l\nError spawning command line âdbus-launch --autolaunch=4a6306b2731d448daedf11f8f399f8de --binary-syntax --close-stderrâ: Child process exited with code 1\n"}}
{"_msgid":"6a838666.05aa58","topic":"","payload":"Error spawning command line âdbus-launch --autolaunch=4a6306b2731d448daedf11f8f399f8de --binary-syntax --close-stderrâ: Child process exited with code 1\n","rc":{"code":1,"message":"Command failed: DISPLAY=:0 playerctl -l\nError spawning command line âdbus-launch --autolaunch=4a6306b2731d448daedf11f8f399f8de --binary-syntax --close-stderrâ: Child process exited with code 1\n"}}
Colin
14 March 2021 08:45
15
OK, it was worth doing in case there was more information.
Try the exec node in Spawn mode instead of Complete mode.
Okay, so in Spawn mode.
playerctl -l:
{"_msgid":"dd257073.0682e","payload":"Cannot autolaunch D-Bus without X11 $DISPLAY\n","topic":""}
{"_msgid":"dd257073.0682e","payload":{"code":1},"topic":""}
DISPLAY=:0 playerctl -l
{"_msgid":"7f3fd4d8.02e0cc","payload":{"code":-2},"topic":""}
Colin
14 March 2021 09:16
17
You have lost the DISPLAY setting again. Note that is the same error that you got without that earlier, saying that it cannot even try to launch dbus. The error when you do specify the display is that it doesn't start properly, but is at least able to try, so it does get further.
I'm not sure if I follow... and I'm stumped as to what I can try next.
Can you please elaborate further?
Colin
14 March 2021 10:12
19
Sorry, I didn't read your reply properly, I see you have tried it with and without.
Well that is progress I think.
With the DISPLAY setting, which output is the message coming from?
Try putting the full path to the playerctl command. Run which playerctl
to find that.
The message is coming from the return code output.
Running DISPLAY:=0 /usr/bin/playerctl -l
returns the same thing