CPMR0072 - Usage of Private Environment Variables
CPMR0072 - Usage of Private Environment Variables
WARNING
This rule has been marked as a Requirement.
Requirements represent the minimum quality of a package that is acceptable. When a package version has failed requirements, the package version requires fixing and/or response by the maintainer. Provided a Requirement has flagged correctly, it must be fixed before the package version can be approved. The exact same version should be uploaded during moderation review.
Issue
In an automation script (.ps1
/.psm1
) the scripts make use of either reading or writing private environment variables that should only be used by Chocolatey CLI helpers and not the automation scripts themselves.
Recommended Solution
Remove any use of the following environment variables in the automation scripts.
chocolateyToolsLocation
chocolateyBinRoot
chocolatey_bin_root
chocolateyPackageFolder
packageFolder
chocolateyChecksum32
chocolateyChecksum64
chocolateyChecksumType32
chocolateyChecksumType64
downloadCacheAvailable
Chocolatey Tools Location
Any usages of the chocolateyToolsLocation
, chocolateyBinRoot
, or chocolatey_bin_root
can be replaced with a call to Get-ToolsLocation. The Get-ToolsLocation
helper is a wrapper that will provide the same information as directly reading the environment variable, but it also ensures that the variable is created if it did not previously exist.
Chocolatey Package Folder
Replace usages of chocolateyPackageFolder
or packageFolder
with Get-ChocolateyPath -PathType 'PackagePath'
. See the documentation for Get-ChocolateyPath for more information on the helper.
Reasoning
The variables are used by the Chocolatey CLI helpers by including additional support and should not be used by the automation scripts themselves.