The Problem
When attempting to open the Bash shell in Ubuntu via Windows Subsystem for Linux (WSL) on Windows Terminal only the following message appears:
The Windows Subsystem for Linux instance has terminated.
[process exited with code …]
The Process
Part of the resolution process and sources are lost to me now, but I still want to document the solution that seems to resolve the issue.
A key seems to be running the terminal instance as administrator.
A StackExchange post about Opening up Windows Terminal with elevated privileges offered some insight on how to accomplish that with terminal commands.
The Solution
I edited my Windows Terminal settings.json to add two new profiles:
{
"guid": "{<<GUID1>>}",
"name": "Ubuntu",
"source": "Windows.Terminal.Wsl"
},
{
"guid": "{<<GUID2>>}",
"name": "Elevate Terminal",
"commandline": "powershell.exe Start-Process -Verb RunAs wt",
"icon": "🔑",
"hidden": false
},
Note: <<GUID1>>
and <<GUID2>>
are stand-in values for the actual guids.
I set Ubuntu as the default profile by editing defaultProfile:
"defaultProfile": "{<<GUID1>>}",
Now, when I select the “Elevate Terminal” profile, a new Windows Terminal instance is opened with administrator privileges to the Ubuntu profile. The profile then is able to access the WSL as expected.