Skip to content
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

Attempting to upgrade multiple packages at once causes an error to be thrown about configuration backups #2884

Closed
adrianmace opened this issue Nov 4, 2022 · 6 comments
Labels
5 - Released Bug IN REGRESSION TEST SUITE These are things that are handled by tools like Test-Kitchen
Milestone

Comments

@adrianmace
Copy link

What You Are Seeing?

When attempting to call choco upgrade -y sql-server-management-studio I receive the following error in the logs:

2022-11-04 03:19:32,140 4344 [DEBUG] - Attempting to create directory "C:\ProgramData\chocolatey\.chocolatey\sql-server-management-studio.15.0.18424.0".
2022-11-04 03:19:32,156 4344 [DEBUG] - There was no original file at 'C:\ProgramData\chocolatey\.chocolatey\sql-server-management-studio.15.0.18424.0\.registry'
2022-11-04 03:19:32,156 4344 [DEBUG] - There was no original file at 'C:\ProgramData\chocolatey\.chocolatey\sql-server-management-studio.15.0.18424.0\.files'
2022-11-04 03:19:32,172 4344 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\sql-server-management-studio.15.0.18424.0\.extra".
2022-11-04 03:19:32,172 4344 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\sql-server-management-studio.15.0.18424.0\.version".
2022-11-04 03:19:32,172 4344 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\sql-server-management-studio.15.0.18424.0\.sxs".
2022-11-04 03:19:32,172 4344 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\sql-server-management-studio.15.0.18424.0\.pin".
2022-11-04 03:19:32,172 4344 [DEBUG] - Sending message 'HandlePackageResultCompletedMessage' out if there are subscribers...
2022-11-04 03:19:32,172 4344 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\lib\sql-server-management-studio\.chocolateyPending".
2022-11-04 03:19:32,172 4344 [INFO ] -  The upgrade of sql-server-management-studio was successful.
2022-11-04 03:19:32,172 4344 [INFO ] -   Software installed to 'C:\Program Files\Azure Data Studio\'
2022-11-04 03:19:32,172 4344 [DEBUG] - Attempting to delete file "C:\Users\Administrator\AppData\Local\NuGet\Cache\sql-server-management-studio.15.0.18424.0.nupkg".
2022-11-04 03:19:32,187 4344 [WARN ] - 
Chocolatey upgraded 0/0 packages. 
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
2022-11-04 03:19:32,187 4344 [DEBUG] - Sending message 'PostRunMessage' out if there are subscribers...
2022-11-04 03:19:32,218 4344 [ERROR] - No backup has been created before trying to reset the current configuration, and removal of the backup was not requested.
2022-11-04 03:19:32,218 4344 [ERROR] - More Details: System.InvalidOperationException: No backup has been created before trying to reset the current configuration, and removal of the backup was not requested.
   at chocolatey.infrastructure.app.configuration.ChocolateyConfiguration.reset_config(Boolean removeBackup)
   at chocolatey.infrastructure.app.services.NugetService.upgrade_run(ChocolateyConfiguration config, Action`1 continueAction, Boolean performAction, Action`1 beforeUpgradeAction)
   at chocolatey.infrastructure.app.services.NugetService.upgrade_run(ChocolateyConfiguration config, Action`1 continueAction, Action`1 beforeUpgradeAction)
   at chocolatey.infrastructure.app.services.ChocolateyPackageService.perform_source_runner_function[T](ChocolateyConfiguration config, Func`2 function)
   at chocolatey.infrastructure.app.services.ChocolateyPackageService.upgrade_run(ChocolateyConfiguration config)
   at chocolatey.infrastructure.app.runners.GenericRunner.run(ChocolateyConfiguration config, Container container, Boolean isConsole, Action`1 parseArgs)
   at chocolatey.infrastructure.app.runners.ConsoleApplication.run(String[] args, ChocolateyConfiguration config, Container container)
   at chocolatey.console.Program.Main(String[] args)
2022-11-04 03:19:32,218 4344 [DEBUG] - Exiting with 1

What is Expected?

Not that.

How Did You Get This To Happen? (Steps to Reproduce)

As described above.

System Details

  • OS Build (In PowerShell run [System.Environment]::OSVersion.version.tostring()): 10.0.17763.0
  • Windows PowerShell version (Run: $PSVersionTable):
    Name Value

PSVersion 5.1.17763.2931
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.2931
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

  • Chocolatey version (Run choco --version): 1.2.0

Output Log

As described above.

@adrianmace
Copy link
Author

Further context, seems to be hitting this code path somehow.

/// <exception cref="InvalidOperationException">No backup has been created before trying to reset the current configuration, and removal of the backup was not requested.</exception>

@adrianmace
Copy link
Author

adrianmace commented Nov 4, 2022

Further information, this seems to be repeatable if I run choco upgrade awscli sql-server-management-studio where both are not installed previously.

@TheCakeIsNaOH
Copy link
Member

Further information, this seems to be repeatable if I run choco upgrade awscli sql-server-management-studio where both are not installed previously.

