Skip to content
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

Chocolatey fails to load all PowerShell helper cmdlets when attempting to loads modules #2412

Closed
AdmiringWorm opened this issue Oct 21, 2021 · 1 comment · Fixed by #2414
Closed

Comments

@AdmiringWorm
Copy link
Member

AdmiringWorm commented Oct 21, 2021

What You Are Seeing?

When the Chocolatey Licensed extension fails to load some of the expected helper cmdlets won't be available due to the importing being aborted before everything is processed.
This also affects when normal extensions are imported if they fail to be imported in some way.
This especially affects users of the AU extension which makes a monkey patch of the cmdlets to make maintenance easier for the user, in which case the Licensed extension can not be loaded.

What is Expected?

All cmdlets available in open source Chocolatey should be loaded even in the case where an extension is failing to load, even if that extension is the Licensed edition of Chocolatey.
Before Chocolatey 0.11.0 failing to import any extension with a DLL extension would report a Warning, but continue execution. After 0.11.1 this has been changed to an error, and is preventing the execution of the module loading.

How Did You Get This To Happen? (Steps to Reproduce)

  1. Have Chocolatey 0.11.1+ and a supported Licensed extension installed.
  2. Create a new package that uses the Get-ChocolateyWebFile cmdlet.
  3. Create an AU update script for updating the package.
  4. Ensure the monkey patched scripts are first removed (Remove-Item $env:TEMP\chocolatey\au
  5. Force a package update using the created AU update script.

Output Log

Chocolatey Log

No log file available

AU Log

Console:

Updating 1 automatic packages at 2021-10-21 12:54:36 (forced)
Push is disabled
NoCheckChocoVersion is disabled
FORCE IS ENABLED. All packages will be updated
   [1/1] veeam-one-iso ERROR:
     The term 'Get-ChocolateyWebFile' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (3,77s)

Log File:

veeam-one-iso - checking updates using au version 2021.7.18

URL check
  https://download2.veeam.com/VONE/v11/VeeamONE_11.0.1.1880_20210922.iso
nuspec version: 11.0.1.1880
remote version: 11.0.1.1880
No new version found, but update is forced
New version is available
Automatic checksum started

Manual Import

> import-module $env:ChocolateyInstall\helpers\chocolateyInstaller.psm1
Import-Module : Could not load file or assembly 'chocolatey, Version=0.10.15.0, Culture=neutral, PublicKeyToken=79d02ea
9cad655eb' or one of its dependencies. Systemet finner ikke angitt fil.
At C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1:76 char:13
+             Import-Module $licensedExtensionPath
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand

@AdmiringWorm
Copy link
Member Author

/cc @mkevenaar

@AdmiringWorm AdmiringWorm self-assigned this Oct 21, 2021
AdmiringWorm added a commit to AdmiringWorm/choco that referenced this issue Oct 21, 2021
…rning

This commit updates the chocoalteyInstaller module to not output an error
when failing to load the Chocolatey Licensed Extension which would prevent
all helper cmdlets in FOSS being exported.

Instead the importing have been wrapped inside a try/catch block and writes
out a Warning that includes the reason the importing failed.
@gep13 gep13 modified the milestones: 0.12.0, 0.11.3 Oct 21, 2021
gep13 pushed a commit to AdmiringWorm/choco that referenced this issue Oct 21, 2021
…rning

This commit updates the chocoalteyInstaller module to not output an error
when failing to load the Chocolatey Licensed Extension which would prevent
all helper cmdlets in FOSS being exported.

Instead the importing have been wrapped inside a try/catch block and writes
out a Warning that includes the reason the importing failed.
gep13 pushed a commit to AdmiringWorm/choco that referenced this issue Oct 21, 2021
This commit updates the chocolateyInstaller module to not output an error
when failing to load the Chocolatey Licensed Extension which would prevent
all helper cmdlets in FOSS being exported.

Instead the importing have been wrapped inside a try/catch block and writes
out a Warning that includes the reason the importing failed.
gep13 added a commit that referenced this issue Oct 21, 2021
…lper-cmdlets-when-extensions-fails-to-load

(#2412) Change importing of Licensed extension to output warning
@gep13 gep13 closed this as completed Oct 21, 2021
@gep13 gep13 changed the title Faling to load all helper cmdlets when extensions fails to load Chocolatey fails to load all PowerShell helper cmdlets when attempting to loads modules Oct 27, 2021
gep13 added a commit that referenced this issue Oct 27, 2021
* hotfix/0.11.3:
  (version) 0.11.3-beta
  (maint) Prevent inclusion of snk file
  (#2336) Remove quotes from InstallLocation
  (#877) Set SourceType for packages parsed from config
  (#2289) Add acknowledgements and license files
  (#2289) Update Rhino.Licensing dependency
  (maint) Replace unversioned Rhino.Licensing dll
  (#2398) Restore PowerShell v2 support
  (#2412) Switch to output warning on failure
gep13 added a commit that referenced this issue Oct 27, 2021
* master:
  (version) 0.11.3
  (version) 0.11.3-beta
  (maint) Prevent inclusion of snk file
  (#2336) Remove quotes from InstallLocation
  (#877) Set SourceType for packages parsed from config
  (#2289) Add acknowledgements and license files
  (#2289) Update Rhino.Licensing dependency
  (maint) Replace unversioned Rhino.Licensing dll
  (#2398) Restore PowerShell v2 support
  (#2412) Switch to output warning on failure

# Conflicts:
#	.uppercut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants