microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
22.98k stars 6.34k forks source link

Broken upgrade after interrupting #8925

Closed jepessen closed 3 years ago

jepessen commented 4 years ago

When I update vcpkg from the repository, I often perform a vcpkg update --no-dry-run operation in order to upgrade libraries to latest version. When I upgrade libraries with a lot of dependencies, like qt5 or boost, sometimes it happens that I lost the internet connection, so the upgrade fails.

It stops, but if I repeat the command many libraries are not installed anymore.

For example: with the command I upgrade the zmq library; at first step vcpkg deletes all libraries, and then it rebuild again libraries from scratch. If at some point the upgrade is interrupted, for example due to internet connection, before upgrading zmq, If I run the upgrade again zmq is not installed anymore. The result is that after restarting the upgrade the library was uninstalled but not installed, and I need to install it again manually.

It would be nice if vcpkg stores somewhere the list of ports that needs to be upgraded with a vcpkg upgrade, and then remove packages from this list one by one when installed, so even if upgrade is interrupted it can be recovered in a nice way without lose any package.

Environment

To Reproduce

  1. git pull origin master for updating the repository
  2. ./bootstrap-vcpkg.bat
  3. ./vcpkg upgrade --no-dry-run
  4. Interrupt the upgrade after that have deleted ports that needs to be upgraded
  5. ./vpkg upgrade --no-dry-run
  6. After upgrade there can be missing packages

Expected behavior When the upgrade is interrupted and repeated. I expect that vcpkg upgrades all packages without missing anyone.

LucaGanio commented 4 years ago

I had a similar problem after updating from the repository. After the update I forgot to re-run bootstrap-vcpkg but I was advised of this only after running 'vcpkg upgrade --no-dry-run'. After the initial phase when old packages are purged (and lost) I finally get the error telling me that vcpkg needs to be rebuild. This simple check should be done as first thing when vcpkg update/upgrade is invoked. And in any case vcpkg should keep track somehow of the packages that needs to be updated. Possible scenarios could be an error during the download phase, an error during the build phase, an unexpected shutdown of the system, splitting the build process in multiple build sessions...

ghost commented 4 years ago

I've learned to do the following after each refresh of vcpkg:

  1. git pull >.\git-updates.txt >2&1
  2. vcpkg.exe upgrade --dry-run >.\upgrade-list.txt 2>&1
  3. Review both .txt files and if any of the C++ files used by vcpkg are updated or their is a message to run bootstrap again then I run the bootstrap to rebuild vcpkg. I also do it after upgrade Visual Studio if the C++ version changes.
  4. and if the upgrade fails, the upgrade-list.txt file created in step 2 can always serve as a guide to what you need to install that was removed during the upgrade process but not reinstalled due to some error via a .\vcpkg.exe install xxx xxx xxx etc etc etc
OlafvdSpek commented 4 years ago

I put the entire vcpkg install blah line in a vcpkg-install.txt file so all requirements can be easily installed from scratch. That way you don't have to bother with manually keeping track of what goes wrong etc.

ompadu commented 4 years ago

Spotty internet is a very common fault and should be handled gracefully.

The list of packages currently upgrading should be automatically handled by vcpkg and not deferred to the end user.

PhoebeHui commented 3 years ago

Duplicated to https://github.com/microsoft/vcpkg/issues/4360.