lukka / run-vcpkg

The GitHub Action to setup vcpkg for your C++ based projects. Stores built ports using Binary Caching backed onto GH Cache.
MIT License
194 stars 26 forks source link

'Could not find toolchain file' even though path seems OK #215

Closed eladm-ultrawis closed 11 months ago

eladm-ultrawis commented 11 months ago

I have an existing workflow that uses all lukkas goodies - get-cmake, run-vcpkg and run-cmake.
It works locally when run with 'act' on 'ubuntu-22.04' / 'ubuntu-latest'.

This is the workflow file:

name: ci
run-name: Continuous Integration ${{ github.actor }}
on:
  workflow_dispatch: # allow manual runs 
jobs:
  linux-clang:
    runs-on: ubuntu-22.04
    steps:
    # - name: print context
    #   env:
    #     GITHUB_CONTEXT: ${{ toJson(github) }}
    #   run: echo "$GITHUB_CONTEXT"
    - name: Install LLVM and Clang
      uses: KyleMayes/install-llvm-action@v1.9.0
      with:
        version: "16.0"
    - uses: actions/github-script@v6
      with:
        script: |
          core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
          core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
    - name: Install dependencies required by ffmpeg and glfw
      run: |
        sudo apt-get update
    - name: Install dependencies required by ffmpeg and glfw + ccache
      uses: awalsh128/cache-apt-pkgs-action@latest
      with: 
        packages: | 
                pkg-config 
                nasm 
                libxinerama-dev 
                libxcursor-dev
                xorg-dev 
                libglu1-mesa-dev
                ccache
        version: 1.0
    - name: Setup ccache
      uses: Chocobo1/setup-ccache-action@v1.4.0
      with:
        install_ccache: false
        prepend_symlinks_to_path: true
    - name: get cmake and ninja
      uses: lukka/get-cmake@v3.27.7
      with:
        cmakeVersion: 3.27.1  
        ninjaVersion: 1.11.1  
        useLocalCache: true         # <--= Use the local cache (default is 'false').
        useCloudCache: false        # <--= Ditch the cloud cache (default is 'true').
    - name: get vcpkg
      uses: lukka/run-vcpkg@v11.3
      with:
        vcpkgGitCommitId: '9f03078bdcbab3ad8c1e3927c40c3fb48e42501f'
         # This is the default location of the directory containing vcpkg sources.
         # Change it to the right location if needed.
         # vcpkgDirectory: '${{ github.workspace }}/vcpkg'
    - name: checkout code with LFS caching https://github.com/actions/checkout/issues/165
      # uses: nschloe/action-cached-lfs-checkout@v1.2.2
      uses: actions/checkout@v4
    - name: Create LFS file list
      run: git lfs ls-files --long | cut -d ' ' -f1 | sort > .lfs-assets-id
    - name: LFS Cache
      uses: actions/cache@v3
      with:
        path: .git/lfs/objects
        key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
        restore-keys: |
          ${{ runner.os }}-lfs-  
    - name: Git LFS Pull
      run: git lfs pull
    - name: extract clspv
      run: |
          unzip docker/clspv-linux-x64.zip -d clspv
          echo "$PWD/clspv" >> $GITHUB_PATH
    - name: Run CMake consuming CMakePreset.json and run vcpkg to build packages
      uses: lukka/run-cmake@v10.7
      with:
        workflowPreset: 'clangr'

However, when I try to run it on an official github runner, running cmake --preset=<> fails:

 Error:   Could not find toolchain file:
    /home/runner/work/cranebit/cranebit/vcpkg/scripts/buildsystems/vcpkg.cmake

This is even though the path seems correct, and VCPKG_ROOT is set correctly by run-vcpkg as far as I can see.

I don't know if this is an issue with run-vcpkg or something else entirely, but I was hoping to at least get a hint of what could possibly go wrong.

I added the logs for all the actions.

7_get cmake and ninja.txt 8_get vcpkg.txt 14_Run CMake consuming CMakePreset.json and run vcpkg to bui.txt

lukka commented 11 months ago

@eladm-ultrawis please take a look to this C++ template project, it shows how to setup a C++ based repository with and without run-vcpkg/get/run-cmake actions, so you have two options at least: https://github.com/lukka/CppCMakeVcpkgTemplate

Note that the attachments in the previous comment are zero byte files, if you could re upload them I will certainly take a look.

eladm-ultrawis commented 11 months ago

@lukka I fixed the missing files - let me know if you want more verbose logs or something is missing.

regarding the template - I am pretty much following the same pattern (working with it for more then a year). The main difference is that I don't put vcpkg as a submodule within the directory. I usually install it on the system and have VCPKG_ROOT point to it. Could that be an issue?

Thanks!

eladm-ultrawis commented 11 months ago

@lukka to make it easier, I created a minimalistic project that reproduces the issue:

https://github.com/Ultrawis/cpp_project_template

you can simply fork it and run the single workflow that is there.

I appreciate any help with this!

lukka commented 11 months ago

@eladm-ultrawis thank you for creating a simple repro of the problem. Looks like one of the steps that I commented out is deleting the vcpkg repository downloaded prior with run-vpkg. Look at this successful run (still ongoing, it passed after the point where the CMake's toolchain is being consumed: https://github.com/lukka/cpp_project_template/actions/runs/6874365199/job/18695892552

eladm-ultrawis commented 11 months ago

@lukka I now moved the run-vcpkg stage to run just before run-cmake and indeed the toolchain is found by cmake. I wonder why the previous stages are messing with this folder. They are only supposed to restore the lfs files, not remove anything. anyway, I am closing this issue. THANKS AGAIN!