4

I've seen related questions, but none offer the answer to my question. I ask because, whenever I invoke xdg-open from the command line, I get the following error instructing me to enable WSL Interoperability. I tried opening a PNG file and a PDF file. Both present me with the same message.

I'm on Ubuntu 22.04.

$ xdg-open IMG_20220629_131736841.jpg 
$ grep: /proc/sys/fs/binfmt_misc/WSLInterop: No such file or directory
WSL Interopability is disabled. Please enable it before using WSL.
grep: /proc/sys/fs/binfmt_misc/WSLInterop: No such file or directory
[error] WSL Interoperability is disabled. Please enable it before using WSL.
/usr/bin/wslview: line 216: /mnt/c/Windows/System32/reg.exe: No such file or directory
/usr/bin/wslview: line 308: [: -ge: unary operator expected
[error] This protocol is not supported before version 1903.
Rinzwind
  • 293,910
  • 41
  • 570
  • 710
TheGeeko61
  • 761
  • 1
  • 10
  • 27
  • 2
    ehm you can use `xdg-open` on WSL2? Not `xdg-open-wsl`? Do you have a desktop in WSL2? – Rinzwind Aug 10 '22 at 15:57
  • @Rinzwind Apparently, with the `wslu` package installed (which requires the PPA in 22.04), yes. It's not something I've experimented with much myself, but apparently installing the `wslu` package registers `wslview` as the handler for `xdg-open`. – NotTheDr01ds Aug 10 '22 at 16:51
  • Interop should be enabled by default, unless you specifically turn it off in a `/etc/wsl.conf`. However, Systemd enabled scripts can often interfere with Interop. Are you using anything to try to run Systemd under Ubuntu in WSL? – NotTheDr01ds Aug 10 '22 at 17:23
  • Rinzwind: My system is a laptop with only Ubuntu as OS. – TheGeeko61 Aug 12 '22 at 22:51
  • NotTheDro1ds: I haven't turned off anything directly... Now if installing packages causes such change, I don't know. The only reason I want to enable it is to be able to use xdg-open again. – TheGeeko61 Aug 12 '22 at 22:52
  • I don't even have any windoze software. – TheGeeko61 Aug 26 '22 at 14:11
  • @TheGeeko61 Ah, you forgot to put the `@` sign in front of my name when you replied, so I never got notified :-(. If so, I would have seen that you actually aren't running WSL itself. In which case, [this](https://askubuntu.com/q/1410764/1165986) is most likely the same problem. Some Ubuntu packages (at least `gimp-help-en`) erroneously have `wslu` as a dependency, even on non-WSL systems. Simply running `sudo apt purge wslu` should work. – NotTheDr01ds Sep 26 '22 at 14:29
  • 1
    Does this answer your question? [Ubuntu 22.04 (fresh install) desktop entries do not open](https://askubuntu.com/questions/1410764/ubuntu-22-04-fresh-install-desktop-entries-do-not-open) – NotTheDr01ds Sep 26 '22 at 14:29
  • After numerous anomalies with Ubuntu, I've switched to fedora, after more than a decade with Ubuntu, The straw? Using xdg-open -- operates without trouble on Fedora. – TheGeeko61 Sep 28 '22 at 18:02
  • @TheGeeko61 Ah, sad. Just an unfortunate bug with the (most likely) `gimp-help-en` package, not with Ubuntu itself. But I can understand needing to make the switch based on a bug you couldn't work around at the time. Just remember to put the `@` tag before names when replying here. If I'd seen it 6 weeks ago, I could have given you the (likely) solution then. – NotTheDr01ds Sep 28 '22 at 19:45
  • @NotTheDr01ds My decision to jump ship after many many moons is not because of this one gotcha. I've racked up more than 10 instances where Ubuntu didn't perform. One example is that I was having errors when I installed a particular package. I contacted the owners of the code and they informed me that Ubuntu, when packaging their app, included outdated libraries... A number of small gotchas led to a big headache and my inability to put trust in ubuntu packages. – TheGeeko61 Oct 01 '22 at 09:41

2 Answers2

6

Running the following command worked on Kubuntu 22.04 with a newly upgraded Plasma version 5.25.5:

sudo apt purge wslu
BeastOfCaerbannog
  • 12,964
  • 10
  • 49
  • 77
Paul Bruheim
  • 61
  • 1
  • 2
0

Delete the file /usr/share/applications/wslview.desktop.

I hit this too on a fresh Ubuntu 22.04.1 LTS release.

I deleted the file /usr/share/applications/wslview.desktop and xdg-open started to work as expected.

I don't know what exactly happens but it seems that the wslview.desktop launcher is meant for using Ubuntu in Windows WSL. But for some reason it's launched for every xdg-open invocation. When it's removed, xdg-open will use another launcher associated with the URL, the correct one.

OndroMih
  • 625
  • 4
  • 10
  • 1
    Probably better to properly get rid of it via `sudo apt purge wslu`. See [this question](https://askubuntu.com/q/1410764/1165986) for details. – NotTheDr01ds Sep 26 '22 at 14:31