- Notifications
You must be signed in to change notification settings - Fork7.7k
Use a dedicated configuration directory path for all-users profiles on non-windows systems.#25748
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Draft
dviererbe wants to merge1 commit intoPowerShell:masterChoose a base branch fromdviererbe:feat/SeparateAllUsersFolderPath
base:master
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Draft
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Currently the all-users profiles are stored in theinstallation directory. Unix-based systems andderivatives mostly follow recommendations of theFilesystem Hierarchy Standard [FHS]. The FHSrecommends to place configuration files into the/etc directory.For example, here are the locations of the systemwide configuration files of other popular shells:- bash(1): /etc/bash.bashrc (Debian/Ubuntu) or /etc/bashrc (RedHat/Fedora)- zsh(1): /etc/zshrc- fish(1): /etc/fish/config.fishI took inspiration from where NuGet is locating itssystem-wide configuration, see [NuGet config file locations]:This commit introduces the environment variable`POWERSHELL_COMMON_APPLICATION_DATA`.If this variable is neither null nor empty, thenthis location is used. This allows distros that donot follow the FHS to customize the location.On Windows PowerShell keeps using the installation directory.On macOS PowerShell uses the `/Library/Application Support/PowerShell` directory.Otherwise PowerShell uses `/etc/opt/powershell`.[FHS]:https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html[NuGet config file locations]:https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#config-file-locations-and-usesFixes:PowerShell#20336,PowerShell#25007Signed-off-by: Dominik Viererbe <dominik.viererbe@canonical.com>
@microsoft-github-policy-service agree company="Canonical Ltd." |
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
Waiting on AuthorThe PR was reviewed and requires changes or comments from the author before being accept
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
PowerShell should search in a dedicated directory (other than the installation directory) for the all-users profile to adhere to theFilesystem Hierarchy Standard (FHS).
PR Context
Currently the all-users profiles are stored in the installation directory. Unix-based systems and derivatives mostly follow recommendations of the FHS. The FHS recommends to place configuration files into the
/etc
directory.For example, here are the locations of the system wide configuration files of other popular shells:
/etc/bash.bashrc
(Debian/Ubuntu) or/etc/bashrc
(RedHat/Fedora)/etc/zshrc
/etc/fish/config.fish
I took inspiration from where NuGet is locating its system-wide configuration, seeNuGet config file locations:
This commit introduces the environment variable
POWERSHELL_COMMON_APPLICATION_DATA
.If this variable is neither null nor empty, then this location is used. This allows distros that do not follow the FHS to customize the location.
/Library/Application Support/PowerShell
directory./etc/opt/powershell
.This change is also needed to make the all-users profile usable when installing powershell via a snap, seecanonical/powershell-snaps#14
Fixes:#20336,#25007
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright header