Shallow sync of `vcpkg` breaks versioning
See https://github.com/microsoft/vcpkg/issues/25349
Because this image shallow-clones vcpkg, it's difficult to get versioning working. Specifically, any useful value of builtin-baseline will fail to sync, and packages will subsequently not be found.
I'm working towards a workaround on this, that looks something like:
- During image build, parse
vcpkg.jsonwith a tool like jq to extract the value ofbuiltin-baselinehash. - Derive the commit date of the hash with
git show -s --format=%ci - Sync the image's
vcpkgrepo withgit fetch --shallow-since=<date>
This is the best I can think of - I don't love bringing in a dependency like jq, and it seems bizarre (although possibly intended) to manipulate the vcpkg repository during such a straightforward use case. I'd love to get any feedback on this approach and see if there's a simpler path forward.
Hi 👋
You can run 'git rev-parse HEAD' to get the current commit of vcpkg and set it as the builtin-baseline.
From versioning.getting-started.md, git rev-parse HEAD works on a shallow clone, and can be checked out.
@nickpdemarco Are you specifically looking to use some different commit SHA which is not of HEAD? I am curious about the reasoning behind it. 😄
Also, a though on your workaround, builtin-baseline property doesn't exist in any vcpkg.json. I believe, that property needs to be manually added for using versioning?
https://github.com/search?q=repo%3Amicrosoft%2Fvcpkg%20builtin-baseline&type=code
Hi
I'm also affected by this. The use case is installing dependencies with vcpkg in manifest mode with versioning which is where builtin-baseline comes in. It is basically locking down dependency versions in order to allow reproducible builds similar to what package-lock.json/yarn.lock achieve for nodejs. So the builtin-baseline field doesn't appear in the vcpkg repository itself (as all those ports are part of said baseline), but in vcpkg.jsons of projects using vcpkg to manage their dependencies (eg here). If you try to install project dependencies this way and the referenced vcpkg commit isn't locally available, you will run into the following error:
[cmake] error: while checking out baseline from commit '71d3fa60b67540e9bf5fde2bf2188f579ff09433', failed to `git show` versions/baseline.json. This may be fixed by fetching commits with `git fetch`.
[cmake] error: git failed with exit code: (128).
[cmake] fatal: path 'versions/baseline.json' exists on disk, but not in '71d3fa60b67540e9bf5fde2bf2188f579ff09433'
[cmake]
[cmake] vcpkg was cloned as a shallow repository in: /usr/local/vcpkg/.git
[cmake] Try again with a full vcpkg clone.
I propose to include the last twelve month of vcpkg git history as that should allow the majority of projects to upgrade their dependencies in time.
@samruddhikhandale do you have further questions regarding my last explanation?