vcpkg binary caching miss: slow rebuild every run in CI
vcpkg builds ports from source and only skips the build when a matching binary is in a cache. With no persisted binary cache, every CI run recompiles every dependency, so builds are slow but do not error. The fix is to enable and persist binary caching.
What this error means
vcpkg install spends many minutes "Building X" on every run for dependencies that never changed. Logs show no "Restored" or cache hit lines.
Building openssl:x64-linux...
Building boost-system:x64-linux...
Building curl:x64-linux...
-- Installing ... (0 restored from cache)Common causes
No binary cache is configured
vcpkg defaults to a local cache under the home directory, which is empty on a fresh runner, so every port builds from source.
The cache is not persisted between runs
Even with a local cache, if the directory is not saved and restored across jobs, each run starts cold.
How to fix it
Use the GitHub Actions binary cache
Point vcpkg at the Actions cache so built binaries persist across runs.
env:
VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite'
# and enable the GHA cache backend in the setup stepCache the binary directory yourself
Restore and save the vcpkg binary cache path with actions/cache keyed on the manifest and baseline.
- uses: actions/cache@v4
with:
path: ~/.cache/vcpkg/archives
key: vcpkg-${{ hashFiles('vcpkg.json') }}How to prevent it
- Enable a persisted vcpkg binary cache in every CI job.
- Key the cache on the manifest and baseline so it invalidates correctly.
- Pin the vcpkg baseline so cache keys stay stable between runs.