Skip to content

Update PowerShell Module Path  #1184

Closed
Closed

Description

PowerShell requires a new module path that points to PowerShell Core modules rather than inbox PowerShell modules.

Desired values and order:

  1. ~\Documents\PowerShell\Modules - User documents module location for PowerShell Core
  2. %ProgramFiles%\PowerShell\Modules - Common module path for all instances of PowerShell Core
  3. %ProgramFiles%\PowerShell\Modules - Module path for the specific instance of PowerShell Core that is running.

PowerShell on Linux will need similar values, as described inline.

Activity

  1. added
    Area-SideBySide
    on Jun 23, 2016
  2. andyleejordan commented on Jun 24, 2016

    @andyleejordan
    Member

    Linux values are set according to XDG BDS for user modules (per #935), and use the app base for system modules (i.e. next to SMA).

  3. modified the milestones: Aug17, on Jul 13, 2016
  4. joeyaiello commented on Jul 21, 2016

    @joeyaiello
    Contributor

    Mike Richmond (@mirichmo) Is this blocked by #1187?

  5. mirichmo commented on Jul 21, 2016

    @mirichmo
    MemberAuthor

    Yes

  6. added this to the milestone on Aug 4, 2016
  7. 1 remaining item

  8. daxian-dbw commented on Aug 12, 2016

    @daxian-dbw
    Member

    resolved by #1721

  9. changed the title [-]Update PowerShell Module Path for Open PowerShell[/-] [+]Update PowerShell Module Path for PowerShell[/+] on Aug 17, 2016
  10. changed the title [-]Update PowerShell Module Path for PowerShell[/-] [+]Update PowerShell Module Path [/+] on Aug 17, 2016
  11. masaeedu commented on Aug 21, 2016

    @masaeedu

    Mike Richmond (@mirichmo) This seems to break PowershellGet for me. If I run install-module zlocation, this results in the ZLocation module being installed to ~\Documents\WindowsPowerShell\Modules. However, this is no longer in PSModulePath. As a result using ipmo zlocation or trying to use any commands from the module fails.

    Either this location should be kept in PSModulePath, or PowershellGet should install modules to the updated ~\Documents\Powershell\Modules location.

  12. kilasuit commented on Aug 21, 2016

    @kilasuit
    Collaborator

    Asad Saeeduddin (@masaeedu) - I would preference for PowerShellGet to understand which edition it is that its being run on and install to \Documents\WindowsPowershell\Modules if Desktop or \Documents\PowerShell\Modules if on Core

    However there is nothing stopping you explictly adding a location to PSModulePath in your session or as part of your profile for PSCore like i've shown in this blog post https://blog.kilasuit.org/2016/08/21/1-small-thing-about-running-powershell-core-and-windows-powershell-side-by-side-on-windows/

  13. masaeedu commented on Aug 21, 2016

    @masaeedu

    Ryan Yates (@kilasuit) I don't have any particular preferences for where Powershell installs modules, as long as the out of box experience works without fiddling with my environment variables. Currently the out of box experience does not work. If you do require me to fiddle with my environment variables before install-module foo will work, the exact changes should be documented in the getting started markdown.

  14. masaeedu commented on Aug 21, 2016

    @masaeedu

    Ryan Yates (@kilasuit) Also, re:

    I would preference for PowerShellGet to understand which edition it is that its being run on and install to \Documents\WindowsPowershell\Modules if Desktop or \Documents\PowerShell\Modules if on Core

    This is not what currently happens. I'm running Powershell Core and the version of PowershellGet loaded is the one bundled with the v6 alpha. Installed modules still end up in ~\Documents\WindowsPowershell.

    PS C:\Program Files\PowerShell\6.0.0.9> ls C:\Users\masae\Documents\PowerShell\Modules
    
    PS C:\Program Files\PowerShell\6.0.0.9> ls C:\Users\masae\Documents\WindowsPowerShell\Modules\
    
    PS C:\Program Files\PowerShell\6.0.0.9> $PSVersionTable
    
    Name                           Value
    ----                           -----
    PSVersion                      6.0.0-alpha
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1
    BuildVersion                   3.0.0.0
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
    PSEdition                      Core
    CLRVersion
    GitCommitId                    v6.0.0-alpha.9-107-gfb3d929e15c51028cf8d6ff6afd0dd19f288e9fd
    WSManStackVersion              3.0
    
    
    PS C:\Program Files\PowerShell\6.0.0.9> (get-command Install-Module).Module.Path
    C:\program files\powershell\6.0.0.9\Modules\PowerShellGet\PSModule.psm1
    
    PS C:\Program Files\PowerShell\6.0.0.9> Install-Module zlocation -Scope CurrentUser
    
    Untrusted repository
    You are installing the modules from an untrusted repository. If you trust this repository, change its
    InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
    'PSGallery'?
    [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): A
    
    PS C:\Program Files\PowerShell\6.0.0.9> ls C:\Users\masae\Documents\PowerShell\Modules
    
    PS C:\Program Files\PowerShell\6.0.0.9> ls C:\Users\masae\Documents\WindowsPowerShell\Modules\
    
    
        Directory: C:\Users\masae\Documents\WindowsPowerShell\Modules
    
    
    Mode                LastWriteTime         Length Name
    ----                -------------         ------ ----
    d-----       2016-08-21   4:27 PM                ZLocation
    
    
    PS C:\Program Files\PowerShell\6.0.0.9>
    
  15. kilasuit commented on Aug 21, 2016

    @kilasuit
    Collaborator

    I personally never install modules to user location but that is because

    I own my machine
    Therefore I have admin rights

    Also

    This is not what currently happens.

    Yeah but logically that is how it should work with the change to the User path in PSModulePath

    Plus PowerShellGet requires some work before it really is a useful module and IMO should not have been bundled with PSCore until the issues were worked out especially with the move to SemanticVersioning which has broken a number of things.

  16. kilasuit commented on Aug 21, 2016

    @kilasuit
    Collaborator

    You can always import modules using the full path to the psd1/psm1/dll file (which I actually do really more frequently than just via the module name)

    So like so it would be

    Import-Module C:\Users\Ryan\OneDrive\GitHub\PowerShellModules\PesterHelpers\PesterHelpers.psd1
  17. masaeedu commented on Aug 21, 2016

    @masaeedu

    I own my machine
    Therefore I have admin rights

    That's great, but non-admin installs should still work as they did before. I should mention that admin installs with Powershell Core doesn't really fix the issue, so this is not relevant. C:\Program Files\WindowsPowerShell is not in the PSModulePath either, but that's where an AllUsers scoped install of a module ends up.

    Yeah but logically that is how it should work with the change to the User path in PSModulePath

    I'm not sure what this means. Are you saying this change is already checked in somewhere or that you agree it should behave as I mentioned earlier (i.e. either keep ~/Documents/WindowsPowershell in PSModulePath or make PowershellGet install to ~/Documents/Powershell on Powershell Core)?

    especially with the move to SemanticVersioning which has broken a number of things.

    The SemanticVersioning issues have been resolved in the nightlies.

    I am aware you can manually import powershell modules from wherever they may exist on disk, but I don't see how this is relevant to fixing the install-module foo; ipmo foo; workflow we had in Powershell 5.

  18. mirichmo commented on Aug 22, 2016

    @mirichmo
    MemberAuthor

    Manikyam Bavandla (@bmanikm) Can you please take a look at this. It seems like Asad Saeeduddin (@masaeedu) is reporting a bug in PowerShellGet and I'd like you to confirm it. If so, please file a new issue to cover it.

  19. bmanikm commented on Aug 22, 2016

    @bmanikm
    Contributor

    Mike Richmond (@mirichmo) Asad Saeeduddin (@masaeedu) I have created #2021 to correct the installation locations in PowerShell Core on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area-SideBySide

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions