Skip to content

[registries] Fix git registry path#20

Closed
klalumiere wants to merge 1 commit intomicrosoft:mainfrom
klalumiere:main
Closed

[registries] Fix git registry path#20
klalumiere wants to merge 1 commit intomicrosoft:mainfrom
klalumiere:main

Conversation

@klalumiere
Copy link
Contributor

Summary

Right now, when using a git registry, the path searched for a port CONTROL or vcpkg.json file is, for instance, $HOME/.cache/vcpkg/registries/git-trees/SHA/. I think the path searched should at least include the port name, that is, at least be $HOME/.cache/vcpkg/registries/git-trees/SHA/PORT_NAME/. Otherwise, each registry could only have a single port. That being said, it could be a good idea to have the same default layout than the official vcpkg repository, that is, search in the directory $HOME/.cache/vcpkg/registries/git-trees/SHA/ports/PORT_NAME/. This is what I implement here.

I understand from the specifications that the ports part of the path will be configurable in vcpkg-configuration.json at some point via the path: attribute. What I implement here is a default behavior that will allow to start using git registries immediately.

Reproduction

Related repositories:
https://github.com/klalumiere/toyprojectvcpkg
https://github.com/klalumiere/vcpkg-overlays

export VCPKG_FEATURE_FLAGS=manifests,registries,versions
export VCPKG_ROOT=PATH_OF_VCPKG
git clone https://github.com/klalumiere/toyprojectvcpkg
cd toyprojectvcpkg
mkdir debug
cd debug
cmake -G Ninja ..

without my fix, this fails with a message

[DEBUG] cmd_execute_and_stream_data() returned 0 after     2871 us
Error: while loading 49fdf3529f1a0bd69c6ef113929bd534e6b89d55:
Failed to find either a CONTROL file or vcpkg.json file.
Error: Failed to load port personaldependency from /home/klalumiere/.cache/vcpkg/registries/git-trees/49fdf3529f1a0bd69c6ef113929bd534e6b89d55
Note: Updating vcpkg by rerunning bootstrap-vcpkg may resolve this failure.
[DEBUG] /home/klalumiere/Projects/vcpkg/buildtrees/_vcpkg/src/vcpkg-tool-2021-02-24-d67989bce1043b98092ac45996a8230a059a2d7e/src/vcpkg/portfileprovider.cpp(188)

Listing the directory /home/klalumiere/.cache/vcpkg/registries/git-trees/49fdf3529f1a0bd69c6ef113929bd534e6b89d55 confirmes that it contains both personaldependency/vcpkg.json and ports/personaldependency/vcpkg.json.

With my fix, the example above works fine.

@ras0219-msft
Copy link
Collaborator

ras0219-msft commented Mar 2, 2021

First, thanks for the PR and thanks for trying out registries!

The intent is that the hash is not a commit id, but rather a git tree:

C:\src\vcpkg> git rev-parse HEAD
4d91d5c8b10cfe46f38e6badc15f63da6fdf7a3d # Not this one -- this is a commit ID
C:\src\vcpkg> git rev-parse HEAD:ports/tinyxml2
5bc723c583463d1e50ff6dcf0131328759371eeb # This is the right one -- this refers to the tree object
C:\src\vcpkg> git ls-tree 5bc723c583463d1e50ff6dcf0131328759371eeb
100644 blob 3be0a859c7db6f27162c7ee7dd08686c6dbe4d02    CONTROL
100644 blob 8021e0f633ee850334c28e9ea42c69bfc8a5f83b    fix-debug-postfix.patch
100644 blob 7108d054064e6a7516d52018b736a18515768408    fix-symbol-exports.patch
100644 blob d4fb1c3f97f2607bc6b37e21021aad6048bc058b    portfile.cmake

This prevents ports from being duplicated for every registry commit -- instead, they are checked out exactly once per unique content.

@strega-nil to improve docs & tooling around this

@klalumiere
Copy link
Contributor Author

The intent is that the hash is not a commit id, but rather a git tree:

C:\src\vcpkg> git rev-parse HEAD
4d91d5c8b10cfe46f38e6badc15f63da6fdf7a3d # Not this one -- this is a commit ID
C:\src\vcpkg> git rev-parse HEAD:ports/tinyxml2
5bc723c583463d1e50ff6dcf0131328759371eeb # This is the right one -- this refers to the tree object
[...]
This prevents ports from being duplicated for every registry commit -- instead, they are checked out exactly once per unique content.

OMG, I didn't think about that! 😳 😆 Super, thanks! 🙂

@klalumiere klalumiere closed this Mar 2, 2021
vicroms added a commit to vicroms/vcpkg-tool that referenced this pull request Aug 28, 2025
# This is the 1st commit message:

WIP

# The commit message #2 will be skipped:

# Fix build error

# The commit message microsoft#3 will be skipped:

# Implement bulk operation

# The commit message microsoft#4 will be skipped:

# Remove unused struct

# The commit message microsoft#5 will be skipped:

# Follow redirects

# The commit message microsoft#6 will be skipped:

# Get HTTP response code

# The commit message microsoft#7 will be skipped:

# Map URL response code to the correct index

# The commit message microsoft#8 will be skipped:

# Map URL response code to the correct index

# The commit message microsoft#9 will be skipped:

# Undo changes to workflows

# The commit message microsoft#10 will be skipped:

# Implement store to asset cache

# The commit message microsoft#11 will be skipped:

# handle file:// protocol

# The commit message microsoft#12 will be skipped:

# Implement try_download_file

# The commit message microsoft#13 will be skipped:

# Add missing calls to curl_easy_cleanup

# The commit message microsoft#14 will be skipped:

# Fix global init

# The commit message microsoft#15 will be skipped:

# Replace all calls in downloads.cpp and fix unit tests

# The commit message microsoft#16 will be skipped:

# use libcurl to submit metrics payload

# The commit message microsoft#17 will be skipped:

# Use Schannel on Windows

# The commit message microsoft#18 will be skipped:

# Apply suggestions from code review
#
# Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

# The commit message microsoft#19 will be skipped:

# Fix unit test

# The commit message microsoft#20 will be skipped:

# Change curl error messages

# The commit message microsoft#21 will be skipped:

# generate message map

# The commit message microsoft#22 will be skipped:

# Always call multi_remove_handle

# The commit message microsoft#23 will be skipped:

# Fix end-to-end tests

# The commit message microsoft#24 will be skipped:

# Cleanup header lists

# The commit message microsoft#25 will be skipped:

# curl global init order

# The commit message microsoft#26 will be skipped:

# Use external libcurl on non-Windows

# The commit message microsoft#27 will be skipped:

# Install libcurl4 dev package on Linux

# The commit message microsoft#28 will be skipped:

# Disable metrics by default in debug builds

# The commit message microsoft#29 will be skipped:

# Set user agent using CURLOPT_USERAGENT

# The commit message microsoft#30 will be skipped:

# curl initialization again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants