2

Using WSL2 on Windows 10, the Linux shell does not recognize commands which are supposed to function. Also, Docker Desktop fails to launch, saying WSL integration stopped and exited with code 1. When I echo $PATH, as suspected, many previously available commands are not included.

enter image description here

But then I run wsl --shutdown in Powershell and start wsl anew. Now all the Windows-related commands are back (ones starting with /mnt/c), and Docker Engine is now able to start. Once it does, the docker and kubectl commands become recognized again also. Now there are way more path variables than before:

enter image description here

What could be the cause of this? I don't want to go through the rigmarole of shutting down and restarting WSL whenever I turn on my machine.

chocojunkie
  • 121
  • 2
  • have you installed tocker and kubectl in your WSL2 – Marcus Müller Nov 17 '21 at 18:54
  • WSL is not a `real installation` so you have not *as default* the same package list installed. This is the same for the environment variables, so you have to set them all for your needs. Do not forgot to make that in .profile or .bashrc etc.... else you loose your variables at end of session. In case of crash of the WSL session this is similar you loose the unsaved environment variables & then your tools might fail. If you want to use deep applications, & huge applications, use a virtual machine not WSL . This is most for good practices & to avoid this kind od use-cases failures. – francois P Nov 17 '21 at 18:55
  • @francoisP WSL2 *is* a VM, and it *is* a real installation! But you're right, only the things you install inside your WSL2 machine are in there. – Marcus Müller Nov 17 '21 at 18:58
  • It's weird because this didn't use to happen. It only started to happen today, while the previous 2 weeks everything was fine. – chocojunkie Nov 17 '21 at 19:05
  • @chocojunkie Is there any pattern that you can find leading up to this? Any particular command that you are issuing that might modify the `PATH` (e.g. `nvm`)? Any chance you are running a Systemd enablement script of any sort? – NotTheDr01ds Nov 17 '21 at 20:59
  • @chocojunkie Also, it's highly recommended that you include the *text* of any output when possible, rather than screenshots. As a real-world for-instance, I lost what I'd typed in my comment twice when clicking on the screenshots :-). Under WSL, it's *really* easy to capture many items to the clipboard. For instance, `echo $PATH | clip.exe`. – NotTheDr01ds Nov 17 '21 at 21:01
  • 1
    @NotTheDr01ds Now I think about it, I might have broken something when running the commands in the top answer [here](https://unix.stackexchange.com/questions/594470/wsl-2-does-not-have-lib-modules). The last command didn't work, so the whole thing was actually in vain. – chocojunkie Nov 18 '21 at 06:46
  • @chocojunkie Okay, I don't see anything in there of concern at first glance, but I'll look more closely in a bit. Just for clarity, when you say "last command", do you mean the `make` or setting the `.wslconfig` kernel option? – NotTheDr01ds Nov 18 '21 at 12:34
  • @chocojunkie But also, I'm more concerned about what leads up to the failure *each time*. You say a `wsl --shutdown` makes it work. What makes it stop working again? That's not quite clear from your question. Does the problem seem to reappear "randomly" at some point? *That* is where I'm thinking there *might* (hopefully) be some pattern. – NotTheDr01ds Nov 18 '21 at 12:36
  • @NotTheDr01ds Yes I mean the `make` command. The problem only presents itself on startup. From there, I do the shutdown and everything works fine till the next time I start my laptop. – chocojunkie Nov 19 '21 at 13:25

0 Answers0