You are not logged in.

#1 2021-10-20 21:18:40

hwallace
Member
Registered: 2021-08-30
Posts: 110

[SOLVED]Can't start user service - env vars "not defined" but they are

Getting this error even after system reboot

:> systemctl --user enable monitor-g
Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)

But these env vars seem to be defined :

:> echo $UID
1000

:> echo $DBUS_SESSION_BUS_ADDRESS 
unix:path=/run/user/1000/bus

:> echo $XDG_RUNTIME_DIR
/run/user/1000

Last edited by hwallace (2021-10-20 23:31:05)

Offline

#2 2021-10-20 21:40:52

loqs
Member
Registered: 2014-03-06
Posts: 18,998

Re: [SOLVED]Can't start user service - env vars "not defined" but they are

What is the output of:

file /run/user/1000/bus
loginctl session-status
systemctl status

Offline

#3 2021-10-20 21:46:17

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,498
Website

Re: [SOLVED]Can't start user service - env vars "not defined" but they are

You've shown us that those variables are set in the environment that is calling systemctl, but this says nothing about whether they are set in the systemd-user process which, if you haven't explicitly imported them, they likely aren't:

https://wiki.archlinux.org/title/System … _variables


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 2021-10-20 21:55:29

hwallace
Member
Registered: 2021-08-30
Posts: 110

Re: [SOLVED]Can't start user service - env vars "not defined" but they are

loqs wrote:

What is the output of:

file /run/user/1000/bus
loginctl session-status
systemctl status

file /run/user/1000/bus :

/run/user/1000/bus: socket

loginctl session status https://pastebin.com/6CxiN9Ec

systemctl status  https://pastebin.com/rCQBM3iC

Last edited by hwallace (2021-10-20 22:02:57)

Offline

#5 2021-10-20 21:59:41

loqs
Member
Registered: 2014-03-06
Posts: 18,998

Re: [SOLVED]Can't start user service - env vars "not defined" but they are

Did you use `su - ` before the failed `systemctl --user enable monitor-g`?

Offline

#6 2021-10-20 22:03:29

hwallace
Member
Registered: 2021-08-30
Posts: 110

Re: [SOLVED]Can't start user service - env vars "not defined" but they are

loqs wrote:

Did you use `su - ` before the failed `systemctl --user enable monitor-g`?

no

Offline

#7 2021-10-20 22:05:01

hwallace
Member
Registered: 2021-08-30
Posts: 110

Re: [SOLVED]Can't start user service - env vars "not defined" but they are

Woh!

After running your queries the enable and start are running fine.

Offline

#8 2021-10-20 22:10:35

loqs
Member
Registered: 2014-03-06
Posts: 18,998

Re: [SOLVED]Can't start user service - env vars "not defined" but they are

Oct 20 14:10:44 meer sudo[6340]:  stephen : TTY=pts/1 ; PWD=/home/stephen ; USER=root ; COMMAND=/usr/bin/systemctl --user enable monitor-gimp

Offline

#9 2021-10-20 22:49:08

hwallace
Member
Registered: 2021-08-30
Posts: 110

Re: [SOLVED]Can't start user service - env vars "not defined" but they are

loqs wrote:
Oct 20 14:10:44 meer sudo[6340]:  stephen : TTY=pts/1 ; PWD=/home/stephen ; USER=root ; COMMAND=/usr/bin/systemctl --user enable monitor-gimp

Please look at my first entry to this topic. There is no 'sudo' there yet there's the error. The prompt is not the root prompt. So...

But there it is. Weird. If it happens again I know where to look but even so... It's happened before and been fixed by rebooting. You have any idea?

Offline

#10 2021-10-20 23:26:57

loqs
Member
Registered: 2014-03-06
Posts: 18,998

Re: [SOLVED]Can't start user service - env vars "not defined" but they are

Check the permissions on /run/user/1000/bus if you had executed the command with root and that failed then you executed it again without root and it still failed.

Offline

#11 2021-10-20 23:30:41

hwallace
Member
Registered: 2021-08-30
Posts: 110

Re: [SOLVED]Can't start user service - env vars "not defined" but they are

loqs wrote:

Check the permissions on /run/user/1000/bus if you had executed the command with root and that failed then you executed it again without root and it still failed.

Ah yes.The permissions are okay now but  that would be it. I have an alias for systemctl to 'sudo systemctl' and then another for 'systemctl --user'. Not a wise strategy I see now. I mistakenly used the first alias on the first run.

I always thought it a bit reckless but didn't realise that errors could have such consequences.

So. Thank you.

Last edited by hwallace (2021-10-20 23:32:34)

Offline

Board footer

Powered by FluxBB