microsoft / vcpkg

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

Cannot load status db when filesystem is readonly #10812

Open linquize opened 4 years ago

linquize commented 4 years ago

Describe the bug

Cannot load status db when filesystem is readonly

vcpkg list
error writing file: C:\vcpkg\installed\vcpkg\status-new: The data is invalid.

Environment

To Reproduce Steps to reproduce the behavior:

  1. Perform vcpkg operation in a writable filesystem
  2. vcpkg install zlib
  3. Make filesystem readonly (you may also deny NTFS write permission)
  4. vcpkg list
  5. Error occur

Expected behavior No error. zlib:x64-windows 1.2.11-6 A compression library

Additional context If C:\vcpkg\installed\vcpkg\status is written immediately before vcpkg install exits, instead of lazy write on subsequent load, it won't fail on a readonly filesystem.

vcpkg update and vcpkg upgrade also fail.

If you run vcpkg list once then make readonly, subsequent vcpkg list will succeed.

JackBoosY commented 4 years ago

@ras0219-msft @dan-shaw Since this scene is too harsh, do we need to consider fixing this issue?

strega-nil commented 3 years ago

This is a vcpkg bug, but we'll need to fix other issues.

ras0219 commented 3 years ago

This is by design but could use improvement. Vcpkg probably should compact the database on exit in addition to on startup.

A workaround could be to issue a list command before making the filesystem read only. This will cause vcpkg to consolidate the DB, which should remove the need for future writes.

See https://github.com/microsoft/vcpkg/issues/13097#issuecomment-763131958.