-
Notifications
You must be signed in to change notification settings - Fork 12
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
Get-PackageProvider is not recognized when running builds as non-administrator #158
Comments
Ok, so this seems to maybe have started happening even if you are an administrator... I have found a workaround for the Chocolatey Developer VM, that may work for others. Basically you can short circuit the script by running the following in an elevated Windows PowerShell session: # Determine where `ConvertToSARIF` and `PSScriptAnalyzer` are installed if they are already installed.
Get-Module -List ConvertToSARIF, PSScriptAnalyzer
# If it is installed to the local user, you need to uninstall it:
Uninstall-Module ConvertToSARIF
Uninstall-Module PSScriptAnalyzer
# Install the module to AllUsers scope
Install-Module ConvertToSARIF -requiredversion 1.0.0 -Scope AllUsers
# Install PSScriptAnalyzer to AllUsers scope
Install-Module PSScriptAnalyzer -RequiredVersion 1.21.0 -Scope AllUsers In my testing, after running this, then the error no longer occurs. It is possible that there are versions of PowerShell modules in play that have been updated and changed some of these things. We will want to identify what versions work for these scripts and pin to them if possible. |
Should the above be done in both PowerShell and Windows PowerShell? |
In my testing it was only needed in Windows PowerShell. From what I can tell, the |
I have an update to this that I've encountered while testing out the new VMs: If you run this entirely from Windows PowerShell, then you only need to run elevated the first time, then every other run works just fine. If however you try to run from within PowerShell 7.4.6 (and probably other versions), you will need to perform the workaround above. This appears to be related to the |
Checklist
What You Are Seeing?
Trying to run the build on Chocolatey CLI in a non-administrative terminal, receive the error:
The term 'Get-PackageProvider' is not recognized as the name of a cmdlet, function, script file, or operable program.
What is Expected?
The build should finish.
How Did You Get This To Happen?
build.bat
in the cloned down repo as a non-admin user.System Details
Installed Packages
Output Log
Additional Context
Workaround(s):
--shouldRunPSScriptAnalyzer=false
if you don't need the PSScriptAnalyzer output.This may stem from the fix for #130.
The text was updated successfully, but these errors were encountered: