lukka / run-cmake

GitHub Action to build C++ applications with CMake (CMakePresets.json), Ninja and vcpkg on GitHub.
MIT License
173 stars 19 forks source link

Windows: "The system cannot find the path specified" when using run-cmake and run-vcpkg #54

Closed gracicot closed 2 years ago

gracicot commented 2 years ago

The linux and apple builds works with my configuration, but not the windows one. I'm not sure I understand the error, so I r don't know if it's a bug from run-cmake or a problem in my configurations.

Here' s the error:

► Run lukka/run-cmake@v3
tool: D:\a\_temp\909795809\cmake-3.21.1-windows-x86_64\bin\cmake.exe
tool: D:\a\_temp\909795809\ninja.exe
► Setup environment variables for triplet 'x64-windows' using 'vcpkg env'
⏱ elapsed: 2.161 seconds
Error: get_directories_non_recursive(D:\a\kangaru\kangaru\vcpkg_installed\x64-windows\tools): The system cannot find the path specified.

    at CMakeUtils.<anonymous> (D:\a\_actions\lukka\run-cmake\v3\dist\index.js:4765:27)
    at Generator.next (<anonymous>)
    at fulfilled (D:\a\_actions\lukka\run-cmake\v3\dist\index.js:4717:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: run-cmake action execution failed: 'Error: get_directories_non_recursive(D:\a\kangaru\kangaru\vcpkg_installed\x64-windows\tools): The system cannot find the path specified.

Here's my configuration:


on: [push, pull_request]

jobs:
  build:
    env:
      buildDir: ${{ github.workspace }}/build
    name: ${{ matrix.os }}-hosted-basic
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        include:
          - os: windows-latest
            triplet: x64-windows
            build-type: RelWithDebInfo
          - os: ubuntu-latest
            triplet: x64-linux
            build-type: RelWithDebInfo
          - os: macos-latest
            triplet: x64-osx
            build-type: RelWithDebInfo

    steps:
      - uses: actions/checkout@v2

      - name: get-cmake
        uses: lukka/get-cmake@v3.21.1

      - name: Run vcpkg
        uses: lukka/run-vcpkg@v6
        with:
          # Just install vcpkg for now, do not install any ports in this step yet.
          setupOnly: true
          # Location of the vcpkg as submodule of the repository.
          vcpkgDirectory: '${{ github.workspace }}/vcpkg'
          vcpkgGitCommitId: '57bd7102d9fd880daa1b0958692294c4a125f6d8'
          # Since the cache must be invalidated when content of the vcpkg.json file changes, let's
          # compute its hash and append this to the computed cache's key.
          appendedCacheKey: ${{ hashFiles( '**/vcpkg.json' ) }}
          vcpkgTriplet: ${{ matrix.triplet }}
          # Ensure the vcpkg artifacts are cached, they are generated in the 'CMAKE_BINARY_DIR/vcpkg_installed'.
          additionalCachedPaths: ${{ env.buildDir }}/vcpkg_installed
      - name: 'Run CMake with Ninja, install dependencies with vcpkg, build with CMake'
        uses: lukka/run-cmake@v3
        with:
          cmakeListsOrSettingsJson: CMakeListsTxtBasic
          cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
          useVcpkgToolchainFile: true
          cmakeAppendedArgs: '-GNinja -DKANGARU_TEST=ON'
          buildDirectory: ${{ env.buildDir }}

      - name: Test
        working-directory: ${{github.workspace}}/build
        # Execute tests defined by the CMake configuration.  
        # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
        run: ctest -C ${{env.build-type}}

Here's the live error. As you can see from that page ubuntu and macos are working correctly.

lukka commented 2 years ago

@gracicot could you please enable debug logging and run your workflow again? Both for runner and steps should help to understand the root cause of this problem.

gracicot commented 2 years ago

@lukka I added the debug logs in my repository, you should be able to download them. Here's the latest output of the actions.

lukka commented 2 years ago

@gracicot thanks for providing additional info! It looks like vcpkg.exe fails while executing the command vcpkg env, which is spawned by run-cmake action in order to obtain the right environment for the MSVC toolset. I cannot spot what the potential cause of this error is. I'd suggest to use the most recent version of the action (e.g. run-vcpkg@v7) and try again, but it should not make a difference. The reason may be buries in the environment the command is spawned with, but I could not spot any suspicious.

gracicot commented 2 years ago

Updating it to v7 didn't helped. I'll try to use egor-tensin/vs-shell@v2 and see if it helps.

Also, I took the v6 first since that was the version in your examples in your readme, maybe changing it would prevent new users to pick an outdated version?

gracicot commented 2 years ago

@lukka I added the egor-tensin/vs-shell but it didn't helped. As you can see in this action,I added the Print cl.exe and this is the log:

Run cl.exe
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30040 for x86
usage: cl [ option... ] filename... [ /link linkoption... ]
Copyright (C) Microsoft Corporation.  All rights reserved.

The windows version is still failing. I wonder if this is more of a run-vcpkg problem? Should I open an issue there instead? I would really love to use those for my windows builds too, those actions are super convenient, but this problem is blocking me. If you find any workaround please let me know.

lukka commented 2 years ago

@gracicot the process vcpkg.exe exits with code 1, it should be a problem in vcpkg.exe itself. The code that is failing is located here: https://github.com/microsoft/vcpkg-tool/blob/main/src/vcpkg/commands.env.cpp#L71

Note: have you tried to reproduce the same problem on your local dev box? I think that is the way I would approach this problem. In the logs you provided (i.e. these ones) could see what is the environment, the current directory, and the argument of the spawn vcpkg.exe process. Let me know if you need more info on how to tackle this problem down.

gracicot commented 2 years ago

@lukka I could try to reproduce the problem, I'll just need to setup a windows dev box. I will also try to reach the vcpkg devs about this problem too. I will let you know how it goes

lukka commented 2 years ago

@gracicot it may be that you caught an actual problem with vcpkg, and here I add few considerations by reading briefly the code at https://github.com/microsoft/vcpkg-tool/blame/main/src/vcpkg/commands.env.cpp#L70:

lukka commented 2 years ago

@gracicot yes, vcpkg env command is broken on Windows. Just to let you know, on Linux and on macOS it does nothing, that is the reason it is not broken in there :)

PS D:\\vcpkg> .\vcpkg.exe env --bin --tools --python set
get_directories_non_recursive(D:\vcpkg\installed\x86-windows\tools): The system cannot find the path specified.

Now if you create that directory (e.g. mkdir installed\x86-windows\tools), then it works fine.

lukka commented 2 years ago

@gracicot reported here: https://github.com/microsoft/vcpkg/issues/19552

gracicot commented 2 years ago

Oh thank you very much for your work and research on the problem! I'm sorry the problem ended up here, as it is not yours. I'll try as soon as I can and I'll let you know!

gracicot commented 2 years ago

@lukka The workaround worked! I created the directory before running vcpkg and everything is working now. I'm gonna close the issue now, since the problem is actually on the vcpkg side and reported. Thank you very much for your support.