I have WSL2 (with Ubuntu 20.04 LTS) and I am using VS Code with the "Remote - WSL" extension. VS Code is installed on Windows 10 and I have an alias in my .bashrc that I use to open VS Code from Ubuntu.
I sometimes get the following messages when I try running VS Code
$ code .
/mnt/c/Users/USER/AppData/Local/Programs/Microsoft VS Code/bin/code: 46: cannot create /tmp/remote-wsl-loc.txt: Permission denied
/mnt/c/Users/USER/AppData/Local/Programs/Microsoft VS Code/bin/code: 52: /mnt/c/Users/USER/.vscode/extensions/ms-vscode-remote.remote-wsl-0.54.6/scripts/wslCode.sh: not found
In my experience, the first message I get after running "code ." isn't a problem. However, looking at the directory specified in the second message, I find that there's no such folder called "ms-vscode-remote.remote-wsl-0.54.6".
My "Remote - WSL" is currently on version 0.56.4. Consequently, there is a folder under my extensions called "ms-vscode-remote.remote-wsl-0.56.4". It seems like VS Code cannot find this folder and run the shell script from there. As such, I just copy the "remote-wsl-0.56.4" and rename it to "remote-wsl-0.54.6". VS Code is going to find the shell script for the next few days until the folder I created gets deleted again.
I am unsure what deletes the folder. It's probably worth mentioning I am not the administrator of the machine I am using.
I was going to try to make the "remote-wsl-0.54.6" file undeletable, but it feels like i'm piling hacks upon hacks and I'm not solving the actual problem. This issue has been bugging me for the past month and i've tried looking it up on various forums (including SO), but I didn't find something that seemed relevant.
Any permanent solutions to this sort of issue? (happy to provide more details if needed)