"dbus-launch": executable file not found in $PATH

I’ve developed a tool to report issues to Launchpad. It’s written in Python and uses launchpadlib to handle the Launchpad side of things.

Once the program connects to Launchpad, it’s supposed to launch a Web browser window to authenticate the user. However, I see this instead:

The authorization page:
 (https://***)
should be opening in your browser. Use your browser to authorize
this program to access Launchpad on your behalf.
Waiting to hear from Launchpad about your decision...
user-open error: exec: "dbus-launch": executable file not found in $PATH

Indeed:

$ snap run --shell qabro
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

$ dbus-launch
dbus-launch: command not found

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

$ ls -l /usr/bin/dbus*
-rwxr-xr-x 1 root root  10224 Jan 13  2017 /usr/bin/dbus-cleanup-sockets
-rwxr-xr-x 1 root root 224208 Jan 13  2017 /usr/bin/dbus-daemon
-rwxr-xr-x 1 root root  22520 Jan 13  2017 /usr/bin/dbus-monitor
-rwxr-xr-x 1 root root  10224 Jan 13  2017 /usr/bin/dbus-run-session
-rwxr-xr-x 1 root root  22512 Jan 13  2017 /usr/bin/dbus-send
-rwxr-xr-x 1 root root  14320 Jan 13  2017 /usr/bin/dbus-update-activation-environment
-rwxr-xr-x 1 root root  10224 Jan 13  2017 /usr/bin/dbus-uuidgen

I’ve tried to add dbus-x11 as a stage-package for the main part:

...
parts:
  qabro:
    plugin: python
    python-version: python2
    source: .
    build-packages:
      - libffi-dev
      - libssl-dev
    python-packages:
      - launchpadlib
      - urwid
    stage-packages:
      - libc6
      - dbus-x11
...

but it still doesn’t appear anywhere in my final snap.

(side question: I wanted to check what was done, but it looks like I cannot run snapcraft cleanbuild stage or snapcraft cleanbuild prime in order to see the status at the different stages… is there a way to do so while still running things in a LXD container?)

How can I make sure dbus-launch is part of my snap?

Thanks!

OK I solved my problem. Adding dbus-x11 in the stage-packages was indeed the right way to go. For some reason in my initial testing it was not working, but rebuilding the snap worked.

1 Like

Actually, using dbus to launch the browser (in snaps) is probably not going to work in general and it only worked because the first thing that was attempted was to talk to xdg-open. The only way that snaps can do that is via snapctl (or with the xdg-open executable that is inside the core snap).

My suggestion would be to look at what launchpadlib does to open the browser (probably using the web browser module) and perhaps monkey-patch it to always use xdg-open or snapctl user-open