[SOLVED] $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined

Creating a bug report/issue

I have searched the existing open and closed issues

Required Information

  • DietPi version
G_DIETPI_VERSION_CORE=8
G_DIETPI_VERSION_SUB=25
G_DIETPI_VERSION_RC=1
G_GITBRANCH='master'
G_GITOWNER='MichaIng'
  • Distro version

bullseye

  • Kernel version

Linux OrangePi 5.10.43 #3.0.6 SMP Mon Aug 1 14:28:13 CST 2022 aarch64 GNU/Linux

  • Architecture

arm64

  • SBC model
    Generic Rockchip RK3399 (aarch64)
    (Orange Pi 4)

  • Power supply used
    5v 3A

  • SD card used
    Kingston 16 GB

Additional Information (if applicable)

  • Software title
    Jotta-cli (Jottacloud terminal control)

  • Was the software title installed freshly or updated/migrated?
    Freshly installed from apt sources provided by jottacloud (jottacloud.com)

  • Can this issue be replicated on a fresh installation of DietPi?
    Yes
    ← If you sent a “dietpi-bugreport”, please paste the ID here →

Steps to reproduce

  1. Install the software step by step as indicated in the web
  2. run the command run_jottad

Expected behaviour

  • The file /usr/lib/systemd/user/jottad.service must be read by systemctl and the daemon must start.

Actual behaviour

Starting via systemd...
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)
Failed to load systemd units. If systemd is not supported, please 'export JOTTAD_SYSTEMD=0' before running this command.
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)
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)

Extra details

Tried with users root and dietpi with the same behavior. It seems the variables are not declared:

export $(dbus-launch)
-bash: dbus-launch: orden no encontrada
declare -x HOME="/root"
declare -x LANG="es_ES.UTF-8"
declare -x LOGNAME="root"
declare -x MOTD_SHOWN="pam"
declare -x OLDPWD
declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
declare -x PWD="/root"
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"
declare -x SSH_CLIENT="192.168.0.55 33000 22"
declare -x SSH_CONNECTION="192.168.0.55 33000 192.168.0.54 22"
declare -x SSH_TTY="/dev/pts/0"
declare -x TERM="xterm-256color"
declare -x USER="root"

This is the run_jottad script:

cat /usr/bin/run_jottad 
#!/usr/bin/env bash

set -uo pipefail

systemd_stop_if_active() {
  service="$1";
  if command -v systemctl &> /dev/null && systemctl --user is-active -q "$service"; then
    systemctl --user stop "$service"
  fi
}

kill_all() {
  if [ "$JOTTAD_KILL" = "1" ]; then
    systemd_stop_if_active "jottad"
  fi
  killall jottad &> /dev/null && echo Shutting down jottad service...
}

start_systemd() {
  echo Starting via systemd...
  systemd_errmsg="Failed to load systemd units. If systemd is not supported, please 'export JOTTAD_SYSTEMD=0' before running this command."
  systemctl --user daemon-reload || echo "$systemd_errmsg"
  enabled=$(systemctl --user is-enabled jottad.service)
  if [ "$JOTTAD_AUTOSTART" = "1" ] && [ "$enabled" = "disabled" ]; then
    systemctl --user enable jottad.service
  elif [ "$JOTTAD_AUTOSTART" = "0" ] && [ "$enabled" = "enabled" ]; then
    systemctl --user disable jottad.service
  fi
  systemctl --user restart jottad.service
}

start_background() {
  echo Launching jottad service...
  jottad datadir $data_dir &
}

startup_all() {
  lockfile="$runtime_dir/jottad.pid"
  if command -v flock &> /dev/null && [ -e "$lockfile" ] ; then
    flock "$lockfile" true
  fi

  if [ "$JOTTAD_SYSTEMD" = "1" ]; then
    start_systemd
  else
    start_background
  fi

  echo 'run_jottad: Success!'
}

JOTTAD_AUTOSTART="${JOTTAD_AUTOSTART:-1}"
JOTTAD_KILL="${JOTTAD_KILL:-0}"
JOTTAD_SYSTEMD="${JOTTAD_SYSTEMD:-1}"
runtime_dir="${XDG_RUNTIME_DIR:-$HOME/.config}/jottad"
data_dir="${HOME}/.jottad"

kill_all
if [ "$JOTTAD_KILL" = "0" ]; then
  startup_all
fi

Any help will be greatly appreciated

Did you tried this already?

Hi Joulinar!

Thanks for your answer. If I tried this, the program gets stucked with the message
[2515] creating logger @ /root/.jottad/jottabackup.log
Maybe because the systemd is actually active in DietPi, isnt’t it?

Means “dbus-launch: Command not found”, right?
So dbus is not installed, which is maybe a requirement for jotta-cli?
which also would explain the $DBUS_SESSION_BUS_ADDRESS not defined

oh! :open_mouth:

Is this possible? dbus not installed in DietPi?.
Must I install it or it will be dangerous?

EDIT.
I installed dbus, and throw this:

dbus.service is a disabled or a static unit, not starting it.
dbus.socket is a disabled or a static unit, not starting it.

after a reboot, trying run_jottad still the same error.

systemctl enable dbus
systemctl start dbus

I’ve tried yet:

systemctl enable dbus
Synchronizing state of dbus.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable dbus
The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Alias= settings in the [Install] section, and DefaultInstance= for template
units). This means they are not meant to be enabled using systemctl.
 
Possible reasons for having this kind of units are:
• A unit may be statically enabled by being symlinked from another unit's
  .wants/ or .requires/ directory.
• A unit's purpose may be to act as a helper for some other unit which has
  a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
  D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some
  instance name specified.

Autoanswer.

export JOTTAD_SYSTEMD=0 did the trick. The program was not stucked, just the process is running.

Ctrl+C and try the jotta-cli utility and works fine.

Problem solved in the @Joulinar 's post.

Many thanks!!!

And did you tried to start dbus as well?

No, haven’t tried.

I think it has no sense just because it can’t be enabled.

It should have been working to start dbus