'How to open a file in vscode under wsl using the vscode:// url?

I would like to open a file in vscode under WSL (Windows Subsystem Linux) using the vscode:// url.

You can do it with a normal file in the usual filesystem vscode://file/c:/myProject/package.json
It is clearly explained in the documentation

I would like to open a file which is located in WSL, so to have something like this vscode://file/home/user/myProject/package.json
But It does not work !

It does not work to use the complete path in windows as it does not start the WSL vscode vscode://file/C:\Users\john\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gqsdeaz4\LocalState\rootfs/home/user/myProject/package.json



Solution 1:[1]

You can use the following scheme vscode://file//wsl$/Ubuntu-18.04
In your case it will be vscode://file//wsl$/Ubuntu-18.04/home/user/myProject/package.json
But unfortunately file is opened in a new window.
Please see https://github.com/microsoft/vscode/issues/99691

Solution 2:[2]

To open a remote window, don't use file but vscode-remote.

Please try vscode://vscode-remote/wsl+distro+name/path/to/file

Source: Opening VS Code with URLs doesn't work with \wsl$ urls

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Potasov
Solution 2 equiman