Thanks for figuring that out.
I can also reproduce this by uninstalling curl and wget, then running choco upgrade curl wget. Or by uninstalling curl (keeping wget installed), then running choco upgrade curl wget -f.

Running choco upgrade curl when curl is not installed does not trigger this bug for me, nor does choco upgrade curl wget -f with curl installed and wget not installed.

@pauby
Copy link
Member

pauby commented Nov 4, 2022

Also confirmed this issue:

PS C:\Users\WDAGUtilityAccount> choco upgrade curl wget
Chocolatey v1.2.0
Upgrading the following packages:
curl;wget
By upgrading, you accept licenses for the packages.
curl is not installed. Installing...
Progress: Downloading curl 7.86.0... 100%
Progress: Downloading curl 7.86.0... 100%

curl v7.86.0 [Approved]
curl package files upgrade completed. Performing other installation steps.
Extracting 64-bit C:\ProgramData\chocolatey\lib\curl\tools\curl-7.86.0-win64-mingw.zip to C:\ProgramData\chocolatey\lib\curl\tools...
C:\ProgramData\chocolatey\lib\curl\tools
 ShimGen has successfully created a shim for curl.exe
 The upgrade of curl was successful.
  Software installed to 'C:\ProgramData\chocolatey\lib\curl\tools'

Chocolatey upgraded 0/0 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
No backup has been created before trying to reset the current configuration, and removal of the backup was not requested.

@pauby pauby added this to the 1.2.1 milestone Nov 4, 2022
vexx32 added a commit to vexx32/choco that referenced this issue Nov 23, 2022
In some cases, code paths may attempt to take or restore multiple config
backups. Previously, this would always result in an error.

With this change, as long as the code paths correctly use start_backup
and reset_config, nested levels of backups will work correctly instead
of unpredictably interfering with each other.
vexx32 added a commit to vexx32/choco that referenced this issue Nov 23, 2022
In some cases, code paths may attempt to take or restore multiple config
backups. Previously, this would always result in an error.

With this change, as long as the code paths correctly use start_backup
and reset_config, nested levels of backups will work correctly instead
of unpredictably interfering with each other.
@vexx32 vexx32 self-assigned this Nov 23, 2022
vexx32 added a commit to vexx32/choco that referenced this issue Nov 23, 2022
In some cases, code paths may attempt to take or restore multiple config
backups. Previously, this would always result in an error.

With this change, as long as the code paths correctly use start_backup
and reset_config, nested levels of backups will work correctly instead
of unpredictably interfering with each other.
vexx32 added a commit to vexx32/choco that referenced this issue Nov 23, 2022
In some cases, code paths may attempt to take or restore multiple config
backups. Previously, this would always result in an error.

With this change, as long as the code paths correctly use start_backup
and reset_config, nested levels of backups will work correctly instead
of unpredictably interfering with each other.
vexx32 added a commit to vexx32/choco that referenced this issue Nov 28, 2022
In some cases, code paths may attempt to take or restore multiple config
backups. Previously, this would always result in an error.

With this change, as long as the code paths correctly use start_backup
and reset_config, nested levels of backups will work correctly instead
of unpredictably interfering with each other.
@vexx32 vexx32 added ADD AUTO TESTS Things that typically go to Test-Kitchen - once completed, IN REGRESSION TEST SUITE label added and removed ADD MANUAL TESTS labels Nov 28, 2022
corbob added a commit that referenced this issue Nov 28, 2022
(#2884) Store configuration backups as a Stack
@vexx32 vexx32 closed this as completed Nov 29, 2022
vexx32 added a commit to vexx32/choco that referenced this issue Dec 5, 2022
In v1.2.0 choco would fall to pieces on being asked to upgrade multiple
packages in a a single command, or when upgrading a package that also
needed to upgrade a dependency. The second package installation would
fail.

This regression test ensures that we can safely `upgrade` multiple
packages at once.
@asheroto
Copy link

asheroto commented Dec 6, 2022

Having this issue as well

vexx32 added a commit to vexx32/choco that referenced this issue Dec 6, 2022
In v1.2.0 choco would fall to pieces on being asked to upgrade multiple
packages in a a single command, or when upgrading a package that also
needed to upgrade a dependency. The second package installation would
fail.

This regression test ensures that we can safely `upgrade` multiple
packages at once.
corbob added a commit that referenced this issue Dec 6, 2022
(#2872, #2884) Add automated regression tests for v1.2.1
@vexx32 vexx32 changed the title No backup has been created before trying to reset the current configuration, and removal of the backup was not requested. Attempting to upgrade multiple packages at once causes an error to be thrown about configuration backups Dec 6, 2022
@choco-bot
Copy link

🎉 This issue has been resolved in version 1.2.1 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

@vexx32 vexx32 added IN REGRESSION TEST SUITE These are things that are handled by tools like Test-Kitchen and removed ADD AUTO TESTS Things that typically go to Test-Kitchen - once completed, IN REGRESSION TEST SUITE label added labels Dec 8, 2022
@vexx32 vexx32 removed their assignment Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Released Bug IN REGRESSION TEST SUITE These are things that are handled by tools like Test-Kitchen
Projects
None yet
Development

No branches or pull requests

7 participants