skip to Main Content

Running Windows 11, WSL2, Ubuntu 20.04. Been developing with VSCode over a year. I regularly run apt update and apt upgrade without any problem. Today after running apt upgrade I can no longer open VSCode. I get the following error

node:internal/modules/cjs/loader:990
throw err;
^

Error: Cannot find module ‘wsl.localhostUbuntu-20.04mntcUsersJimDAppDataLocalProgramsMicrosoft VS CodeCode.exe’
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
at Module._load (node:internal/modules/cjs/loader:832:27)
at Function.c._load (node:electron/js2c/asar_bundle:5:13343)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
code: ‘MODULE_NOT_FOUND’,
requireStack: []

That is the correct path to the VSCode exe, but I am not sure about the wsl.localhostUbuntu-20.04 part

I rolled back my wsl to an month old backup and confirmed VSCode ran fine. Ran apt update and upgrade on that and get the same error.

Does anyone know how to fix this?

3

Answers


  1. Chosen as BEST ANSWER

    Starting from a functioning backup of the WSL image, I manually installed each packaged listed from apt list --upgradable. Turns out it is the upgrade from systemd-genie 2.3 to 2.4 that is causing the problem.

    If I upgrade every other package, VSCode still loads. When I upgrade systemd-genie to 2.4 and restart my laptop, VSCode will not load giving the error in the original post.


  2. edit /usr/lib/binfmt.d/WSLInterop.conf, change flag PF to F, reboot wsl seems able to let you run code again, but not sure whether any other side-effects exists.

    Login or Signup to reply.
  3. My final solution was to just not use systemd. With the release of Windows 11, a new feature has been added to WSL to runs scripts on WSL startup. This feature is now also available to Windows 10 users if you install WSL from the Microsoft Store (requires KB5020030, which should be available under Optional Updates).

    create the file /etc/wsl.conf and the following

    [boot]
    command = bash /etc/[path to startup script]
    

    in my case I used the path "/etc/wsl-services-start.sh" This shell script contains only

    service apache2 start
    service mysql start
    

    Starting apache2 and mysql was the only thing I needed systemd for, so this works fine for me.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search