Ubuntu xdg-open fails to launch browser

Hello,

I hope there is some issue with my setup rather than my java code as it works fine outside of the snap package.

Example:
$ cd source/
$ java -jar orangecalc-1.5.8.jar
Starts application no problem and from application launch browser (Support URL)
Launching: xdg-open http://www.wagemaker.co.uk (WORKS OK)
$ cd …
$ snap install --dangerous orangecalc_1.5.8_amd64.snap orangecalc 1.5.8 installed
$ orangecalc
Starts application no problem and from application launch browser (Support URL)
Launching: xdg-open http://www.wagemaker.co.uk (BROWSER DOES NOT LOAD)

In my java code I am launching it this way…

Runtime.getRuntime().exec("xdg-open "+ url);

Works fine outside of snap but does not work when run as a snap application

INSTALLATION DETAILS:
ii snapd-xdg-open 0.0.0~16.04 amd64
ii xdg-utils 1.1.1-1ubuntu1.16.04.1 all

Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial

Many Thanks in advance

this is likely https://bugs.launchpad.net/bugs/1705708
the fix is https://github.com/snapcore/snapd/pull/3613 and landed in master already …

I’ve check and done this but still no luck…
$ ls -al /usr/bin/xdg-open
-rwxr-xr-x 1 root root 22746 Oct 5 2016 /usr/bin/xdg-open
$ sudo ln -s /usr/bin/xdg-open /usr/local/bin/xdg-open
$ ls -al /usr/local/bin/xdg-open
lrwxrwxrwx 1 root root 17 Aug 3 12:00 /usr/local/bin/xdg-open -> /usr/bin/xdg-open
$ orangecalc
Starts application no problem and from application launch browser (Support URL)
Launching: xdg-open http://www.wagemaker.co.uk (BROWSER WONT OPEN)
$ ls /snap/core/current/usr/bin/xdg-open
/snap/core/current/usr/bin/xdg-open
$ file /snap/core/current/usr/bin/xdg-open
/snap/core/current/usr/bin/xdg-open: POSIX shell script, ASCII text executable
$ more /snap/core/current/usr/bin/xdg-open
#!/bin/sh
dbus-send --print-reply --session --dest=com.canonical.SafeLauncher / com.canonical.SafeLauncher.OpenURL string:"$1"

Noticed that the “/snap/core/current/usr/bin/xdg-open” only has 1 line in it’s code were as the “/usr/bin/xdg-open” is 938 lines long too much to list…

$ wc -l /usr/bin/xdg-open
938 /usr/bin/xdg-open

there isnt anythng you can do to hack around the issue… the path is wrong inside the snapd binary (or respectively inside the readonly core snap, depends from which side you look at it)

just wait til the fix lands (you could try using the core snap from the edge channel to get the binary from the master tree build by using “snap refresh --edge core” (to switch back again later use: “snap refresh --stable core”))

My friend you fixed the issue… :slight_smile:

The refresh command resolved the issue and the browser is now launched:

$ sudo snap refresh --edge core (WORKED)

Many Thanks

note that the core snap in the edge channel does not undergo any testing though … you should not use it permanently … (switch back to stable once the fix moved there)