Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code.exe: Invalid argument after upgrading to Windows 11 #7050

Open
jared-thoughtbot opened this issue Aug 11, 2022 · 23 comments
Open

Code.exe: Invalid argument after upgrading to Windows 11 #7050

jared-thoughtbot opened this issue Aug 11, 2022 · 23 comments
Labels
wsl Issue in vscode-remote WSL

Comments

@jared-thoughtbot
Copy link

  • VSCode Version: 1.70.1
  • Local OS Version: Windows 11 21H2 22000.856
  • Remote OS Version: Ubuntu 20.04.4 LTS (WSL2)
  • Remote Extension/Connection Type: WSL

Steps to Reproduce:

  1. Ignore Windows 11 upgrade prompts for ages
  2. Upgrade to Windows 11
  3. Open terminal in WSL2 linux distro
  4. Navigate to a repo
  5. Type code . to launch VSCode

What you expected to see:

VSCode opens in remote mode

What you saw instead:

$ code .
/mnt/c/Users/jared/AppData/Local/Programs/Microsoft VS Code/Code.exe: Invalid argument

Notes

  • Opening VSCode directly and connecting to remote works fine
  • Opening VSCode in Windows (non-remote), uninstalling and re-installing the 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.

@github-actions github-actions bot added the wsl Issue in vscode-remote WSL label Aug 11, 2022
@jared-thoughtbot
Copy link
Author

This seems to have fixed itself 🤷‍♂️ I have no idea what changed so can't provide further context but going to close this now.

@jared-thoughtbot
Copy link
Author

This issue has re-appeared again, seemingly after another restart. Happy to help debug this in any way I can.

@kp1dell
Copy link

kp1dell commented Mar 10, 2023

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

image

@teichert
Copy link

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.

@revoyrm
Copy link

revoyrm commented Jul 13, 2023

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.

@apkatsikas
Copy link

suffering from this since windows 11 update. no idea what to do

@apkatsikas
Copy link

suffering from this since windows 11 update. no idea what to do

my solution was to uninstall/reinstall vscode. hopefully it lasts

@yooakim
Copy link

yooakim commented Aug 15, 2023

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

@GraueEminenz79
Copy link

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)

@leandroauzier
Copy link

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

@abdullzz
Copy link

abdullzz commented Dec 1, 2023

this issue still persist till today, need a follow up, anyone?

@zumsix
Copy link

zumsix commented Jan 2, 2024

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

@lulzhipsters
Copy link

I'm also experiencing the same problem, wsl --shutdown has yet to resolve the issue

@kokakin
Copy link

kokakin commented Jan 16, 2024

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.

@hmenorjr
Copy link

hmenorjr commented Jan 22, 2024

This worked for me as of this writing:

  1. Reinstall VSCode (latest version)
  2. Ran wsl --shutdown
>wsl --version
WSL version: 2.0.9.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59

@chazwilder
Copy link

The issue was resolved for me when turned off "Run As Admin"

image

image

@divinity76
Copy link

I also had this problem, I had success with running wsl --shutdown + start WSL as administrator 🤔

@tutunak
Copy link

tutunak commented Mar 20, 2024

Same problem

@leandroauzier
Copy link

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

@sherlockyzd
Copy link

The issue was resolved for me when turned off "Run As Admin"

image

image

It does work well, thx!!!

@AhmadYousif89
Copy link

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

Specifications:

WSL version: 2.1.5.0
Distro: Ubuntu-22.04
Kernel version: 5.15.146.1-2
OS: Windows_NT x64 10.0.19045

@MatchalatteR
Copy link

The issue was resolved for me when turned off "Run As Admin"

image

image

It works for me, thanks!

@andersonlobo98
Copy link

O problema foi resolvido para mim quando desativei "Executar como administrador"

imagem

imagem

Thank you, works here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wsl Issue in vscode-remote WSL
Projects
None yet
Development

No branches or pull requests