[tools] Fix missing executable permission on downloaded tools for Unix #1911
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
On macOS/Linux, tools downloaded by
download_tool()insrc/vcpkg/tools.cppcan lack the executable bit (0644instead of0755), causingPermission denied(exit code 126) when vcpkg immediately attempts to run the tool to determine its version.This affects:
cosclion macOS/Linux always gets0644from HTTP downloadpowershell-core.tar.gzloses execute permission during the extract-to-temp-then-rename processThe PowerShell Core cross-platform tool support was recently introduced in microsoft/vcpkg#49910, adding
powershell-coreentries for macOS and Linux tovcpkg-tools.json. This makes the permission issue more visible, asvcpkg fetch powershell-corenow fails on these platforms without this fix.The CMake-side equivalent (
vcpkg_find_acquire_program.cmake) already handles this correctly viaFILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE ..., but the C++download_tool()path had no such handling.Fix
Add
chmod(exe_path, 0755)beforereturn exe_pathindownload_tool(), covering both the raw-binary and archive code paths in a single call. The helper is gated behind#if !defined(_WIN32)and usesDebug::printlnfor non-fatal failure reporting.Changes are confined to a single file (
src/vcpkg/tools.cpp, +18 lines).Test Results
Tested on macOS arm64 by comparing
vcpkg fetch <tool>between the unpatched and patched binaries after clearing tool caches:0644— Permission denied0755— OK0644— Permission denied0755— OK0755— OK (preserved)0755— OK0755— OK (preserved)0755— OKConsistency
This follows the same "chmod at placement time" pattern used throughout the vcpkg ecosystem:
vcpkg_find_acquire_program.cmake—file(COPY ... FILE_PERMISSIONS OWNER_EXECUTE ...)bootstrap.sh—chmod +xbeforemvapplocal.py—chmod 755after copying dependencies