Reputation: 29
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)
EDIT : ( 19 Mar 2023)
Thanks for the replies everybody. For the remainder of time I worked with WSL and VSCode on that project, I stuck to copying and renaming that file ( I think I had to do it about once per month). Sadly, I no longer have access to that machine, and I cannot test any of the solutions you've given me to assert that they work in my case. There are way too many steps to reproduce the issue right now, and, frankly, I don't have the time to do it and test it myself.
If any of the solutions get positive feedback from other users, I will flag that solution as the accepted answer.
Upvotes: 2
Views: 3453
Reputation: 1
I fixed this problem just by running this code in terminal:
sudo chmod 777 /tmp/remote-wsl-loc.txt
Upvotes: 0
Reputation: 21
Reinstalling VSCode WSL extension and then renaming the .txt inside /tmp worked for me.
mv remote-wsl-loc.txt remote-wsl-loc.txt.old
This happened to me when I changed the default Ubuntu user I use in WSL. Hope it helps.
Upvotes: 2
Reputation: 1
Had the same issue. What worked was to upgrade wsl with:
sudo apt upgrade wsl
Then, I just restarted wsl on the Windows side:
wsl --shutdown
wsl
Upvotes: 0
Reputation: 63
Had the same issue, WSL 2 and remote-wsl0.56.4 too. I solved it by upgrading the remote-wsl extension version in visual studio
Upvotes: 1
Reputation: 2599
It 's a version incompatible issue.
Install another version remote-wsl(0.54.6) that could solve.
Or navigate to your C:\Users\{Your Username}\.vscode\extensions
folder, and find currently installed remote-wsl extension version, and corrected it in /tmp/remote-wsl-loc.txt
.
Upvotes: 0
Reputation: 81
it's happened with me becouse the remote-wsl updated but the folder in /mnt/c/Users/USER/.vscode/extensions/m
keep the old version. Try remove the old folder and install the remote-wsl again
Upvotes: 1