vcpkg keeps every build tree it ever made, unless you tell it not to
vcpkg leaves buildtrees, packages and downloads in its root folder after every install. Which are safe to delete on a Mac, and the flag that stops the growth.
A single vcpkg install of something like Boost or Qt can leave several gigabytes behind that nothing ever reads again. vcpkg keeps the extracted sources and intermediate objects of every port it builds, inside the folder you cloned it into.
# VCPKG_ROOT is wherever you cloned vcpkg, often ~/vcpkg
R="${VCPKG_ROOT:-$HOME/vcpkg}"
du -sh "$R"/buildtrees "$R"/packages "$R"/downloads "$R"/installed 2>/dev/null
du -sh ~/.cache/vcpkg/archives 2>/dev/null
find ~ -maxdepth 5 -type d -name vcpkg_installed -prune -exec du -sh {} + 2>/dev/nullWhat each folder is
| Folder | What it holds | Safe to delete? |
|---|---|---|
| buildtrees | Extracted sources and object files from each build | Yes. Usually the largest |
| packages | Staging copy of each port before it is installed | Yes |
| downloads | Source archives and downloaded tools | Yes, they download again when needed |
| installed | The libraries your projects link against (classic mode) | No, unless you reinstall |
| ~/.cache/vcpkg/archives | Binary cache of finished builds | Yes, but the next install rebuilds from source |
Clean up, then stop it growing
rm -rf "$R"/buildtrees "$R"/packages
# From now on, have vcpkg delete its build trees itself
vcpkg install <port> --clean-after-buildIn manifest mode each project gets its own vcpkg_installed folder. It is rebuilt from the binary cache on the next configure, so deleting it in projects you are not working on is safe. Deleting the binary cache is the one choice that costs time, because every port then compiles again.
Other build output that piles up the same way: CMake build folders and ccache and the hidden .cache folder.
Common questions
Is it safe to delete the vcpkg buildtrees folder?
Yes. It holds extracted sources and intermediate object files from past builds. Installed libraries live in the installed folder or in each project's vcpkg_installed folder, which buildtrees does not touch.
How do I stop vcpkg filling buildtrees?
Pass --clean-after-build to vcpkg install. vcpkg then removes the build tree, package folder and downloads for each port once it is installed.
Where is the vcpkg binary cache on a Mac?
By default in ~/.cache/vcpkg/archives. Deleting it is safe, but the next install compiles every port from source again, which can take a long time.