現象
Visual Studio Codeで”wsl$”配下のフォルダを開くと、毎回以下のような警告が表示される。

[Window Title]
Visual Studio Code
[Main Instruction]
The host 'wsl.localhost' was not found in the list of allowed hosts. Do you want to open it anyway?
[Content]
The path '\\wsl.localhost\Ubuntu\tmp' uses a host that is not allowed. Unless you trust the host, you should press 'No'
[Yes] [No] [Learn More]
毎回、”Yes”を選択すれば通常通り、VSCodeを開けるのだが、毎回めんどくさいので、この警告が表示されないようにする方法を紹介する。
※ちなみに、version 1.78.1からUNC パス (先頭が\\で始まるパス)でこのような警告がでるようになったらしい
解決方法
1.VSCodeの設定を開く(ファイル→ユーザー設定→設定)

2.セキュリティの項目を開く

3.”項目の追加”ボタンを押下

4.”wsl$”と”wsl.localhost”と入力して”OK”を押下
(よくわからないが、警告のメッセージ内のパスが”wsl$”だったり、”wsl.localhost”だったりするので両方入れとく)

5.VSCodeの再起動を求められるので再起動する。

6.これで、”wsl$”と”wsl.localhost”配下のフォルダを開くときには警告は表示されなくなる。
コメント