如何在 Ubuntu 22.04 上启用 WSL 互操作性?

The*_*o61 6 command-line windows-subsystem-for-linux

我看过相关的问题,但没有一个能回答我的问题。我问这个问题是因为,每当我从命令行调用 xdg-open 时,都会收到以下错误,指示我启用 WSL 互操作性。我尝试打开 PNG 文件和 PDF 文件。两者都向我传达了相同的信息。

我使用的是 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.
Run Code Online (Sandbox Code Playgroud)

小智 7

在具有新升级的 Plasma 版本 5.25.5 的 Kubuntu 22.04 上运行以下命令有效:

sudo apt purge wslu
Run Code Online (Sandbox Code Playgroud)


Ond*_*Mih 0

删除文件/usr/share/applications/wslview.desktop

我在新的 Ubuntu 22.04.1 LTS 版本上也遇到了这个问题。

我删除了该文件/usr/share/applications/wslview.desktopxdg-open开始按预期工作。

我不知道到底发生了什么,但wslview.desktop启动器似乎是为了在 Windows WSL 中使用 Ubuntu 而设计的。但由于某种原因,它会在每次xdg-open调用时启动。删除后,xdg-open将使用与 URL 关联的另一个启动器(正确的启动器)。