-
Notifications
You must be signed in to change notification settings - Fork 129
Move PS content out of OneDrive #388
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are many more comments and questions I want to add. But start with these changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More comments
The file should have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just needs some consistency on the path naming and clarification on cross platform path consistency which is one of the most critical components of this.
|
||
```json | ||
{ | ||
"UserPSContentPath" : "$env:LOCALAPPDATA\\PowerShell\\PSContent", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the Linux existing CurrentUser modulepaths, etc. be updated to also use this? Will there be a migration approach? I don't like the idea of disparate paths per OS, should follow the XDG standard for both.
https://specifications.freedesktop.org/basedir-spec/latest/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Linux I'm thinking there is no need to change their existing paths at all. But I do think they would want this customizability.
So a way to achieve this is to add the current modulepaths to powershell.config.json and make the API retrieve the value every time.
For the migration approach, I'm thinking Linux users won't need to do anything if they keep their current path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is that on Linux, for example Modules, it's LOCALAppData\PowerShell by default (which dotnet does environment translation to XDG) and on windows it'll now be PowerShell\PSContent, so it'll be inconsistent, and if someone does this setting in a portable way, they'll have to account for those differences.
Is the PSContent folder really necessary? Why not just put Modules/Scripts/etc. in LocalAppData/PowerShell
directly? Then it's the same path on both Windows and Linux (from a dotnet perspective), plus one less level of unnecessary hierarchy. Is there a problem the PSContent
folder solves?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be the same "path" in dotnet on both, but land differently in the OS. That way if I change my preferred path, it'll still work consistently. I feel it should also be lowercase on both but if you want to add the appropriate handling for windows so it is PowerShell, that's fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for dropping PSContent-subfolder as default. Brings consistency with current structure in Documents/PowerShell and other platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We added the PSContent folder idea because we are trying to make the location customizable.
To achieve this we want to look at powershell.config to tell us where to look for the PSContent folder which will have everything PowerShell related.
On a side note, I think this also means the location of powershell.config has to be hardcoded and cannot be customized.
Interesting... I didn't know LocalApplicationData dotnet grabbed the linux equivalent like that.
I think Platform.XDG_Type.USER_MODULES already resolves to /home/user/.local/share/powershell
Currently for UNIX we grab the user module path like this:
internal static string GetPersonalModulePath()
{
#if UNIX
return Platform.SelectProductNameForDirectory(Platform.XDG_Type.USER_MODULES);
#else
string myDocumentsPath = InternalTestHooks.SetMyDocumentsSpecialFolderToBlank ? string.Empty : Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
return string.IsNullOrEmpty(myDocumentsPath) ? null : Path.Combine(myDocumentsPath, Utils.ModuleDirectory);
#endif
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a side note, I think this also means the location of powershell.config has to be hardcoded and cannot be customized
Yes 👍 I expected the config file itself to be hardcoded.
Combined with no automatic content migration when the setting is changed, I don't see any risk of sharing the same powershell-folder for both content and config by default.
- Recommendation: Ignore the setting in the machine-level configuration file since this is a user | ||
setting. No error - just ignore it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Silent errors often lead to confusion. We should warn somewhere (i.e. Event Log, Write-Warning on launch, etc.).
If a system admin sets this expecting all their users to get migrated by default and nothing happens, it'll lead to confusion and frustration.
As a system administrator I may want to set this on a shared system where we would want to avoid users ever dealing with OneDrive issues. We should just match the existing precedent defined in about_PowerShell_Config
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After Group Policy, settings defined at the AllUsers level take precedence over settings defined for the CurrentUser level.
Are you talking about this precedence? If so you're suggesting we make this be default AllUsers unless specified? I'm not opposed to this but am worried about breaking the current setups since they would be forced to migrate all their UserPSContent to the new location. Any thoughts @sdwheeler ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worried about breaking the current setups
While I would tend to agree and caution against breaking existing setups, this would only be the case for admins who deploy this setting retroactively. I would prioritize being consistent in how settings are applied and warn admins what the effect of this on the machine level would have.
If we're not consistent then we get into the, "Well in this scenario, the precedent comes from X, and in that scenario it comes from Y."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for machine-level preference for consistency and supporting managed/strict environments like shared device and even VDI/VDA where you might place it on a attached user drive.
If a system admin sets this expecting all their users to get migrated by default and nothing happens, it'll lead to confusion and frustration.
Not sure if it's done already, but in general there should be an event logged on startup all config-settings with effective value and source (User, Machine, GroupPolicy) as merge/precedence behavior can get complicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if the following is relevant but I think it'll help with the discussion.
I took another look at the PSModulePath code and as of now machine scoped stuff is not in OneDrive but in program files and not in the documents.
I think we decided to leave this alone and not move anything out of there.
internal static string GetSharedModulePath()
{
#if UNIX
return Platform.SelectProductNameForDirectory(Platform.XDG_Type.SHARED_MODULES);
#else
string sharedModulePath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
if (!string.IsNullOrEmpty(sharedModulePath))
{
sharedModulePath = Path.Combine(sharedModulePath, Utils.ModuleDirectory);
}
return sharedModulePath;
#endif
}
Will need some clarification from @sdwheeler for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not relevant. Our concern is the user-level modules folder, profile location etc.
My understanding is that a UserPSContentPath
setting in the machine pwsh config file would be a mandatory location (template string) for user profile, user-installed modules etc.
In Windows it would be equal to a user configuration in Group Policy, which we can't use here due to cross-platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Added some thoughts and concerns.
- Recommendation: Ignore the setting in the machine-level configuration file since this is a user | ||
setting. No error - just ignore it. | ||
|
||
- Will **UserPSContentPath** support environment variables (like `$env:USERNAME` or `%USERNAME%`)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required to support the machine-wide config at all without mixing user content, isn't it? env:UserName
, $HOME/$env:USERPROFILE
, $env:LocalAppData
etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think yes the goal is to support environment variables. I think this would be very useful.
But for machine-wide config I think we are not touching those that are in program files at this time. We are only trying to move the user PSContent folder out of myDocuments
- Recommendation: Ignore the setting in the machine-level configuration file since this is a user | ||
setting. No error - just ignore it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for machine-level preference for consistency and supporting managed/strict environments like shared device and even VDI/VDA where you might place it on a attached user drive.
If a system admin sets this expecting all their users to get migrated by default and nothing happens, it'll lead to confusion and frustration.
Not sure if it's done already, but in general there should be an event logged on startup all config-settings with effective value and source (User, Machine, GroupPolicy) as merge/precedence behavior can get complicated.
|
||
```json | ||
{ | ||
"UserPSContentPath" : "$env:LOCALAPPDATA\\PowerShell\\PSContent", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for dropping PSContent-subfolder as default. Brings consistency with current structure in Documents/PowerShell and other platforms.
|
||
## User Experience | ||
|
||
- On startup PowerShell will create a directory in AppData and a configuration file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it be created empty or with UserPSContentPath
predefined?
This is essential for the machine config discussed below unless machine-level gets precedence (ideally). User-level precedence and potentially predefined setting in user config would block any machine config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking with the experimental feature turned on UserPSContentPath will be predefined in the config file pointing to the new "recommended" location in LocalAppData. But all of the directories will be empty and the user will have to migrate on their own. As of now for this migration we are thinking about providing an example script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, as long as the machine config setting with variable support takes precedence. 🙂
This pull request proposes a new RFC (RFC0066) to change the default location of PowerShell user content on Windows machines from OneDrive to the AppData directory. The goal is to align PowerShell with other developer tools and improve usability by preventing unnecessary syncing issues.
Key changes include:
PSModulePath
.