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

Integrate with tool version managers like Aqua and mise #5123

Open
2 tasks done
o-l-a-v opened this issue Jan 10, 2025 · 2 comments
Open
2 tasks done

Integrate with tool version managers like Aqua and mise #5123

o-l-a-v opened this issue Jan 10, 2025 · 2 comments
Labels
Issue-Enhancement A feature request (enhancement). Needs: Triage Maintainer attention needed!

Comments

@o-l-a-v
Copy link
Contributor

o-l-a-v commented Jan 10, 2025

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.

Summary

There are now multiple multiplatform tools that can manage PowerShell versions as any other dev tool, like:

It'd be cool of vscode-powershell somehow could integrate with external tools for easily setting what PowerShell version to run for a session. It doesn't have to be tool specific, but maybe instead of hardcoding a path to pwsh.exe one could do trigger a command:

  • mise use pwsh@<version_supplied_by_vscode_powershell>; mise where pwsh@<version_supplied_by_vscode_powershell>

Which then tells what path to pwsh.exe vscode-powershell should use.

Proposed Design

No response

@o-l-a-v o-l-a-v added Issue-Enhancement A feature request (enhancement). Needs: Triage Maintainer attention needed! labels Jan 10, 2025
@andyleejordan
Copy link
Member

andyleejordan commented Jan 10, 2025

I think this is two asks both of which are feasible:

  1. Teach VS Code to search for PowerShell installations in the directories that mise, Aqua, etc. install them. An example would be

    private findPSCoreDaily(): IPossiblePowerShellExe | undefined {
    and the most annoying part frankly would be adding the appropriate test coverage. I'm happy to accept a PR for this as long as it comes with citation of documentation as to why it's now looking where. When done correctly, it should make those installed versions available in the PowerShell session menu, and should name them accurately. No defaults should change. This would essentially allow the user to skip manually adding these installations to powershell.powerShellAdditionalExePaths. They could access these PowerShells just by running "Show Session Menu" (or clicking the PowerShell langauage status icon) and could set it as a default by its name.

  2. Teach mise, Aqua, etc. to edit the current workspace's powershell.powerShellDefaultVersion setting to the name of the desired PowerShell as it shows in the additional PowerShells after (1) is completed when running e.g. mise use. This is out of scope of this project and would be something to work on with those developers.

Note that I'm saying this with no familiarity with these exact tools, and am assuming they operate somewhat like the Python and Ruby environment managers.

@o-l-a-v
Copy link
Contributor Author

o-l-a-v commented Jan 24, 2025

I've found a way to do this now using a combination of mise and Scoop.

Scoop can create shims, which will create a .exe that can be pointed to by vscode-powershell.

mise alias for pwsh

mise uses powershell-core as name for PowerShell. I prefer pwsh. So I added following to the mise config.toml:

[alias]
pwsh = 'aqua:PowerShell/PowerShell'

After that you can do mise use --global [email protected], instead of mise use --global [email protected].

Scoop shims for specific pwsh version

My two shims for v7.4 and v7.5:

PS > scoop shim add pwsh75 mise "exec [email protected] -- pwsh"

PS > scoop shim add pwsh74 mise "exec [email protected] -- pwsh"

PS > (Get-Command -Name 'pwsh*').Path

C:\Users\olav.birkeland\scoop\persist\mise\mise\installs\pwsh\7.5.0\pwsh.exe
C:\Users\olav.birkeland\SCOOP\apps\mise\current\mise\installs\pwsh\7.5.0\pwsh.exe
C:\Users\olav.birkeland\scoop\shims\pwsh74.exe
C:\Users\olav.birkeland\scoop\shims\pwsh75.exe

PS >

Windows Terminal

Can use commands and thus mise directly like so in settings.json:

[
  {
    "commandline": "mise exec [email protected] -- pwsh -NoLogo",
    "guid": "{f1781ba6-28e5-4be2-85cf-56a9937de9de}",
    "hidden": false,
    "icon": "ms-appx:///ProfileIcons/pwsh.png",
    "name": "PowerShell 7.5 (mise)",
    "startingDirectory": "%USERPROFILE%"
  },
  {
    "commandline": "mise exec [email protected] -- pwsh -NoLogo",
    "guid": "{f12194ee-663f-4a48-9d6e-166b464afee9}",
    "hidden": false,
    "icon": "ms-appx:///ProfileIcons/pwsh.png",
    "name": "PowerShell 7.4 (mise)",
    "startingDirectory": "%USERPROFILE%"
  }
]

VSCode built in terminal

Can use commands too. VSCode settings.json:

{
  "terminal.integrated.defaultProfile.windows": "PowerShell v7.5 (mise)",
  "terminal.integrated.profiles.windows": {
    "PowerShell v7.4 (mise)": {
      "args": [
        "exec",
        "[email protected]",
        "--",
        "pwsh",
        "-NoLogo",
        "-NoExit",
        "-ExecutionPolicy",
        "RemoteSigned"
      ],
      "icon": "terminal-powershell",
      "overrideName": true,
      "path": "mise"
    },
    "PowerShell v7.5 (mise)": {
      "args": [
        "exec",
        "[email protected]",
        "--",
        "pwsh",
        "-NoLogo",
        "-NoExit",
        "-ExecutionPolicy",
        "RemoteSigned"
      ],
      "icon": "terminal-powershell",
      "overrideName": true,
      "path": "mise"
    },
    "Windows PowerShell (x64)": {
      "args": [
        "/NoLogo",
        "/NoExit",
        "/ExecutionPolicy",
        "RemoteSigned"
      ],
      "overrideName": true,
      "path": "${env:SystemRoot}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
    },
    "Windows PowerShell (x86)": {
      "args": [
        "/NoLogo",
        "/NoExit",
        "/ExecutionPolicy",
        "RemoteSigned"
      ],
      "icon": "terminal-powershell",
      "overrideName": true,
      "path": "${env:SystemRoot}\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe"
    }
  }
}

VSCode + vscode-powershell

Requires path, can't use command. Here one can use the Scoop shims. VSCode settings.json:

{
  "powershell.powerShellAdditionalExePaths": {
    "PowerShell v7.5": "C:\\Users\\olav.birkeland\\scoop\\shims\\pwsh75.exe",
    "PowerShell v7.4": "C:\\Users\\olav.birkeland\\scoop\\shims\\pwsh74.exe"
  },
  "powershell.powerShellDefaultVersion": "PowerShell v7.5"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement A feature request (enhancement). Needs: Triage Maintainer attention needed!
Projects
None yet
Development

No branches or pull requests

2 participants