Open jared-thoughtbot opened 2 years ago
This seems to have fixed itself 🤷♂️ I have no idea what changed so can't provide further context but going to close this now.
This issue has re-appeared again, seemingly after another restart. Happy to help debug this in any way I can.
I just migrated to Windows 11 and see the exact same issue.
I migrated my entire WSL from my older laptop using it's export/import feature and installed a fresh copy of Visual Studio Code along with WSL extension and now can't get this very important feature, for me, working. See screenshot below
In my case, this was related to this WSL issue, and the suggestion to wsl --shutdown
from the windows command prompt fixed my issue at least temporarily. (After starting wsl
again, code
works as expected again.) However, it does seems to break again sometimes, and I don't see a consistent pattern with what causes it to break.
This is also consistently happening to me as well. On Windows 11, new computer, not and upgrade. It isn't just code .
that doesn't work. Similar commands like explorer.exe .
give the same error.
wsl --shutdown works for a little bit but it always breaks again.
suffering from this since windows 11 update. no idea what to do
suffering from this since windows 11 update. no idea what to do
my solution was to uninstall/reinstall vscode. hopefully it lasts
I have the same issue as reported here. For me wsl --shutdown
resolved the problem. (Windows 11 version 10.0.22621
)
I am using VS Code:
1.81.1
6c3e3dba23e8fadc360aed75ce363ba185c49794
x64
WSL distro:
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
Imho, this is not due to a Windows 11 upgrade but a WSL update: it happens to me frequently on Win 10, too.
And "frequently" really means that it works at first for a few minutes/hours/... and then out of a sudden stops to work.
Annoying!
Btw, in my impression everything™ under /mnt/c/
is not working from there onwards (had my AZ CLI installed in Windows instead of WSL, failing too)
im not using windows 11 but had to reinstall it again Ubuntu 20.04, and when type code .
gives me
/mnt/c/Users/leand/AppData/Local/Programs/Microsoft VS Code/Code.exe: Invalid argument
I've tried the wsl --shutdown
command but it continues the same, and even trying to reload WSL extension, so the only way i can is opening VSCode and acessing host from there
this issue still persist till today, need a follow up, anyone?
Strange thing is, it works when i navigate to the program folder and then execute the program. But when i execute the program from another folder with absolute program path, it doesn't. By the way it is not only with vscode but every windows program which is mounted in WSL
I'm also experiencing the same problem, wsl --shutdown
has yet to resolve the issue
Using W11 updated as of last week. For me the issue was WSL had to have administrator privileges. Without it, the same error occurred, with it the command code
works. My guess is that something during VSCode installation made it administrator only, which impedes wsl to access it without such privileges.
This worked for me as of this writing:
wsl --shutdown
>wsl --version
WSL version: 2.0.9.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
The issue was resolved for me when turned off "Run As Admin"
I also had this problem, I had success with running wsl --shutdown
+ start WSL as administrator
🤔
Same problem
i forgot to mention that the palliative measure that i found was to remove vscode-server and shutdown wsl:
rm -r ~/.vscode-server
then on cmd or powershell:
wsl --shutdown
and then boot again with code .
command to reinstall vscode
The issue was resolved for me when turned off "Run As Admin"
It does work well, thx!!!
Just running the wsl terminal (Ubuntu) as administrator fixed the issue for me. you can temporarily right click on the app and run as administrator or for permanent solution go to the WSL folder on this path: C:\Program Files\WSL and make the wsl.exe file to always run as administrator from the compatibility tab check the image below
WSL version: 2.1.5.0 Distro: Ubuntu-22.04 Kernel version: 5.15.146.1-2 OS: Windows_NT x64 10.0.19045
The issue was resolved for me when turned off "Run As Admin"
It works for me, thanks!
O problema foi resolvido para mim quando desativei "Executar como administrador"
Thank you, works here
Fixed the problem with opening ubuntu in administrator hope it works for you too but I downloaded ubuntu through wsl than restarted it than administrator part just in case.
Any other solution beisdes running vscode as an admin? in most corp, the admin option is not a solution.
The root cause of this issue lies in the permission management and process isolation mechanisms between Windows and WSL. When you run code.exe
as an administrator, processes running as a regular user in WSL cannot interact with the elevated process. This leads to the code
command in WSL failing to start Visual Studio Code correctly.
Permission Isolation: In Windows, there is permission isolation between processes running as an administrator and those running as a regular user. Regular user processes cannot directly interact with administrator processes. This is a security measure to prevent unauthorized operations by regular user processes.
WSL and Windows Process Interaction: Processes in WSL typically run with regular user permissions. When you run the code .
command in WSL, it attempts to start a new code.exe
process. If code.exe
is already running as an administrator, the regular user process in WSL cannot interact with this elevated process, leading to the error.
To avoid this issue, you can choose from the following solutions:
Do Not Run VS Code as Administrator: Ensure that code.exe
is not running as an administrator. This way, regular user processes in WSL can start and interact with code.exe
normally.
Run WSL as Administrator: If you need to run VS Code as an administrator, you can try running WSL as an administrator. This can be done with the following steps:
wsl
code .
command in WSL.Use VS Code Remote - WSL Extension: This extension allows you to seamlessly use VS Code within WSL without worrying about permission issues. Ensure you have installed VS Code and the Remote - WSL extension, then run the following command in WSL:
code .
This will start VS Code and connect to the WSL environment.
By following these methods, you should be able to avoid permission issues and use the code
command in WSL without any problems.
关闭“以管理员身份运行”后,此问题已为我解决
The issue was resolved for me when turned off "Run As Admin"
This works in mine.As the saying goes :“Every cause has its effect.”A few days ago I ticked exactly this Run-As-Admin-option in order to install an extension for VSCode. If this solution holds true for you as well, in order to permanently solve similar possible problems, I would suggest that you assign permissions to the root directory where VSCode is located (e.g., 'D:\Program Files') to your usual users instead of just administrators (of course, you need to make sure that you know what you're doing).
Steps to Reproduce:
code .
to launch VSCodeWhat you expected to see:
VSCode opens in remote mode
What you saw instead:
Notes
Remote - WSL
extension fixes the issue temporarily. But when I restart my computer the problem returns. All the evidence I've found online suggests this fix and I was hopeful but for some reason it doesn't persist after a reboot.I appreciate there's not a lot of info here. Please let me know what I can do to help troubleshoot this further.