Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profile is being auto updated with PowerShellCore #4532

Closed
wsmelton opened this issue Feb 11, 2020 · 8 comments
Closed

Profile is being auto updated with PowerShellCore #4532

wsmelton opened this issue Feb 11, 2020 · 8 comments
Labels
Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting

Comments

@wsmelton
Copy link

wsmelton commented Feb 11, 2020

Environment

Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.18362.0 Microsoft Windows NT 10.0.18362.0
Windows Terminal version (if applicable): Version: 0.8.10261.0

Steps to reproduce

  1. Using the new profile.json format, open it up in VS Code or I'm using Visual Studio 2019 CE
  2. Remove the block below from the list[] :
,
        {
            "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
            "hidden": false,
            "name": "PowerShell Core",
            "source": "Windows.Terminal.PowershellCore"
        }
  1. Save the file
  2. The removed block reappears at the end of the list[].

Expected behavior

The ability to add PowerShell 6 and PowerShell 7 to my Terminal.

Actual behavior

The block I remove for Windows.Terminal.PowerShellCore continues to be added back, and the entries I have for PowerShell 6 and 7 seem to be ignored.

I am trying to add the following to my profile in order to get PowerShell 6 and 7 in my terminal session:

"list": [
      {
        "guid": "{34fa1a1d-ed51-448e-a053-62d840dfceac}",
        "name": "PowerShell 7",
        "tabTitle": "PowerShell 7",
        "suppressApplicationTitle": "true",
        "source": "C:\\Program Files\\PowerShell\\7-preview\\pwsh.exe"
      },
      {
        "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
        "name": "PowerShell 6",
        "tabTitle": "PowerShell 6",
        "suppressApplicationTitle": "true",
        //        "source": "Windows.Terminal.PowershellCore"
        "source": "C:\\Program Files\\PowerShell\\6\\pwsh.exe"
      },
      {
        "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
        "name": "Windows PowerShell",
        "commandline": "powershell.exe"
      },
      {
        "guid": "{bd3ec972-9de6-4e4a-a353-62d035770223}",
        "name": "Anaconda PowerShell",
        "commandline": "powershell.exe -ExecutionPolicy ByPass -NoExit -Command \"& \"$env:LOCALAPPDATA\\Continuum\\anaconda3\\shell\\condabin\\conda-hook.ps1\" ; conda activate \"$env:LOCALAPPDATA\\Continuum\\anaconda3\" ",
        "startingDirectory": "%USERPROFILE%",
        "icon": "%LOCALAPPDATA%\\Continuum\\anaconda3\\Menu\\anaconda-navigator.ico"
      },
      {
        "guid": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
        "name": "Debian",
        "source": "Windows.Terminal.Wsl"
      },
      {
        "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
        "hidden": false,
        "name": "Azure Cloud Shell",
        "source": "Windows.Terminal.Azure"
      }
    ]
  },

However ever time I save the changes the contents are being changed to this (notice the last item:

"list": [
      {
        "guid": "{34fa1a1d-ed51-448e-a053-62d840dfceac}",
        "name": "PowerShell 7",
        "tabTitle": "PowerShell 7",
        "suppressApplicationTitle": "true",
        "source": "C:\\Program Files\\PowerShell\\7-preview\\pwsh.exe"
      },
      {
        "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
        "name": "PowerShell 6",
        "tabTitle": "PowerShell 6",
        "suppressApplicationTitle": "true",
        //        "source": "Windows.Terminal.PowershellCore"
        "source": "C:\\Program Files\\PowerShell\\6\\pwsh.exe"
      },
      {
        "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
        "name": "Windows PowerShell",
        "commandline": "powershell.exe"
      },
      {
        "guid": "{bd3ec972-9de6-4e4a-a353-62d035770223}",
        "name": "Anaconda PowerShell",
        "commandline": "powershell.exe -ExecutionPolicy ByPass -NoExit -Command \"& \"$env:LOCALAPPDATA\\Continuum\\anaconda3\\shell\\condabin\\conda-hook.ps1\" ; conda activate \"$env:LOCALAPPDATA\\Continuum\\anaconda3\" ",
        "startingDirectory": "%USERPROFILE%",
        "icon": "%LOCALAPPDATA%\\Continuum\\anaconda3\\Menu\\anaconda-navigator.ico"
      },
      {
        "guid": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
        "name": "Debian",
        "source": "Windows.Terminal.Wsl"
      },
      {
        "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
        "hidden": false,
        "name": "Azure Cloud Shell",
        "source": "Windows.Terminal.Azure"
      },
        {
            "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
            "hidden": false,
            "name": "PowerShell Core",
            "source": "Windows.Terminal.PowershellCore"
        }
    ]
  },

I may be doing something wrong, but I have not been able to determine what it is.

For those that want to see this in action:

profiles_json_terminal

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Feb 11, 2020
@WSLUser
Copy link
Contributor

WSLUser commented Feb 11, 2020

If they are installed and on your PATH then simply relaunching Terminal should pop them up as it detects new console apps and terminals during loading of Terminal itself.

@wsmelton
Copy link
Author

wsmelton commented Feb 11, 2020

@WSLUser you can't do that when pwsh is what starts both versions. pwsh ties itself to PowerShell 6.2 first, which is what WIndows.Terminal.PowerShellCore is apparently tied to.

I have no way of adding pwsh to have it call PowerShell 7.

@WSLUser
Copy link
Contributor

WSLUser commented Feb 11, 2020

