wslgでGUIを出そうとしたときに"Error: Can't open display: :0"と言われたときの対処法


備忘録的な

問題

Error: Can't open display: :0

ってエラーが出た。

直し方

sudo rm -r /tmp/.X11-unix
ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix

これ実行する。

ただ、再起動するとリセットされる。

もっといい方法があった。
下のやつを/etc/tmpfiles.d/wslg.confに追加すればいい。
そうすれば再起動しても問題ない。
https://github.com/microsoft/wslg/issues/43#issuecomment-826039096

#  This file is part of the debianisation of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.

# See tmpfiles.d(5) for details

# Type Path           Mode UID  GID  Age Argument
L+     /tmp/.X11-unix -    -    -    -   /mnt/wslg/.X11-unix