In case you're interested, here's how to reproduce the error:
- Install a new shell to your user (ex. zsh)
- Set it to your default (for example by using chsh but the zsh install script already does so)
- Uninstall that shell
WSL Background
WSL is run by Windows as the wsl.exe executable file located on c:\windows\system32. That executable bootstraps the whole Linux subsystem on your machine using files located on your Windows disk. Knowing where the files used by your WSL instance are located is a good start to troubleshooting. On my machine, they're found on:Fixing the Issue
Because wsl.exe is an executable, we can run it on the console. In order to do so, open a windows terminal and:- cd into c:\windows\system32
- run wsl --help
However if WSL is broken any additional information will not be output on the console. So, it's important to have some context on the issue before we can fix it. On my particular case, since I knew my default shell (ZSH) was failing to load, to fix the issue I just had to change my user's shell to bash as the root user. That's as simple as:
- log in WSL as root
- As root, use chsh to change your user's shell
Logging in as Root from the Terminal in WSL
To login as root from the terminal, simply run the following command:Changing the User shell with chsh
Next we change the shell using chsh. chsh is a GNU utility created to chang the user shell. After logged in as root, one simply has to run the command:Testing
To test, you either have to close WSL (^D) and reopen it or as root, ron run su <user> on the current shell:Final Thoughts
Despite WSL not emitting much information on failures, it's important to remember that there's still a Linux system behind it. Knowing Linux or searching Linux related articles could help.It's also important to remember that, because all the filesystem is located on your C drive, you still have access to logs/config files and could try to fix from there if necessary.References
- Ubuntu - Changing Shells
- Windows command line reference available
- Linux apps are coming to Chromebooks
- Troubleshooting Windows Subsystem for Linux
See Also
- My journey to 1 million articles read
- Windows Subsystem for Linux, the best way to learn Linux on Windows
- 5 tools for Azure Development on Linux
- How to copy data between Azure databases
- How to create a Ubuntu Desktop instance on Azure
- How to build and run ASP.NET Core on Linux
- Creating ASP.NET Core websites with Docker
- Send emails from ASP.NET Core websites using SendGrid and Azure
- Why I use Fedora Linux
- How I fell in love with i3