Closed2

WSL2でtauriを動かすときにやったこと

yubachiriyubachiri

環境はこれ

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
yubachiriyubachiri

セットアップはほぼ公式通りでOKだった。
https://tauri.studio/en/docs/get-started/setup-linux/

動かなかったのは手順4。DIPSLAYのIPアドレスと、X serverを起動するときのパラメータが、記載されている通りではだめだった。

DISPLAY環境変数について

ドキュメントでは export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0 としているが、これで取得できるのはWSL側のIPアドレス。自分の環境ではこれでは動作しなかったので、こちらを参照。
https://qiita.com/souyakuchan/items/a484e1dd23639eb63bdb

ipconfig.exe より、ホスト側のIPアドレスを取得することで動作するようになった。

X server起動時のパラメータについて

自分の環境で利用したのはVcXsrv。ドキュメントには -ac を渡すよう記載があったが、 -nowgl を渡したら動作するようになった。
参考: https://veresk.hatenablog.com/entry/2020/02/26/190000

ちなみに -ac のみを渡したときに発生していたエラーはこちら

libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast

(WebKitWebProcess:3461): Gdk-ERROR **: 11:32:40.225: The program 'WebKitWebProcess' received an X Window System error.
This probably reflects a bug in the program.
The error was 'GLXBadFBConfig'.
  (Details: serial 179 error_code 163 request_code 149 (GLX) minor_code 21)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the GDK_SYNCHRONIZE environment
   variable to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)

-nowgl について
https://gist.github.com/ctaggart/68ead4d0d942b240061086f4ba587f5f

このスクラップは2022/02/03にクローズされました