Do both Powershell options appear for you from the drop down menu? I would rename one of the executables such as pwsh6.exe. I only have 7 installed and it works just fine. The problem is while Terminal can dynamically find different Powershells on the system, it is not able to determine which pwsh to execute, so it defaults to whatever appears on your PATH first.

@WSLUser
Copy link
Contributor

WSLUser commented Feb 11, 2020

Also adding

{
            "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
            "hidden": false,
            "name": "PowerShell Core",
            "source": "Windows.Terminal.PowershellCore"
        }

when both 6 and 7 are there in your profile is redundant.

@DHowett-MSFT
Copy link
Contributor

So, this is a bit of an artifact of how dynamic profiles work. #3231 (comment) has a bit more information.

In short, Terminal detects some known powershell locations (version < 0.9: only one powershell will be detected; version >= 0.9: all known powershell instances will be detected) and automatically generates profiles for them.

The dynamic profile system is, perhaps, a bit unintuitive. When a profile has a guid and a source, it's "managed" by the dynamic profile generator. The options that aren't in your profiles.json are generated at runtime; that's things like the icon, commandline, colorScheme, etc.

What's happening here is that you're changing the source of the dynamically-generated PS Core profile--whose source used to tell Terminal "I was created and owned by the PSCore generator"--to something different. Terminal then treats it like the apocryphal baby bird(*) and refuses to touch it... so it has to make a new one.

To suppress the dynamic one, set hidden to true or just override the options and keep guid and source the same. Or, wait for 0.9, the version after which Terminal will just find 7 and 6 and let them coexist peaceably.

*: it is a misunderstanding that birds do not accept their own young if a human has set a source value they do not understand.

@DHowett-MSFT DHowett-MSFT added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Feb 11, 2020
@wsmelton
Copy link
Author

I'm not sure I follow @DHowett . I set my profile to this and it still won't work, it actually errors because it can't find the default profile:


// 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": "{34fa1a1d-ed51-448e-a053-62d840dfceac}",

  "profiles": {
    "defaults": {
      "fontFace": "Cascadia Code Mono PL",
      "colorScheme": "AdventureTime",
      "fontSize": 14
    },
    "list": [
      {
        "guid": "{34fa1a1d-ed51-448e-a053-62d840dfceac}",
        "name": "PowerShell Core",
        "tabTitle": "PowerShell 7",
        "suppressApplicationTitle": "true",
        "source": "C:\\Program Files\\PowerShell\\7-preview\\pwsh.exe"
      },
      {
        "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
        "name": "PowerShell 6",
        "tabTitle": "PowerShell 6",
        "suppressApplicationTitle": "true",
        //        "source": "Windows.Terminal.PowershellCore"
        "source": "C:\\Program Files\\PowerShell\\6\\pwsh.exe"
      },
      {
        "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
        "name": "Windows PowerShell",
        "commandline": "powershell.exe"
      },
      {
        "guid": "{bd3ec972-9de6-4e4a-a353-62d035770223}",
        "name": "Anaconda PowerShell",
        "commandline": "powershell.exe -ExecutionPolicy ByPass -NoExit -Command \"& \"$env:LOCALAPPDATA\\Continuum\\anaconda3\\shell\\condabin\\conda-hook.ps1\" ; conda activate \"$env:LOCALAPPDATA\\Continuum\\anaconda3\" ",
        "startingDirectory": "%USERPROFILE%",
        "icon": "%LOCALAPPDATA%\\Continuum\\anaconda3\\Menu\\anaconda-navigator.ico"
      },
      {
        "guid": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
        "name": "Debian",
        "source": "Windows.Terminal.Wsl"
      },
      {
        "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
        "hidden": false,
        "name": "Azure Cloud Shell",
        "source": "Windows.Terminal.Azure"
      },
      {
        "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
        "hidden": true,
        "name": "PowerShell Core",
        "source": "Windows.Terminal.PowershellCore"
      }
    ]
  },

  // Add custom color schemes to this array
  "schemes": [
    {
      "background": "#1F1D45",
      "black": "#050404",
      "blue": "#0F4AC6",
      "brightBlack": "#4E7CBF",
      "brightBlue": "#1997C6",
      "brightCyan": "#C8FAF4",
      "brightGreen": "#9EFF6E",
      "brightPurple": "#9B5953",
      "brightRed": "#FC5F5A",
      "brightWhite": "#F6F5FB",
      "brightYellow": "#EFC11A",
      "cyan": "#70A598",
      "foreground": "#F8DCC0",
      "green": "#4AB118",
      "name": "AdventureTime",
      "purple": "#665993",
      "red": "#BD0013",
      "white": "#F8DCC0",
      "yellow": "#E7741E"
    }
  ],

  // Add any keybinding overrides to this array.
  // To unbind a default keybinding, set the command to "unbound"
  "keybindings": [
    {
      "command": "closeWindow",
      "keys": [
        "alt+f4"
      ]
    },
    {
      "command": "splitHorizontal",
      "keys": [
        "ctrl+\\"
      ]
    },
    {
      "command": "splitVertical",
      "keys": [
        "ctrl+shift+\\"
      ]
    },
    {
      "command": "closeTab",
      "keys": [
        "ctrl+w"
      ]
    }
  ]
}

@ghost ghost added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Feb 11, 2020
@DHowett-MSFT
Copy link
Contributor

In even shorter: do not change source, as it's not intended to be changed by users. The thing you're looking for is commandline 😄

Setting source tells Terminal that the profile in question was dynamically-generated, and Terminal can hide it if it doesn't think it's applicably any longer.

@wsmelton
Copy link
Author

Ah! Gotcha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting
Projects
None yet
Development

No branches or pull requests

3 participants