Skip to content

Make Install-Module automatically install in CurrentUser scope for non admin users #2292

Closed

Description

This is a feature request. Currently Install-Module gives a warning in Windows PowerShell if it is not run with admin privileges and -Scope CurrentUser is not specified.

As many users just expect Install-Module to work and as the ability to install Modules in the current users scope is one of the key advantages of PowerShell, it would be a great enhancement if the default behaviour of Install-Module would be to automatically install the Module in the current user scope if it is run with non admin privileges.

Activity

  1. added
    Area-PowerShellGet
    on Sep 19, 2016
  2. andyleejordan commented on Sep 19, 2016

    @andyleejordan
    Member

    Doing it specifically for "non-admin" users would not be a correct approach on Linux. Unlike Windows, Linux permissions are wildy varied, and changing behavior based on root/non-root user is generally regarded as incorrect. If you absolutely must adapt a behavior, you do so based on the result of first trying the operation (rather than guessing if you're going to succeed, you test instead), as it may be that a particular non-root user was given permissions to install to AllUsers scope. So we purposefully did not implement this logic.

    That said, it may make sense to change the default regardless of current user or permissions to be CurrentUser, as it is a) far more likely to succeed, and b) probably what the user wants in the first place. What do you think Manikyam Bavandla (@bmanikm)?

    So change:

    the default behaviour of Install-Module would be to automatically install the Module in the current user scope if it is run with non admin privileges.

    to just:

    the default behaviour of Install-Module would be to automatically install the Module in the current user scope

    and then I agree 😄

    I also agree with Florian Feldhaus (@ffeldhaus)'s other issue #2286 that the current presented error when installing to AllUsers scope fails is confusing. Instead of System.IO.DirectoryNotFoundException the error should be something like "you don't have the required permissions".

  3. ghost closed this as completedon Sep 19, 2016
  4. ghost reopened this on Sep 19, 2016
  5. andyleejordan commented on Sep 19, 2016

    @andyleejordan
    Member

    I'd say that's more in line with my final comment:

    the current presented error when installing to AllUsers scope fails is confusing. Instead of System.IO.DirectoryNotFoundException the error should be something like "you don't have the required permissions"

    Fail more gracefully than currently (but don't attempt the installation automatically a second time at a different scope).

  6. bmanikm commented on Sep 19, 2016

    @bmanikm
    Contributor

    I agree, we need to improve the error messages to fail more gracefully.

  7. kilasuit commented on Sep 30, 2016

    @kilasuit
    Collaborator

    As PowerShellGet has been decoupled to its own Repository in line with #1979 (almost complete for PowerShellGet as I have a PR coming shortly to finish this off) I have created this issue in the PowerShellGet Repository where further discussions around this issue can occur if required which means we can close this issue in this repository.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-PowerShellGet

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions