Skip to content

vcpkg fetch fails with ninja #50051

@Erik-White

Description

@Erik-White

Describe the bug
Since the implementation of vcpkg fetch, builds are failing when attempting to use ninja:

Extracting cmake...
Detecting compiler hash for triplet x64-linux...
error: while detecting compiler information:
The log file content at "/src/vcpkg/buildtrees/detect_compiler/stdout-x64-linux.log" is:
CMake Error at scripts/cmake/vcpkg_execute_in_download_mode.cmake:29 (execute_process):
  execute_process failed command indexes:

    1: "Child return code: 1"

Call Stack (most recent call first):
  scripts/cmake/vcpkg_execute_in_download_mode.cmake:29 (cmake_language)
  scripts/cmake/vcpkg_find_acquire_program.cmake:110 (vcpkg_execute_in_download_mode)
  scripts/cmake/vcpkg_find_acquire_program(NINJA).cmake:1 (z_use_vcpkg_fetch)
  scripts/cmake/vcpkg_find_acquire_program.cmake:144 (include)
  scripts/cmake/vcpkg_configure_cmake.cmake:150 (vcpkg_find_acquire_program)
  scripts/detect_compiler/portfile.cmake:18 (vcpkg_configure_cmake)
  scripts/ports.cmake:206 (include)

I think this is happening because ninja is writing to stderr waiting to take filesystem lock, then the --x-stderr-status flag makes vcpkg return exit 1 on ANY stderr output

Environment

  • OS: ubuntu:24.04
  • Compiler: cmake v3.31.10, gcc 13.2.0

To Reproduce
Dockerfile:

FROM ubuntu:24.04

# Install minimal dependencies
RUN apt update && apt install -y \
    git wget build-essential curl zip unzip tar \
    nasm pkg-config python3 \
    gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64

WORKDIR /src

RUN git clone https://github.com/microsoft/vcpkg vcpkg && \
    cd vcpkg && \
    git checkout e5a1490e1409d175932ef6014519e9ae149ddb7c && \
    cd ..
RUN ./vcpkg/bootstrap-vcpkg.sh

COPY vcpkg.json .

CMD ["bash"]

Manifest vcpkg.json (the particular port doesn't matter, just something that requires ninja):

{
  "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
  "dependencies": [
    {
      "name": "dav1d",
      "platform": "x64 & windows"
    }
  ],
  "builtin-baseline": "e5a1490e1409d175932ef6014519e9ae149ddb7c"
}

Build script build.ps1:

#!/usr/bin/env pwsh

$ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true

Set-Location -LiteralPath $PSScriptRoot

$container_name = "vcpkg-repro"

docker rm -f $container_name 2>$null
docker build -t vcpkg-repro .
docker run -dit --name $container_name vcpkg-repro

docker exec -it $container_name vcpkg/vcpkg install --triplet="x64-mingw-dynamic" --vcpkg-root="vcpkg" --x-manifest-root=""

Expected behavior
cmake can download and use ninja when required

Failure logs

logs.txt
stdout-x64-linux.log

Additional context
The same error does not occur with x64-linux-dynamic
This may be a duplicate of #49549, but I found that quite difficult to follow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions