Replies: 2 comments
-
Environment variables are strings, and in PowerShell, empty or null strings translate to false
But for your example, it looks like whatever it is that you are passing in wants a boolean value explicitly, and powershell is having trouble for whatever reason converting the environment variable to a boolean. Potentially, you could try casting it to a bool with
Chocolatey CLI is not a powershell module. Chocolatey CLI is an executable program that uses PowerShell internally for package automation scripts. If you want to use Chocolatey CLI as a PowerShell module, you may want to look into using something like ChocolateyGet or Foil If you are actually talking about the Chocolatey CLI PowerShell host that runs the package automation scripts, then can you please provide a bit more information about what you are talking about?
This is the output I get from reinstall git with
And here is the output from reinstalling git on Chocolatey CLI, with 16 lines of output:
I wouldn't call the Chocolatey output dozens of lines. Of course, it could get up to dozens lines if multiple packages are being installed/upgraded/uninstalled, but it still would be in the same ballpark as Since Chocolatey is a package manager, it should be compared to other package managers in terms of output. The information that is logged to the screen is there for good reason, it either helps troubleshooting if something goes wrong, or it helps let the user know where it is in the process of completing the actions. If you have specific things that you think may not need to be logged to the console, perhaps open a discussion about it or jump on the Discord?
I'm slightly confused as to what you are referring to. Admittedly, I'm not a PowerShell expert, but everything I have learned about PowerShell writing package automation scripts (like |
Beta Was this translation helpful? Give feedback.
-
As there is no specific issue here, I've converted this to a discussion. |
Beta Was this translation helpful? Give feedback.
-
Good evening
What You Are Seeing?
Chocolatey explains in the docs functions for Variables like
$Env:ChocolateyForce
:Actually, choco 1.1.0 behaves like this 😞:
$Env:ChocolateyForce
is set to$True
$Env:ChocolateyForce
is$Null
😢What is Expected?
Please, follow the PowerShell module developers' basics and treat the ChocolateyForce variable like the common switch parameter:
$Env:ChocolateyForce
is set to$True
$Env:ChocolateyForce
should be set to$False
A second, very general suggestion:
Please, please, always follow the PowerShell recommendations for module developers.
For example, choco also constantly displays a lot of information that is normally only displayed in PowerShell when -verbose is activated.
It would make Chocolatey look much more professional if package installations did not produce dozens of lines of output when everything is OK, but simply listed the packages.
If Chocolatey doesn't stick to the really very good guidelines, then it doesn't make Choco cool, it harms the product:
We are surprised and quite disappointed that Chocolatey uses PowerShell as a foundation, but that Chocolatey behaves very often different than the PowerShell basics recommends for module developers 😢
The consequence is three times fatal:
How Did You Get This To Happen? (Steps to Reproduce)
Just use
$Env:ChocolateyForce
in your Code like any other[Switch]
Parameter. You'll get Exceptions because$Env:ChocolateyForce
can be$null
, too 😞System Details
ERROR: Cannot convert value "" to type "System.Boolean". Boolean parameters accept only Boolean values and numbers, such as $True, $False, 1 or 0.
The install of app-chrome-tom was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\…\tools\ChocolateyInstall.ps1'.
See log for details.
Beta Was this translation helpful? Give feedback.
All reactions