The problem

When I launched VS Code by running the code command inside WSL2, the folder did not open in WSL Remote mode. Instead, VS Code opened it using a Windows UNC path such as \\wsl.localhost\Ubuntu-24.04\home\user.
As a result, I had to select “Reopen Folder in WSL” in VS Code every time.
The cause

When the code command inside WSL resolves to /mnt/c/Program Files/Microsoft VS Code/bin/code, it first asks the VS Code CLI for the location of the WSL extension. If the extension is found, the folder is opened in WSL Remote mode. If it is not found, VS Code falls back to opening the folder with the Windows Code.exe.
In my case, the problem was that the VS Code CLI could not locate the installed WSL extension.
The WSL extension itself was installed on the Windows side under C:\Users\<username>\.vscode\extensions, but the VS Code CLI apparently only checks the extensions associated with the default profile1.
This means that even if the WSL extension is installed in another VS Code profile, the code command launched from WSL may not be able to find it unless the extension is also installed in the default profile.
The fix

The solution is simple: install the WSL extension in the default VS Code profile.
More specifically, it appears to only read
C:\Users\<username>\.vscode\extensions\extensions.json. ↩︎
