Closed josesos closed 6 months ago
Hi @josesos thanks for reporting the issue.
Can I please confirm/ check some additional information about your environment:
PSRULE_AZURE_BICEP_PATH
environment variable by outputting the variable with $Env:PSRULE_AZURE_BICEP_PATH
is as expected.
If a similar exception is still generated, create a convention for debugging to do this:
Assert-PSRule
create a new sub-directory named .ps-rule
.Debug.Rule.ps1
, the final path .ps-rule/Debug.Rule.ps1
.Export-PSRuleConvention 'DebugBicepCLI' -Initialize {
Write-Host "PSRULE_AZURE_BICEP_PATH=$($Env:PSRULE_AZURE_BICEP_PATH)"
Write-Host "Bicep CLI PATH=$((Get-ChildItem -Path $Env:PSRULE_AZURE_BICEP_PATH | Select-Object -First 1).FullName)"
Write-Host "Bicep CLI version=$(& $Env:PSRULE_AZURE_BICEP_PATH --version)"
}
Add -Convention DebugBicepCLI
to your command line. For example:
Assert-PSRule -InputPath . -Convention DebugBicepCLI
The convention should dump the result of these variables for verification.
For clarification the PSRULE_AZURE_BICEP_PATH
environment variable should point to the .exe
file for example C:\Users\user-abc\.Azure\bin\bicep.exe
Thank you!
Using the Debug Rules helped me solve the issue!
For reasons I don't understand setting the env variable to "%USERPROFILE%.Azure\bin\bicep.exe" was making Bicep CLI path be returned as "C:\Users\xxxxxxx\source\repos\LearningLab\MLE.Lab\src\MLE.Web.API.AzureResources\Bicep\%USERPROFILE%.Azure\bin\bicep.exe", which is not where the bicep exe is. It obviously doesn't exist. :)
I kept changing the env variable to explicitely use address with no USERPROFILE variable, and kept updating the variable and restarting PowerShell until it too. It is working now.
Thank you!
Hi @josesos. No worries. It sounds like the problem is solved and it was related to an environment specific issue.
As a result, I will proceed to close the issue. If that it not correct, please let me know.
[like] Jose Sosa reacted to your message:
From: Bernie White @.> Sent: Monday, May 20, 2024 11:17:45 PM To: Azure/PSRule.Rules.Azure @.> Cc: Jose Sosa @.>; Mention @.> Subject: Re: [Azure/PSRule.Rules.Azure] [BUG] Bicep CLI Cannot be found, even though I added bicep.exe to Env Variable. (Issue #2873)
Hi @josesoshttps://github.com/josesos. No worries. It sounds like the problem is solved and it was related to an environment specific issue.
As a result, I will proceed to close the issue. If that it not correct, please let me know.
— Reply to this email directly, view it on GitHubhttps://github.com/Azure/PSRule.Rules.Azure/issues/2873#issuecomment-2121373277, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BDMAHFYTMW5DZZ6HRHJF4RTZDKABTAVCNFSM6AAAAABH64AK5SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRRGM3TGMRXG4. You are receiving this because you were mentioned.Message ID: @.***>
Existing rule
No response
Description of the issue
I'm running PSRule.Azure locally. When I do, I get an error: "Bicep CLI can not be found. Consider installing Bicep or setting the PSRULE_AZURE_BICEP_PATH environment variable to resolve this issue."
I have already added the bicep.exe directory to PSRULE_AZURE_BICEP_PATH but it did not work. I have tried adding bicep to the PATH, but that did not work either.
The interesting thing is that it was working 12 hours ago. I tried today, without making any changes to my setup or configuration and it just did not work.
Error messages
ERROR Exception calling "GetBicepVersion" with "1" argument(s): "Bicep CLI can not be found. Consider installing Bicep or setting the PSRULE_AZURE_BICEP_PATH environment variable to resolve this issue." ERROR Failed to expand bicep source 'C:\Users\josesos\source\repos\LearningLab\MLE.Lab\src\MLE.Web.API.AzureResources\Bicep\Parameters\StorageAccount.bicepparam'. Exception calling "GetBicepParamResources" with "2" argument(s): "Object reference not set to an instance of an object."
Reproduction
I followed these instructions:
Got error
Version of PSRule
2.9.0
Version of PSRule for Azure
1.36.0
Additional context
Bicep CLI version: 0.27.1