PowerShell / PowerShell Public
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
Let's move PSModulePath out of the documents folder #15552
Comments
|
A few extra things to consider when putting this up for triage:
I think this change should happen... hopefully soon. I think storage for these modules should be in the PS: I create PowerShell modules... I have a lot of them... and they are all on my OneDrive now. |
|
@jeroenlandheer Do you mean Update-Module? If so you couls discuss in PowerShellGet repository. |
|
@iSazonov Would the PowerShellGet guys be able to change the default value of Though there should probably be a second issue in PowerShellGet to respect the value, not overwrite it. |
|
@JohnLudlow Any changes related to PSModulePath are breaking changes. We need to keep backward compatibility. |
|
@iSazonov Sorry, that was a typo. This should indeed go there too, but don't you think they will choose the location of the modules where they install them... based on whatever this teams says it should be? (AFAIK there's no way to customize this with settings, but that's something for another day.) If paths for loading the modules is the primary function of
No need to move stuff around, new things get installed in And now we're on this subject, in Windows installations, modules which are installed on the local machine are installed by default in the AFAIK the functionality of Hope this helps. |
|
@jeroenlandheer Indeed, and if I do want to move the older modules to the new folder (I probably would, in my case), there are some options:
Any of those would work for me, but some people may appreciate it being done for them. And you're absolutely correct IMHO about the Windows Modules. The only modules that should be there are ones that are installed as part of PowerShell and shouldn't be removed. |
While I agree that it would be hard to claim this is explicitly a breaking change of an API, it would still be disruptive. There has never been a supported way of determining the module paths of different scopes, e.g. no (Note that I'm not necessarily advocating against it, but it's something that needs to be considered) |
|
Related: #7082 (comment) |
|
Previously discussed in #8069 too |
|
So we reviewed this on the @PowerShell/powershell-committee today, but also this is something I've personally done some thinking on in the past. The mangling on particular locations on the PSModulePath is something we've seen users impacted by repeatedly. For example: PowerShell/vscode-powershell#2824 (comment). Another important point is that the CurrentUser and AllUsers module paths are actually configurable in the powershell.config.json: PowerShell/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs Lines 1304 to 1305 in e2c23fc
So there is a concept of both the default CurrentUser module path and the actual one. However, there's currently no way to communicate the actual one, so the default is the implicit contract between PowerShell's module system ( Today it seems that both PowerShell 7 and PowerShellGet agree that the default CurrentUser module path lies under the The big issue now is that OneDrive configurations override the MyDocuments folder and cause this unexpected migration. But additionally, the actual CurrentUsers module path could be overridden with a configuration. And this is something that things like the PowerShell Azure Functions worker would want to do given the radically different environment in which it operates. Except that there's no way for PowerShellGet to pick this up. In terms of changing the default PSModulePath, there have been a lot of proposals to fix PSModulePath in various ways. Changing the CurrentUser path away from MyDocuments is going to break PowerShellGet, since it depends on the same location being used. However, the MyDocuments path clearly presents problems, and both the proposed alternatives ( So in terms of recommendations:
|
|
@rjmholt That's a great summary. Thanks. We'll see what the Engine Working Group say |
|
With behavior of OneDrive the WG agrees that we need to come up with a proper solution, however the scenarios have a high level of complexity which is exacerbated by the need that other PS tools also need to be able to use whatever solution is made available. The WG proposes that PS should provide an API which allows tools to query for the default location of modules. The tool chain also needs to be able to query PS so the values are consistent. We propose that an RFC is needed to define the behaviors, not only for PowerShell proper but for tools like PowerShellGet. We think at least the following requirements need to be addressed in the RFC:
|
|
+1. Nuget doesn't have this problem because it uses It's like syncing a .git repo in OneDrive! Unnecessary. Whichever solution comes up, it should be configurable for devices, i.e. via InTune or PowerShell so we can make it consistent for all our developers. |
|
Would a dot folder work here possibly? i.e. I came across this as I'm looking to considerably cut down my documents folder when looking at OneDrive backup and I was hoping there was a way I could have PSGet use another folder. I'm still looking into what my options for this are - not sure if just changing |
|
@mikhey Changing A |
|
My preference is Also, I notice that many other tools on Windows are now using |
|
@JohnLudlow yeah, I was thinking of making it a symlink, but OneDrive doesn't like that for the backups. After I realized that I had much more space than I thought it did, I just let it go to OneDrive. While it may have become a non-issue for me regarding OneDrive, I do feel it is something that should be addressed. This has probably been mentioned before, but off the top of my head a few things to look at for an implementation could be:
|
As @rkeithhill said, those dot folders pollute PowerShell actually already conforms to the XDG base directory specification on *nix, which is a standard intended to solve this problem. PowerShell data files, including modules, are stored in The issue then is that Windows doesn't really offer a clear answer here, because its philosophy is to separate users from configurers/application installers. Worth noting is that the XDG standard is configurable with a sensible default, and I imagine we want the same, we just need to weigh configurability against complexity (mainly for anyone developing against our decision) and performance. |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.


Summary of the new feature/enhancement
The documents folder has always been where modules user-scoped are kept, and that's always been ok, but I recently discovered some problems with this as I've been getting more familiar with Azure and my work laptop maps Documents to OneDrive. This can be problematic for a few reasons, such as OneDrive not syncing correctly or trying to restore a bunch of files from a module I just uninstalled. This is particularly an issue with larger modules (or groups of modules) such as Az.*
We can certainly wish OneDrive was better at its job, but really these files shouldn't be there - they are not documents. The user is not expected to edit them or look at them. They are more akin to application files or application data. There's no value to them being in OneDrive other than to transfer them to another machine, and that can be better achieved by having a script in OneDrive that calls PSDepend or PowerShellGet to install modules on that other machine.
I have updated my profile script to remove this path but it reappears after running
install-module.Proposed technical implementation details (optional)
Documents\PowerShell\Modulesfrom the$env:PSModulePathdefault. Select a new default path such as~\PowerShell\Modulesor$env:localappdata\PowerShell\ModulesThe text was updated successfully, but these errors were encountered: