You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
When I ran this resource on a server that was freshly built I was seeing errors about invalid paths.
I looked at the code and traced the problem to the functions Get-ChocoInstalledPackage and Get-ChocoVersion.
The problem was caused by the environment variable $env:ChocolateyInstall being null.
I could retrieve the requried value using [environment]::GetEnvironmentVariable('ChocolateyInstall', 'Machine').
This problem was intermittent. I think it depended on the order that DSC ran the resources, as several steps caused the server I was building to reboot. I think a reboot after installing Chocolatey avoids this issue.
What is Expected?
The code should check if the environment variables haven't been initialised yet and update them if they haven't.
Adding this to the start of both functions resolves the problem.
if ([string]::IsNullOrEmpty($env:ChocolateyInstall))
{
$env:ChocolateyInstall= [environment]::GetEnvironmentVariable('ChocolateyInstall','Machine')
}
How Did You Get This To Happen?
This problem happened when installing Chocolatey and then trying to install a package immediately afterwards.
Checklist
What You Are Seeing?
When I ran this resource on a server that was freshly built I was seeing errors about invalid paths.
I looked at the code and traced the problem to the functions Get-ChocoInstalledPackage and Get-ChocoVersion.
The problem was caused by the environment variable $env:ChocolateyInstall being null.
I could retrieve the requried value using [environment]::GetEnvironmentVariable('ChocolateyInstall', 'Machine').
This problem was intermittent. I think it depended on the order that DSC ran the resources, as several steps caused the server I was building to reboot. I think a reboot after installing Chocolatey avoids this issue.
What is Expected?
The code should check if the environment variables haven't been initialised yet and update them if they haven't.
Adding this to the start of both functions resolves the problem.
How Did You Get This To Happen?
This problem happened when installing Chocolatey and then trying to install a package immediately afterwards.
System Details
Installed Packages
Output Log
Additional Context
No response
The text was updated successfully, but these errors were encountered: