PowerShell / PowerShell/PowerShell
Allow specifying custom PowerShell config and cache directory instead of the hardcoded paths in `Platform`
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 55.5k
- Forks
- 8.5k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 88
Description
Summary of the new feature/enhancement
Currently, it is possible to download PowerShell Core as a .zip archive and unzip it to a custom directory and everything seems to work correctly even from non-standard path, so users could run pwsh as a portable package by putting it e.g. on a USB flash drive and just plugging it in whenever needed.
However, the config directory (where profile and installed modules are stored; at Documents/Powershell) and cache directory (at LocalAppData\Microsoft\PowerShell) paths are currently hardcoded. It would be great if we could specify custom paths in powershell.config.json or another similar config file, ideally with support for paths relative to the pwsh.exe binary.
Proposed technical implementation details (optional)
It seems that both directories are configured here: https://github.com/PowerShell/PowerShell/blob/1a3721a574e00263f64101d5dbbe1a975e6c8087/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs#L149
As far as I can tell, it should be enough to check if there are any paths configured in the config file and set them here (and ideally abort with an error if the paths do not exist). I don't have much experience with C#, but I can try writing a pull request if we agree on a solution.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/System.Management.Automation/CoreCLR/CorePsPlatform.cs around the path definitions referenced in the issue, then trace how powershell.config.json is loaded. Determine how custom config and cache paths, including paths relative to pwsh.exe, should be represented and validated. Done means portable installations can use configured directories instead of the current hardcoded paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- cli, operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100