-
Notifications
You must be signed in to change notification settings - Fork 909
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
Ensure .arguments files that cannot be decrypted do not prevent running Chocolatey CLI commands #3503
Comments
#2354 an deferred issue related to this issue |
@Git-North are you using, or have you used, any authenticated Chocolatey repository, where you were required to enter username/password, or certificate/password information? Or are you just using the default Chocolatey Community Repository? Or perhaps, you have had to set proxy information, in order to use Chocolatey CLI? The reason that I ask is that this error seems to be related to an attempt to decrypt a value that is stored in the chocolatey.config file, so I am curious as to what might have happened to get this file into a state where it can't be read correctly. |
I've never used anything other then the default repository and was never asked to authenticate to anything, and never did. Regarding the proxy, I never used any chocolatey specific proxy. Only system wide and it is currently disabled |
I don't know if any package could have done this though. If it can I'm unaware |
Okay, thank you for the information. Part of the reason that I wanted to ask that, is due to the fact that it would be good to see the contents/format of the chocolatey.config file. However, this file can contain sensitive information, and not something that should be routinely shared with anyone. If you were willing, if would be good to get a copy of the chocolatey.config file, and also the backup file, if it exists, from the Seeing this file, and attempting to use it locally might help understand what is going on. |
@Git-North please accept my apologies, I misread the stacktrace for the problem that you are having here. The problem is not with the chocolatey.config file, but rather with one of the Can I get you to try something? Can you navigate into the
Assuming that this command runs as expected, you should hopefully see something like this, listed at the bottom of the output: ![]() If that works, it means that the How many packages do you have installed with Chocolatey? In other words, how many folders do you have in the |
Can you also please confirm which commands you are seeing being impacted by this? |
After some internal discussion, the decision has been made that any attempt to decrypt an For example, if/when running However, if running the The commands that are affected by this problem are |
|
after running Processing directory: adb a few times and then starts saying Processing directory: adb
Maximum setlocal recursion level reached.
again and again and then at the very bottom it says Processing directory: anaconda3
Processing directory: adb
Processing directory: adb after that the terminal closes |
@Git-North that seems very strange to me! (I will need to look into that specific issue, as I don't know if that is related). Can you try the command I gave you with some other packages that you have installed? Do they have the same results? |
Would it be possible for you to show a screenshot of this happening? So far, I am not able to replicate this happening. Can you also confirm what terminal you are using? Are you using Command Prompt? PowerShell? Something else? Also, in a PowerShell session, can you run the following, and provide the output here?
|
I use pwsh 7 and when I don't I use cmd with clink My main terminal is "microsoft-windows-terminal --pre" but I also get these outputs when I use the default conhost and some automated VBS scripts. I'll provide the other information later today. |
|
Interesting update: trying the info command results in:
error which used to run fine. cant thing of anything that would change this behaviour |
Thank you for confirming. This rules out another problem that I thought could be at play.
Thank you again for confirming.
I think I am getting lost in exactly what is, and what isn't working for you. Initially, you said you were seeing the:
when running Can you confirm if you are now seeing the same:
error when running a single If you can confirm the above is the case, we can move forward with trying to figure out what could be wrong with the |
Yes I was infact seeing a different error message. However when I later tried the same command above I got the |
I've run the following batch file I wrote for this occasion @echo off
setlocal enabledelayedexpansion
REM Set the path to the Chocolatey library folder
set "libPath=C:\ProgramData\chocolatey\lib"
REM Set the path to the output log file
set "logPath=%cd%\logs.txt"
REM Clear the log file if it exists
echo. > "%logPath%"
REM Loop through each folder in the library path
for /d %%F in ("%libPath%\*") do (
set "folderName=%%~nxF"
echo Processing !folderName!...
echo. >> "%logPath%"
echo Folder: !folderName! >> "%logPath%"
choco info !folderName! --local-only >> "%logPath%"
)
echo Done. All information has been logged to %logPath%.
and got the following output |
For the record, this batch file runs |
Hi, did you find a solution? I have the same problem. |
@tfonias74 follow the instructions above to findout which package is causing the issue. |
Thanks. |
You may be able to run If that does not work you will need to uninstall and install the package again. |
I am running into this same error. It happens when I try to install, upgrade, or remove any package, including when I use the Per the above instructions, I have tried running I am unclear how to proceed. Should I be manually removing my entire If it helps, here is a list of my folders in
Lastly, I believe choco itself was upgraded on this machine today. Unfortunately I can't tell you what version it was at originally, but likely was 2-3 years old. |
We ended up solving it. We deleted the |
I made this batch script for finding faulty .argument files and deleting them @echo off
setlocal enabledelayedexpansion
REM Set the directory of the script
set "scriptDir=%~dp0"
REM Set the path to the Chocolatey library folder
set "libPath=C:\ProgramData\chocolatey\lib"
REM Set the path to the Chocolatey .chocolatey folder
set "chocoRoot=C:\ProgramData\chocolatey\.chocolatey"
REM Set the path to the output log file in the script's directory
set "logPath=%scriptDir%logs.txt"
REM Set the path to the error log file in the script's directory
set "errorLogPath=%scriptDir%error_logs.txt"
REM Clear the log files if they exist
echo. > "%logPath%"
echo. > "%errorLogPath%"
REM Loop through each folder in the library path
for /d %%F in ("%libPath%\*") do (
set "folderName=%%~nxF"
echo Processing !folderName!...
echo. >> "%logPath%"
echo Folder: !folderName! >> "%logPath%"
REM Get the output of the choco info command
choco info !folderName! --local-only > "%scriptDir%temp_output.txt" 2>&1
REM Log the entire output
type "%scriptDir%temp_output.txt" >> "%logPath%"
REM Check for the specific error message in the output file
findstr /c:"Key not valid for use in specified state." "%scriptDir%temp_output.txt" >nul
if !errorlevel! equ 0 (
echo !folderName! >> "%errorLogPath%"
echo Error: "Key not valid for use in specified state." found for !folderName!
REM Delete the .arguments file for the package
if exist "%chocoRoot%\!folderName!\.arguments" (
del "%chocoRoot%\!folderName!\.arguments"
echo Deleted .arguments file for !folderName! >> "%logPath%"
) else (
echo .arguments file not found for !folderName! >> "%logPath%"
)
)
REM Delete the temporary output file
del "%scriptDir%temp_output.txt"
)
echo Done. All information has been logged to %logPath%.
echo Packages with the error have been logged to %errorLogPath%. |
Currently we are decrypting the arguments file every time a list is run, even though we only care about them in scenarios where we might output them to the user (when Verbose is specified on the list command or with the info --local-only command). This updates the handling of the remembered arguments to be consistent between the List method and the scenario in an Upgrade where we want to use the remembered arguments. We now will only throw an error in a scenario where we can't decrypt the contents and we need them for the scenario to succeed. We are also stating what file we couldn't decrypt so the user can troubleshoot.
Currently we are decrypting the arguments file every time a list is run, even though we only care about them in scenarios where we might output them to the user (when Verbose is specified on the list command or with the info --local-only command). This updates the handling of the remembered arguments to be consistent between the List method and the scenario in an Upgrade where we want to use the remembered arguments. We now will only throw an error in a scenario where we can't decrypt the contents and we need them for the scenario to succeed. We are also stating what file we couldn't decrypt so the user can troubleshoot.
Add some Pester tests for the arguments file decryption handling. Ensuring that both invalid keys and base64 corruption works correctly.
Currently we are decrypting the arguments file every time a list is run, even though we only care about them in scenarios where we might output them to the user (when Verbose is specified on the list command or with the info --local-only command). This updates the handling of the remembered arguments to be consistent between the List method and the scenario in an Upgrade where we want to use the remembered arguments. We now will only throw an error in a scenario where we can't decrypt the contents and we need them for the scenario to succeed. We are also stating what file we couldn't decrypt so the user can troubleshoot.
Add some Pester tests for the arguments file decryption handling. Ensuring that both invalid keys and base64 corruption works correctly.
Currently we are decrypting the arguments file every time a list is run, even though we only care about them in scenarios where we might output them to the user (when Verbose is specified on the list command or with the info --local-only command). This updates the handling of the remembered arguments to be consistent between the List method and the scenario in an Upgrade where we want to use the remembered arguments. We now will only throw an error in a scenario where we can't decrypt the contents and we need them for the scenario to succeed. We are also stating what file we couldn't decrypt so the user can troubleshoot.
Add some Pester tests for the arguments file decryption handling. Ensuring that both invalid keys and base64 corruption works correctly.
- Use OrdinalIgnoreCase for command name comparison. - Log with Warn or Error where appropriate and emit to log file only as needed. - Use explicitly named parameters instead of true/false. - Remove comment that's no longer valid.
- Use OrdinalIgnoreCase for command name comparison. - Log with Warn or Error where appropriate and emit to log file only as needed. - Use explicitly named parameters instead of true/false. - Remove comment that's no longer valid.
- Use OrdinalIgnoreCase for command name comparison. - Use explicitly named parameters instead of true/false. - Remove comment that's no longer valid.
Currently we are decrypting the arguments file every time a list is run, even though we only care about them in scenarios where we might output them to the user (when Verbose is specified on the list command or with the info --local-only command). This updates the handling of the remembered arguments to be consistent between the List method and the scenario in an Upgrade where we want to use the remembered arguments. We now will only throw an error in a scenario where we can't decrypt the contents and we need them for the scenario to succeed. We are also stating what file we couldn't decrypt so the user can troubleshoot.
Add some Pester tests for the arguments file decryption handling. Ensuring that both invalid keys and base64 corruption works correctly.
- Use OrdinalIgnoreCase for command name comparison. - Use explicitly named parameters instead of true/false. - Remove comment that's no longer valid.
The CommandName is null when the list method is called during alternate source commands.
The CommandName is null when the list method is called during alternate source commands.
🎉 This issue has been resolved in version 2.4.0 🎉 The release is available on: |
Checklist
What You Are Seeing?
most commands give the following error:
Key not valid for use in specified state.
What is Expected?
For the command to run like normal
For example when run choco list: I get the following output:
Instead of it listing the program list.
How Did You Get This To Happen?
I Cannot recall any action I have made recently that would cause this.
System Details
Installed Packages
Output Log
https://gist.github.com/Git-North/a2726d51475f267e15bab8d716781169
Additional Context
I have refreshed my crypto folder under %appdata% as google recommended however no luck with that too
@gep13 added...
See the comment here on a decision that was reached on how to proceed with this problem.
The text was updated successfully, but these errors were encountered: