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

Initial chocolatey.config configuration file is initialized with empty descriptions #3201

Closed
4 tasks done
AdmiringWorm opened this issue Jun 7, 2023 · 2 comments · Fixed by #3223
Closed
4 tasks done
Assignees
Milestone

Comments

@AdmiringWorm
Copy link
Member

Checklist

  • I have verified this is the correct repository for opening this issue.
  • I have verified no other issues exist related to my problem.
  • I have verified this is not an issue for a specific package.
  • I have verified this issue is not security related.

What You Are Seeing?

Right after installing Chocolatey CLI to v2.0.0, the configuration file that gets initialized is missing the description for the elements cacheLocation, containsLegacyPackageInstalls and commandExecutionTimeoutSeconds. This causes issues with Chocolatey GUI due to it not handling empty descriptions. While this is something that needs to be fixed in Chocolatey GUI, we should also ensure that the description gets added when the configuration file is created.

image

What is Expected?

There should not be any empty/missing descriptions in the configuration file.

How Did You Get This To Happen?

  1. Install Chocolatey CLI using the script on https://chocolatey.org/install
  2. Open up the file %ChocolateyInstall%\config\chocolatey.config
  3. See the top three items are missing their description.

System Details

  • Operating System: Windows Server 2022 (10.0.20348.0)
  • Windows PowerShell version: 5.1.20348.859
  • Chocolatey CLI Version: 2.0.0
  • Chocolatey Licensed Extension version: N/A
  • Chocolatey License type: N/A
  • Terminal/Emulator: Windows PowerShell

Installed Packages

N/A

Output Log

