terminal: Windows Terminal keeps forgetting/can't find my default WSL Ubuntu profile

Environment

Windows build number: Version 1909 (OS Build 18363.900)
Windows Terminal version (if applicable): 1.0.1811.0

Any other software?
Ubuntu 18.04 LTS for WSL

Steps to reproduce

  1. WSL and Ubuntu 18.04 are already installed and configured.
  2. Install Windows Terminal from the Microsoft Store.
  3. Upon first installation, it will automatically pick up the Ubuntu profile
  4. Set the Ubuntu profile as default in settings.json
  5. After e.g. restarting the pc, Windows Terminal can no longer find the default profile and does not list Ubuntu in the drop-down

Expected behavior

Ubuntu 18.04 for WSL to persist as the default profile that Windows Terminal uses when it launches.

Actual behavior

After e.g. restarting the pc, Windows Terminal can no longer find the default profile and does not list Ubuntu in the drop-down. The following error occurs when launching Windows Terminal: " Encountered errors while loading user settings Could not find your default profile in your list of profiles - using the first profile. Check to make sure the “defaultProfile” matches the GUID of one of your profiles. "

The defaultProfile guid matches that of the Ubuntu profile. JSON for Ubuntu profile:

           {
                "guid": "{some_guid}",
                "hidden": false,
                "name": "Ubuntu-18.04",
                "source": "Windows.Terminal.Wsl",
		"startingDirectory": "//wsl$/Ubuntu-18.04/home/my_username"
            }

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 41 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Happened to me (seemingly) after updating Docker for Windows.

Haven’t had any issues with WSL2 for months. I updated Docker for Windows from 2.4.0 to 2.5.0 as prompted by the tool recently. Had no issues with updating Docker for Windows in the past. This time too everything continued to work at first. But today the WSL option had disappeared from WT dropdown selection. wsl.exe was not responding at all. Docker for Windows too would get stuck in its Starting stage.

What fixed it for me:

  1. Run optionalfeatures.exe as admin
  2. Unselect Windows Subsystem for Linux (could have probably used a PS cmdlet, just had this dialog open)
  3. Restart
  4. Run Enable-WindowsOptionalFeature -Online -FeatureName $("VirtualMachinePlatform", "Microsoft-Windows-Subsystem-Linux") as admin
  5. Restart
  6. Everything back to normal

If you’d like to make startup fully deterministic and move back to manual control for WSL, here’s what you can do.

  1. Add "disabledProfileSources": [ "Windows.Terminal.Wsl" ] to the root node of your settings file
  2. Get rid of the source line from your WSL profile
  3. Add "commandline": "wsl -d Ubuntu-18.04"
  4. Add "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png" to get the Tux icon back

I encountered the same problem after installing the pre-release version along with the standard version that I have used for a long time. It seems that the pre-release one accidentally corrupted the setting file (but I didn’t notice anything weird when I was checking the setting.json).

Here is my solution:

  1. Exit the terminal.
  2. Delete the setting.json file
  3. Relaunch the terminal to let it generate a fresh new setting.json.

Then, I get my WSL profile back.

I wonder if it’s something to do with "source": "Windows.Terminal.Wsl", because when I comment this line out, it does seem to launch into Ubuntu. Although it’s not quite right, because it doesn’t set all the colour/font scheme settings I have, doesn’t have the Linux icon, and doesn’t like me passing in a starting directory.

Here’s the full settings.json:

// This file was initially generated by Windows Terminal 1.0.1811.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.

// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
    "$schema": "https://aka.ms/terminal-profiles-schema",

    "defaultProfile": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",

    // You can add more global application settings here.
    // To learn more about global settings, visit https://aka.ms/terminal-global-settings

    // If enabled, selections are automatically copied to your clipboard.
    "copyOnSelect": false,

    // If enabled, formatted data is also copied to your clipboard
    "copyFormatting": false,

    // A profile specifies a command to execute paired with information about how it should look and feel.
    // Each one of them will appear in the 'New Tab' dropdown,
    //   and can be invoked from the commandline with `wt.exe -p xxx`
    // To learn more about profiles, visit https://aka.ms/terminal-profile-settings
    "profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles.
        },
        "list":
        [
            {
                // Make changes here to the powershell.exe profile.
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
                "hidden": false
            },
            {
                // Make changes here to the cmd.exe profile.
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "Command Prompt",
                "commandline": "cmd.exe",
                "hidden": false
            },
            {
                "guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",
                "hidden": false,
                "name": "Ubuntu-18.04",
                "source": "Windows.Terminal.Wsl",
		"startingDirectory": "//wsl$/Ubuntu-18.04/home/<user>",
		"colorScheme": "Ubuntu",
		"fontFace": "DejaVuSansMono"
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            }
        ]
    },

    // Add custom color schemes to this array.
    // To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
    "schemes": [
		{
			"name": "Ubuntu",
			
			"background": "#300a24",
			"foreground": "#eeeeec",
			
			"black": "#2e3436",
			"red": "#cc0000",
			"green": "#4e9a06",
			"yellow": "#c4a000",
			"blue": "#3465a4",
			"purple": "#75507b",
			"cyan": "#06989a",
			"white": "#d3d7cf",
			"brightBlack": "#555753",
			"brightRed": "#ef2929",
			"brightGreen": "#8ae234",
			"brightYellow": "#fce94f",
			"brightBlue": "#729fcf",
			"brightPurple": "#ad7fa8",
			"brightCyan": "#34e2e2",
			"brightWhite": "#eeeeec"
			
		}
	],

    // Add custom keybindings to this array.
    // To unbind a key combination from your defaults.json, set the command to "unbound".
    // To learn more about keybindings, visit https://aka.ms/terminal-keybindings
    "keybindings":
    [
        // Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
        // These two lines additionally bind them to Ctrl+C and Ctrl+V.
        // To learn more about selection, visit https://aka.ms/terminal-selection
        { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
        { "command": "paste", "keys": "ctrl+v" },

        // Press Ctrl+Shift+F to open the search box
        { "command": "find", "keys": "ctrl+shift+f" },

        // Press Alt+Shift+D to open a new pane.
        // - "split": "auto" makes this pane open in the direction that provides the most surface area.
        // - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
        // To learn more about panes, visit https://aka.ms/terminal-panes
        { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }
    ]
}

By commenting out "source" and using "commandline" : "wsl -d Ubuntu-18.04" (from the docs here ) instead, it seems to work more or less the same way as it does on a fresh install that uses "source"

So what do you think is happening with "source": "Windows.Terminal.Wsl"?

  1. Restart
  2. Open the original ubuntu terminal. (The one that you downloaded from microsoft store
  3. Wait for the Welcome login to be finished (This message is shown once a day. To disable it please create the /home/<your_username>/.hushlogin file.)
  4. Close it, and go back to your windows terminal, it should work fine now.

I just had this problem today. Seems like Windows Terminal uses a sort of well-known GUID value for the WSL profile (it also does for PowerShell.Core). If you have custom profile using "source": "Windows.Terminal.Wsl" and the guid doesn’t match the expected value (for me it’s "{2c4de342-38b7-51cf-b940-2309a097f518}") then you get this error. In fact, if you don’t use this guid value in your custom profile, Terminal seems to add the “missing” profile automatically, and then you end up with two profiles using the same source but with different guid values.

For a little bit of backstory… Terminal queries which WSL distributions exist every time it’s launched, by running wsl -l. That might seem strange, but it’s based on the official guidance from the WSL team. Now, sometimes wsl fails to return anything in time. That used to cause Terminal to hang indefinitely on startup!

I reached out to the dev lead who owns some of the WSL usermode experience, and he suggested that two seconds is “long enough” to give WSL to respond. Pursuant to that, we added a timeout: if WSL doesn’t respond within 2 seconds, Terminal will move on as though WSL is wedged, stalled or stopped. Our launch issues went away overnight!

It seems like you’re one of the suffering few that have lingering WSL issues. I might have to bounce you over to the WSL repository for this one, if only because they’ll know best how to handle an issue like this. 😕

When it was in a broken state, I would say yes, at least compared to now (no errors because I’m using "commandLine" rather than "source".) When it was broken, it would take a little while to list Ubuntu, and then a bit longer to complete the command. Now it’s instantaneous.

Interesting. So, when you comment out source two things happen.

  • Terminal stops deleting the profile
  • Terminal launches cmd.exe (lol), not wsl

When a profile has a source and a guid, Terminal queries to make sure that the source (in this case, “wsl”) still thinks it exists. When Terminal asks, unfortunately, WSL reports that there aren’t any installed distributions.

Are you running WT at a different user than your desktop session?

If you relaunch terminal some time later, does the Ubuntu profile show back up?