You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make Install-Module automatically install in CurrentUser scope for non admin users #2292
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.
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".
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).
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.
Activity
andyleejordan commentedon Sep 19, 2016
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
AllUsersscope. 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:
to just:
and then I agree 😄
I also agree with Florian Feldhaus (@ffeldhaus)'s other issue #2286 that the current presented error when installing to
AllUsersscope fails is confusing. Instead ofSystem.IO.DirectoryNotFoundExceptionthe error should be something like "you don't have the required permissions".andyleejordan commentedon Sep 19, 2016
I'd say that's more in line with my final comment:
Fail more gracefully than currently (but don't attempt the installation automatically a second time at a different scope).
bmanikm commentedon Sep 19, 2016
I agree, we need to improve the error messages to fail more gracefully.
kilasuit commentedon Sep 30, 2016
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.