2023-06-07 11:08:24,598 2996 [DEBUG] - XmlConfiguration is now operational
2023-06-07 11:08:24,708 2996 [DEBUG] - Adding new type 'CygwinService' for type 'IAlternativeSourceRunner' from assembly 'choco'
2023-06-07 11:08:24,708 2996 [DEBUG] - Adding new type 'CygwinService' for type 'IInstallSourceRunner' from assembly 'choco'
2023-06-07 11:08:24,708 2996 [DEBUG] - Adding new type 'PythonService' for type 'IAlternativeSourceRunner' from assembly 'choco'
2023-06-07 11:08:24,708 2996 [DEBUG] - Adding new type 'PythonService' for type 'IListSourceRunner' from assembly 'choco'
2023-06-07 11:08:24,708 2996 [DEBUG] - Adding new type 'PythonService' for type 'IInstallSourceRunner' from assembly 'choco'
2023-06-07 11:08:24,723 2996 [DEBUG] - Adding new type 'PythonService' for type 'IUninstallSourceRunner' from assembly 'choco'
2023-06-07 11:08:24,723 2996 [DEBUG] - Adding new type 'RubyGemsService' for type 'IAlternativeSourceRunner' from assembly 'choco'
2023-06-07 11:08:24,723 2996 [DEBUG] - Adding new type 'RubyGemsService' for type 'IListSourceRunner' from assembly 'choco'
2023-06-07 11:08:24,723 2996 [DEBUG] - Adding new type 'RubyGemsService' for type 'IInstallSourceRunner' from assembly 'choco'
2023-06-07 11:08:24,723 2996 [DEBUG] - Adding new type 'SystemStateValidation' for type 'IValidation' from assembly 'choco'
2023-06-07 11:08:25,021 2996 [DEBUG] - Adding new type 'EmptyOrInvalidUrlMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2023-06-07 11:08:25,021 2996 [DEBUG] - Adding new type 'FrameWorkReferencesMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2023-06-07 11:08:25,021 2996 [DEBUG] - Adding new type 'IconMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2023-06-07 11:08:25,021 2996 [DEBUG] - Adding new type 'LicenseMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2023-06-07 11:08:25,021 2996 [DEBUG] - Adding new type 'PackageTypesMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2023-06-07 11:08:25,036 2996 [DEBUG] - Adding new type 'ReadmeMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2023-06-07 11:08:25,036 2996 [DEBUG] - Adding new type 'RepositoryMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2023-06-07 11:08:25,036 2996 [DEBUG] - Adding new type 'RequireLicenseAcceptanceMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2023-06-07 11:08:25,036 2996 [DEBUG] - Adding new type 'ServicableMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2023-06-07 11:08:25,036 2996 [DEBUG] - Adding new type 'VersionMetadataRule' for type 'IMetadataRule' from assembly 'choco'
2023-06-07 11:08:25,036 2996 [DEBUG] - Registering new command 'list' in assembly 'choco'
2023-06-07 11:08:25,036 2996 [DEBUG] - Registering new command 'template' in assembly 'choco'
2023-06-07 11:08:25,051 2996 [DEBUG] - Registering new command 'export' in assembly 'choco'
2023-06-07 11:08:25,051 2996 [DEBUG] - Registering new command 'info' in assembly 'choco'
2023-06-07 11:08:25,051 2996 [DEBUG] - Registering new command 'help' in assembly 'choco'
2023-06-07 11:08:25,051 2996 [DEBUG] - Registering new command 'config' in assembly 'choco'
2023-06-07 11:08:25,051 2996 [DEBUG] - Registering new command 'feature' in assembly 'choco'
2023-06-07 11:08:25,051 2996 [DEBUG] - Registering new command 'new' in assembly 'choco'
2023-06-07 11:08:25,051 2996 [DEBUG] - Registering new command 'outdated' in assembly 'choco'
2023-06-07 11:08:25,051 2996 [DEBUG] - Registering new command 'pack' in assembly 'choco'
2023-06-07 11:08:25,051 2996 [DEBUG] - Registering new command 'pin' in assembly 'choco'
2023-06-07 11:08:25,051 2996 [DEBUG] - Registering new command 'push' in assembly 'choco'
2023-06-07 11:08:25,051 2996 [DEBUG] - Registering new command 'apikey' in assembly 'choco'
2023-06-07 11:08:25,051 2996 [DEBUG] - Registering new command 'source' in assembly 'choco'
2023-06-07 11:08:25,051 2996 [DEBUG] - Registering new command 'uninstall' in assembly 'choco'
2023-06-07 11:08:25,051 2996 [DEBUG] - Registering new command 'upgrade' in assembly 'choco'
2023-06-07 11:08:25,051 2996 [DEBUG] - Registering new command 'search' in assembly 'choco'
2023-06-07 11:08:25,051 2996 [DEBUG] - Registering new command 'unpackself' in assembly 'choco'
2023-06-07 11:08:25,051 2996 [DEBUG] - Registering new command 'install' in assembly 'choco'
2023-06-07 11:08:25,193 2996 [DEBUG] - Attempting to create directory "C:\ProgramData\chocolatey\config".
2023-06-07 11:08:25,741 2996 [INFO ] - ============================================================
2023-06-07 11:08:26,367 2996 [DEBUG] - Attempting to replace "C:\ProgramData\chocolatey\config\chocolatey.config"
 with "C:\ProgramData\chocolatey\config\chocolatey.config.2996.update".
 Backup placed at "C:\ProgramData\chocolatey\config\chocolatey.config.backup".
2023-06-07 11:08:26,367 2996 [DEBUG] - Attempting to copy "C:\ProgramData\chocolatey\config\chocolatey.config.2996.update"
 to "C:\ProgramData\chocolatey\config\chocolatey.config".
2023-06-07 11:08:26,382 2996 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\config\chocolatey.config.2996.update".
2023-06-07 11:08:26,382 2996 [INFO ] - 2.0.0
2023-06-07 11:08:26,382 2996 [DEBUG] - Exiting with 0

Additional Context

No response

@gep13
Copy link
Member

gep13 commented Jun 23, 2023

This issue is related to this issue as they both have the same root cause.

@gep13 gep13 linked a pull request Jun 23, 2023 that will close this issue
10 tasks
gep13 added a commit to gep13/choco that referenced this issue Jun 23, 2023
Previously, in this commit:

chocolatey@da19356#diff-cb6a0471e41268b22a928bd57a59d51b70b7024e9beb30e89a330e193a089eba

The usage of the top level CacheLocation and
CommandExecutionTimeoutSeconds values had been removed, since these top
level properties within the chocolatey.config had been replaced with
values contained within the config section of the chocolatey.config
file.

However, the changes in that commit were too aggressive, and removed
the call to the set_config_item (which has subsequently been renamed to
SetConfigItem).  The method call does the work of taking any value that
is defined in the chocolatey.config for a given property name, and
adding it to the ChocolateyConfiguration instance.  When this method
call was removed, it stopped setting the property value on the
instance, and as a result, values that had been configured in the
chocolatey.config file were ignored.  They were still in play when the
configuration was passed in via a command line option, but not when
defining them in the chocolatey.config file.

The removal of this call to the set_config_item method also explains
why it was necessary to apply this bug fix in Chocolatey GUI:

chocolatey/ChocolateyGUI#1003

The method call also had the effect of setting the description on the
configuration value, which would have meant that Chocolatey GUI
wouldn't have thrown a null reference exception.  The change in
Chocolatey GUI is still valid though, as there are times when a config
value can have a missing description, so it makes sense to leave that
fix in place.
corbob pushed a commit to gep13/choco that referenced this issue Jun 23, 2023
Previously, in this commit:

chocolatey@da19356#diff-cb6a0471e41268b22a928bd57a59d51b70b7024e9beb30e89a330e193a089eba

The usage of the top level CacheLocation and
CommandExecutionTimeoutSeconds values had been removed, since these top
level properties within the chocolatey.config had been replaced with
values contained within the config section of the chocolatey.config
file.

However, the changes in that commit were too aggressive, and removed
the call to the set_config_item (which has subsequently been renamed to
SetConfigItem).  The method call does the work of taking any value that
is defined in the chocolatey.config for a given property name, and
adding it to the ChocolateyConfiguration instance.  When this method
call was removed, it stopped setting the property value on the
instance, and as a result, values that had been configured in the
chocolatey.config file were ignored.  They were still in play when the
configuration was passed in via a command line option, but not when
defining them in the chocolatey.config file.

The removal of this call to the set_config_item method also explains
why it was necessary to apply this bug fix in Chocolatey GUI:

chocolatey/ChocolateyGUI#1003

The method call also had the effect of setting the description on the
configuration value, which would have meant that Chocolatey GUI
wouldn't have thrown a null reference exception.  The change in
Chocolatey GUI is still valid though, as there are times when a config
value can have a missing description, so it makes sense to leave that
fix in place.
AdmiringWorm added a commit that referenced this issue Jun 26, 2023
(#3201 #3225) Re-instate setting of config properties
@gep13 gep13 closed this as completed Jun 26, 2023
@gep13 gep13 changed the title Initial configuration file is initialized with empty descriptions Initial chocolatey.config configuration file is initialized with empty descriptions Jun 27, 2023
gep13 added a commit that referenced this issue Jun 29, 2023
* release/2.1.0: (52 commits)
  (maint) If statement formatting change
  (#3224) Add Assembly Loaded configuration option
  (maint) Resave without BOM
  (#3224) Update version check tests
  (#3174) Store non-normalized package version
  (maint) Add required whitespace
  (#3225) Add Pester Tests to ensure environment
  (#3201 #3225) Re-instate setting of config values
  (maint) Remove env variable for release version
  (maint) Fix encoding of file
  (#3194) Add tab completion for cache command
  (#2854) Re-save file with UTF-8 with BOM
  (#3218) Update Tab Expansion to use Test-Path
  (#3218) Remove try catch block for tab completion
  (build) Use latest Chocolatey.Cake.Recipe package
  (#2854) Do Write-Error instead of Write-Warning
  (#2854) Pester tests to Get-ChocolateyConfigValue
  (maint) Resave Get-ChocolateyConfigValue as CRLF
  (#2854) Add helper to read config values
  (#3214) Add Pester tests to ensure cache cleared
  ...
@choco-bot
Copy link

🎉 This issue has been resolved in version 2.1.0 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

gep13 added a commit that referenced this issue Jun 29, 2023
* master:
  (maint) If statement formatting change
  (#3224) Add Assembly Loaded configuration option
  (maint) Resave without BOM
  (#3224) Update version check tests
  (#3174) Store non-normalized package version
  (maint) Add required whitespace
  (#3225) Add Pester Tests to ensure environment
  (#3201 #3225) Re-instate setting of config values
  (maint) Remove env variable for release version
  (maint) Fix encoding of file
  (#3194) Add tab completion for cache command
  (#2854) Re-save file with UTF-8 with BOM
  (#3218) Update Tab Expansion to use Test-Path
  (#3218) Remove try catch block for tab completion
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.

3 participants