Xdg-open does nothing on first invocation

After booting my Ubuntu 18.04 system, the first time any of my Snap applications tries to invoke xdg-open, nothing happens. On re-starting the application, xdg-open works fine.
This applies to the use of xdg-open both within a Java program and within a shell script and both to opening a file and to opening a website.
I would be grateful for any comments on this and any advice as to whether a workaround is possible.

Thanks for reporting this. I can reproduce this problem on Arch too.

[maciek@sloop maciek]$ xdg-open http://google.com
user-open error: Object does not implement the interface
[maciek@sloop maciek]$ xdg-open http://google.com
# this time firefox opened the web page as expected
[maciek@sloop maciek]$ 

I’ll try to find out what’s happening and propose a fix.

1 Like

A bug indeed, I’ve opened a PR with the fix: https://github.com/snapcore/snapd/pull/7476 It should end up in 2.42.

2 Likes

The code in Userd.Init in usersession/userd/userd.go looks like it has some ordering problems. It registers the well known name on the bus and then hooks up the service to the object path. This means there is a short period of time when userd owns the name on the bus but does not know how to serve the method calls.

It should be performing the Export calls before registering the bus name.

2 Likes