Skip to content

fix: non-writable global user profile #14 #17

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

dviererbe
Copy link
Contributor

@dviererbe dviererbe commented Jul 11, 2025

Summary

PowerShell should search in a dedicated directory (other than the installation directory) for the all-users profile to adhere to the Filesystem Hierarchy Standard (FHS).

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:

  • bash(1): /etc/bash.bashrc (Debian/Ubuntu) or /etc/bashrc (RedHat/Fedora)
  • zsh(1): /etc/zshrc
  • fish(1): /etc/fish/config.fish

I took inspiration from where NuGet is locating its system-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, then this location is used; otherwise PowerShell uses /etc/opt/powershell.

Fixes: #14

I am currently working on upstreaming a similar patch, see PowerShell/PowerShell#25748

Note

This PR is based on PR #15. It needs to merge first. For easier readability of the diff I set the merge target to #15. Reset this to main once #15 is merged.

Summary
=======
PowerShell should search in a dedicated directory (other than the
installation directory) for the all-users profile to adhere to the
Filesystem Hierarchy Standard [FHS].

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:
- bash(1): `/etc/bash.bashrc` (Debian/Ubuntu) or
           `/etc/bashrc` (RedHat/Fedora)
- zsh(1):  `/etc/zshrc`
- fish(1): `/etc/fish/config.fish`

I took inspiration from where NuGet is locating its
system-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, then this
location is used; 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-uses

Fixes: #14
Signed-off-by: Dominik Viererbe <dominik.viererbe@canonical.com>
@dviererbe dviererbe requested a review from a team as a code owner July 11, 2025 14:30
@mateusrodrigues
Copy link
Member

mateusrodrigues commented Jul 11, 2025

suggestion (blocking): Let's introduce this change to Snaps only when the upstream PR gets merged.

Given the functionality change introduced by this PR, upstream might also have opinions that can change how this specific issue is solved. Therefore, I would be much more comfortable letting PowerShell/PowerShell#25748 merge before introducing this change to our Snap users.

At that point, even if only 7.6.x gets the fix, we can consider backporting to Stable and LTS through patches, but maybe not until we know for sure what the final fix looks like.

@mateusrodrigues mateusrodrigues force-pushed the feat/s390x-ppc64el-support branch 2 times, most recently from c0c79bb to 7408dcd Compare July 11, 2025 18:18
@dviererbe dviererbe changed the base branch from feat/s390x-ppc64el-support to main July 12, 2025 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants