microsoft / vcpkg

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

Asset caching using a script does not work #38842

Open jonathanverner opened 3 months ago

jonathanverner commented 3 months ago

Describe the bug When trying to use the asset caching tweaking e.g. the instructions from Creating a x-script Asset Caching source for NuGet to my usecase (using a python script), vcpkg fails when trying to execute the script.

On Windows, I just get

Downloading 7zip...
https://github.com/ip7z/7zip/releases/download/23.01/7z2301-extra.7z->C:\tools\vcpkg\downloads\7z2301-extra.7z
error: Failed to download from mirror set
error: Launching <mirror-script>: error: calling CreateProcessW failed with 2 (The system cannot find the file specified.)
linux I get a more verbose output, the relevant part of which:

on Linux the message is slightly more verbose

[DEBUG] 1000: execute_process( "/usr/bin/python3 /builds/team-b/crescendomd/tools/nexus/cache_vcpkg_assets.py https://github.com/catchorg/Catch2/archive/v3.3.2.tar.gz 3d0c5666509a19be54ea0c48a3c8e1c4a951a2d991a7c9f7fe6d326661464538f1ab9dc573b1b2647f49fb6bef45bbd866142a4ce0fba38545ad182b8d55f61f /tools/vcpkg/downloads/catchorg-Catch2-v3.3.2.tar.gz.263.part")
sh: 1: /usr/bin/python3 /builds/team-b/crescendomd/tools/nexus/cache_vcpkg_assets.py https://github.com/catchorg/Catch2/archive/v3.3.2.tar.gz 3d0c5666509a19be54ea0c48a3c8e1c4a951a2d991a7c9f7fe6d326661464538f1ab9dc573b1b2647f49fb6bef45bbd866142a4ce0fba38545ad182b8d55f61f /tools/vcpkg/downloads/catchorg-Catch2-v3.3.2.tar.gz.263.part: not found
[DEBUG] 1000: cmd_execute_and_stream_data() returned 127 after      808 us
error: Failed to download from mirror set
error: <mirror-script> failed with exit code: (127).
sh: 1: /usr/bin/python3 /builds/team-b/crescendomd/tools/nexus/cache_vcpkg_assets.py https://github.com/catchorg/Catch2/archive/v3.3.2.tar.gz 3d0c5666509a19be54ea0c48a3c8e1c4a951a2d991a7c9f7fe6d326661464538f1ab9dc573b1b2647f49fb6bef45bbd866142a4ce0fba38545ad182b8d55f61f /tools/vcpkg/downloads/catchorg-Catch2-v3.3.2.tar.gz.263.part: not found
[DEBUG] /mnt/vss/_work/1/s/src/vcpkg/base/downloads.cpp(1029): 

Note that the variable X_VCPKG_ASSET_SOURCES is set to

x-script,C:/Python311/python.exe C:\builds\team-b\crescendomd/tools/nexus/cache_vcpkg_assets.py {url} {sha512} {dst};x-block-origin

As far as I can tell, it seems that vcpkg takes the X_VCPKG_ASSET_SOURCES variable, replaces the placeholders with data and passes the result directly to CreateProcessW or sh as a single argument. So, e.g., sh tries looking for an executable called /usr/bin/python3 /builds/team-b/crescendomd/tools/nexus/cache_vcpkg_assets.py https://github.com/catchorg/Catch2/archive/v3.3.2.tar.gz 3d0c5666509a19be54ea0c48a3c8e1c4a951a2d991a7c9f7fe6d326661464538f1ab9dc573b1b2647f49fb6bef45bbd866142a4ce0fba38545ad182b8d55f61f /tools/vcpkg/downloads/catchorg-Catch2-v3.3.2.tar.gz.263.part instead of looking for /usr/bin/python3 and passing the rest as commandline arguments.

This will obviously fail with file not found error.

jonathanverner commented 3 months ago

I can easily reproduce it on version 2024-01-12. The issue seems to be fixed on master.

github-actions[bot] commented 3 months ago

This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 28 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.