sytemctl --user start results in “Failed to connect to bus: no such file or directory”

Asked by David Wen Riccardi-Zhu

I'm on an Ubuntu server (16.04, via SSH), trying to set up a service to check mail, and following these instructions: https://bostonenginerd.com/posts/notmuch-of-a-mail-setup-part-1-mbsync-msmtp-and-systemd/.

When I enter:

systemctl --user start checkmail.timer
I get:

Failed to connect to bus: No such file or directory
I'm lost as to why. I followed the exact same instructions on a desktop 16.04 and had no issues.

Question information

Language:
English Edit question
Status:
Expired
For:
Ubuntu systemd Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
David Wen Riccardi-Zhu (dwrz) said :
#1
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#2

Assuming you followes the guide to the letter, did you try:

systemctl --user start /home/$USER/scripts/checkmail.sh

You don't need to change the command, it uses BASH variables. Very handy

Revision history for this message
David Wen Riccardi-Zhu (dwrz) said :
#3

Thanks -- but I'm getting the same result: "Failed to connect to bus: No
such file or directory".

On 2016-12-16 08:49, actionparsnip wrote:

> Your question #406793 on systemd in Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+source/systemd/+question/406793
>
> Status: Open => Answered
>
> actionparsnip proposed the following answer:
> Assuming you followes the guide to the letter, did you try:
>
> systemctl --user start /home/$USER/scripts/checkmail.sh
>
> You don't need to change the command, it uses BASH variables. Very handy

Revision history for this message
Launchpad Janitor (janitor) said :
#4

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
David Wen Riccardi-Zhu (dwrz) said :
#5

I've still not been able to resolve this issue.

Revision history for this message
Launchpad Janitor (janitor) said :
#6

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
David Wen Riccardi-Zhu (dwrz) said :
#7

I've still not been able to resolve this issue.

Revision history for this message
Manfred Hampl (m-hampl) said :
#8

What is the output of the command

ps -p1 | grep systemd && echo systemd || echo upstart

(just to conform whether you are running system and not upstart)

Revision history for this message
David Wen Riccardi-Zhu (dwrz) said :
#9

Thanks, Manfred. Ran it and can confirm systemd.

Revision history for this message
Manfred Hampl (m-hampl) said :
#10

Try

XDG_RUNTIME_DIR=/run/user/`id -u` systemctl --user start checkmail.timer

(from https://answers.launchpad.net/ubuntu/+source/systemd/+question/287454 )

Revision history for this message
David Wen Riccardi-Zhu (dwrz) said :
#11

I get:

Failed to connect to bus: No such file or directory

I think the prior issue is incorrectly marked as solved. One of the comments mentions that they are also having the same issue. : \

Revision history for this message
Manfred Hampl (m-hampl) said :
#12

from http://stackoverflow.com/questions/34167257/can-i-control-a-user-systemd-using-systemctl-user-after-sudo-su-myuser

export XDG_RUNTIME_DIR="/run/user/$UID"
export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"

What is the output on your system for the commands

echo $XDG_RUNTIME_DIR
echo $DBUS_SESSION_BUS_ADDRESS
ls -l /run/user/$UID
ls -l /run/user/$UID/bus

Revision history for this message
David Wen Riccardi-Zhu (dwrz) said :
#13

Thanks again for all your help, Manfred.

Output:

user@user-machine:~$ echo $XDG_RUNTIME_DIR

user@user-machine:~$ echo $DBUS_SESSION_BUS_ADDRESS

user@user-machine:~$ ls -l /run/user/$UID
ls: cannot access '/run/user/1000': No such file or directory

user@user-machine:~$ ls -l /run/user/$UID/bus
ls: cannot access '/run/user/1000/bus': No such file or directory

user@user-machine:~$ export XDG_RUNTIME_DIR="/run/user/$UID"
user@user-machine:~$ export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"

user@user-machine:~$ echo $XDG_RUNTIME_DIR
/run/user/1000

user@user-machine:~$ echo $DBUS_SESSION_BUS_ADDRESS
unix:path=/run/user/1000/bus

user@user-machine:~$ ls -l /run/user/$UID
ls: cannot access '/run/user/1000': No such file or directory

user@user-machine:~$ ls -l /run/user/$UID/bus
ls: cannot access '/run/user/1000/bus': No such file or directory

user@user-machine:~$ XDG_RUNTIME_DIR=/run/user/`id -u` systemctl --user start checkmail.timer
Failed to connect to bus: No such file or directory

Revision history for this message
David Wen Riccardi-Zhu (dwrz) said :
#14

Just to clarify -- the original echo outputs ($XDG_RUNTIME_DIR, $DBUS_SESSION_BUS_ADDRESS) were blank. After export, they were /run/user/1000 and /run/user/1000/bus.

Revision history for this message
Manfred Hampl (m-hampl) said :
#15

are you sure that DBUS is correctly configured and running on your system?

Revision history for this message
David Wen Riccardi-Zhu (dwrz) said :
#16

I'm not sure, sorry. Everything should be stock, though. I haven't tried to configure systemd. The only thing this sever has running is syncthing and these minor email clients (isync, msmtp, notmuch).

Revision history for this message
Launchpad Janitor (janitor) said :
#17

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
David Wen Riccardi-Zhu (dwrz) said :
#18

Issue is still not resolved.

Revision history for this message
Launchpad Janitor (janitor) said :
#19

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
David Wen Riccardi-Zhu (dwrz) said :
#20

Issue is still not resolved. Especially as this is on a server, I really would like to be able find some way to run scripts on it.

Revision history for this message
Manfred Hampl (m-hampl) said :
#21

Have you tried contacting the author of the document that you try to follow?

Revision history for this message
David Wen Riccardi-Zhu (dwrz) said :
#22

Hi Manfred, I have not, because I have the issue with all systemd services I have tried to create.

I don't know much about systemd, but if I had to guess there seems to be something wrong with the default dbus setup.

Revision history for this message
Launchpad Janitor (janitor) said :
#23

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
David Wen Riccardi-Zhu (dwrz) said :
#24

Still getting:

Failed to connect to bus: No such file or directory

System is up to date.

: (

Revision history for this message
Manfred Hampl (m-hampl) said :
#25

How did you install this server? Did you install Ubuntu 16.04, or did you start with an older Ubuntu release and upgrade to 16.04?

Do you see the possibility to do a new installation?

Revision history for this message
David Wen Riccardi-Zhu (dwrz) said :
#26

I installed 16.04, sever edition -- no upgrade.

I'm not going to be able to do a fresh install any time soon, unfortunately.

It looks like others still have this issue: https://answers.launchpad.net/ubuntu/+source/systemd/+question/287454.

I can confirm the same output:

If I run "execute dbus-monitor", I get:
Failed to open connection to session bus: Using X11 for dbus-daemon autolaunch was disabled at compile time, set your DBUS_SESSION_BUS_ADDRESS instead

Is there a way to set the address?

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#27

Sure, its an environment variable. What is the output of:

env | grep DBUS

Thanks

Revision history for this message
David Wen Riccardi-Zhu (dwrz) said :
#28

There's no output. : \

Revision history for this message
Manfred Hampl (m-hampl) said :
#29

What is the output of

ps ax | grep -i dbus

Revision history for this message
David Wen Riccardi-Zhu (dwrz) said :
#30

 1111 ? Ss 0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
 9881 pts/1 S+ 0:00 grep --color=auto -i dbus

Revision history for this message
Launchpad Janitor (janitor) said :
#31

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
David Wen Riccardi-Zhu (dwrz) said :
#32

Still facing this issue, unfortunately. System is up to date.

Revision history for this message
Launchpad Janitor (janitor) said :
#33

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
David Wen Riccardi-Zhu (dwrz) said :
#34

Still have this issue.

Not sure if it's helpful, but I get the following with dbus-monitor.

Failed to open connection to session bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

Is this the correct behavior for a server setup?

Revision history for this message
Launchpad Janitor (janitor) said :
#35

This question was expired because it remained in the 'Open' state without activity for the last 15 days.