-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Summary of the new feature request
'pwshup' (pronounced "push-up") is a proposed self-contained CLI tool meant to facilitate installing, updating, and configuring PowerShell on all platforms without relying on the presence of PowerShell. The goal is to provide a self-contained executable that can be dropped in a fresh environment (Windows, macOS, Linux) and use it to bootstrap a usable PowerShell environment.
Once PowerShell is installed, the tool would be called to update PowerShell and ensure proper baseline on all platforms, making it easier to the latest and greatest rather than deal with older versions for too long. Since the tool needs to install and update PowerShell, it cannot itself be written in PowerShell, which is why a "traditional" CLI tool is required.
This idea is a follow-up to this discussion on twitter.
Proposed technical implementation details
The 'pwshup' CLI tool would be written in Rust, just like the tool it takes inspiration from, 'rustup'. Without going into details as to why Rust is a good choice or not, it is a very common choice nowadays for making CLI tools, especially when they need to be fast, secure and cross-platform. Long story short, rustup is Rust toolchain installer that consists of a single executable. All you need is to copy it in the right place and call it to bootstrap the installation of everything needed for Rust development. It creates a local directory structure in the current user directory, and allows you to easily switch between versions of the Rust tooling.
The local user directory approach taken by rustup avoids the problem of elevating privileges, which has its advantages that could be transferred to PowerShell. One can "install" PowerShell relatively easily without admin rights, as it doesn't really need to be installed globally, as long as you can call it. However, I suggest that we support both install options in "Global" and "CurrentUser" scopes, leaving it up to the user to decide what works best depending on the use case.
For the "Global" install option, I suggest that 'pwshup' adds support for downloading platform-specific packages and simplify its installation or update. For instance, it could fetch and install the msi on Windows by default. It could also be made to support the MSIX installation, and the package type could be passed as an option to override the default. On macOS, it could detect the 'brew' command and default to install/update it through homebrew, etc. Alternatively, it could also handle doing a global installation without a platform-specific package, by doing the same type of installation done in a user local directory, but inside a global directory that is not writable with regular permissions.
For updating, 'pwshup' should help with the detection of PowerShell installation(s) and their versions, such that the update could be conditional on not having a recent enough version of PowerShell. For instance, an application could request pwsh 7.0.0, which would be fine if the system already has 7.1.0 installed. Various third-party applications could do version checks to detect if they have a suitable PowerShell environment available. If those applications are not given elevated permissions, they could call pwshup to download and "install" a recent version of PowerShell in a user-writable directory, and work around the problem this way. This may sound a bit extreme, but this alone would make it possible for a lot of third-party applications to add PowerShell 7 as a hard dependency, since there would be a reasonable way to always make it work without bundling a full copy of PowerShell.
I suggest we start small and just get the cross-platform "global" install to work, detecting and downloading the latest PowerShell releases directly from github.com/PowerShell/PowerShell GitHub releases. Once we have a usable prototype, it should be easier to look into getting the "CurrentUser" scope installations to work as well, unless someone wants to give it a short right away, probably importing bits and pieces from the original rustup.
For Windows specifically, I hope that a tool like 'pwshup' would really ease the transition away from Windows PowerShell 5.1. Since it comes with Windows and most PowerShell modules are compatible with it, it is hard to require PowerShell 7 as a baseline without running into issues where the system doesn't have it installed. Rather than use chocolatey, winget, or all sorts of different package managers on all platforms, I'd like to simply point to a single "download and run this" tool that can executed manually or automatically in a script.
PowerShell deserves a special treatment in this case, because PowerShell becomes the platform for many other tools. What if all you really need is to bootstrap PowerShell, then use purely PowerShell tools afterwards? In many cases, PowerShell is really all you're going to need, you just need PowerShell to get started.
I would like to hear your thoughts and comments on this!