conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
7.95k stars 951 forks source link

[question] Conan with CMake failing only in CI pipeline but not on local machine. #16497

Closed NateSeymour closed 1 week ago

NateSeymour commented 1 week ago

What is your question?

Hi! Thank you for taking the time to help me here.

I am experiencing a strange bug with conan (I believe, but could possible be do to other components) in my GitHub CI pipeline. For reference, here is the repo and a failed build.

Here is the relevant snippet (line 18ff) from my ci.yml:

    - name: Install Conan
      run: wget https://github.com/conan-io/conan/releases/download/2.2.2/conan-2.2.2-amd64.deb && sudo dpkg -i conan-2.2.2-amd64.deb
    - name: Configure Conan
      run: conan profile detect
    - uses: actions/checkout@v4
    - name: Configure Project and Install Conan Dependencies
      run: mkdir cmake-build-release && sudo conan install . --output-folder="cmake-build-release" --build=missing -s build_type="Release" -c tools.system.package_manager:mode=install -c tools.system.package_manager:sudo=True
    - name: Configure Project
      run: cd cmake-build-release && cmake .. --preset conan-release -G "Ninja"

The "Configure Project" command is the one that is failing with the following error message:

CMake Error at cmake-build-release/cmakedeps_macros.cmake:67 (message):
  Library 'sfml-audio-s' not found in package.  If 'sfml-audio-s' is a system
  library, declare it with 'cpp_info.system_libs' property
Call Stack (most recent call first):
  cmake-build-release/SFML-Target-release.cmake:23 (conan_package_library_targets)
  cmake-build-release/SFMLTargets.cmake:24 (include)
  cmake-build-release/SFMLConfig.cmake:16 (include)
  CMakeLists.txt:7 (find_package)

Which is strange, because the build succeeds when running the same commands on my Ubuntu 23.10 development computer and also on MacOS 13.

I've tried the latest conan 2.4.1 on the CI as well, but downgraded it to match the one on my local machine (2.2.2) to eliminate that potential source of error.

Any help/advice/direction would be greatly appreciated! This one really has me scratching my head. Thanks for all the work you do!

Have you read the CONTRIBUTING guide?

memsharded commented 1 week ago

Hi @NateSeymour

Thanks for reporting. I am having a look, but if it only happens in CI and not locally it might be a bit challenging to debug.

As a first quick question: why are you using sudo conan? This shouldn't be necessary, and it is discoraged in most cases.

Also the last cmake .. --preset conan-release -G "Ninja" could be problematic, the generator should already be defined earlier, because depending on the generator, the layout, files, etc might be different. The correct way is:

conan install ... -c tool.cmake.cmaketoolchain:generator=Ninja
cmake --preset conan-release

As a side recommendation, adding [layout] with cmake_layout will simplify your command line, and --output-folder will be unnecessary (and it works better with other generators as Visual Studio)

memsharded commented 1 week ago

I am trying first with Windows, my base OS, but it seems the code is not fully portable, for example depends on BISON, but this is not a Conan dependency? I'll move to Linux to try

memsharded commented 1 week ago

Uhm, I am getting in Linux:

Could NOT find BISON (missing: BISON_EXECUTABLE) (Required is at least

Are you assuming bison is in the system?

memsharded commented 1 week ago

I am skipping the bison, flex and llvm requirements, trying to reproduce locally on my Ubuntu 22.04, but still didn't manage to make it fail.

It would be great to have something a bit more reproducible, like using a public docker image, and also reducing the reproducible case to the minimum, removing the unnecessary bits like bison, flex, llvm, and just leaving the sfml lib. Thanks!

NateSeymour commented 1 week ago

Hi, @memsharded! First, thanks so much for taking a look! A couple of things:

  1. The sudo conan is left over from numerous failed debugging attempts. I'll remove it.
  2. Thanks for the heads up on generator creation. I didn't know that conan could be fed that option.
  3. I'll take a look into cmake_layout. Looks very helpful from a quick look at the docs.
  4. I hadn't even thought to look in conan center for the flex/bison packages. Good to know that they're there. I'll definitely end up migrating them over to conan deps. Just strange that they don't support Windows?

Second, I'll go ahead and create both

  1. A minimal docker image.
  2. A GitHub repository with a GitHub action that builds it.

and I'll get back to you a bit later today.

Have a great day!

NateSeymour commented 1 week ago

Hi again, @memsharded! It must have been the sudo that I forgot to remove, because now the build stage is passed just fine. Sorry to waste your time with this one, but I really appreciate the help and all the conan tips! Hope you have a great day :)

memsharded commented 1 week ago

Hi again, @memsharded! It must have been the sudo that I forgot to remove, because now the build stage is passed just fine. Sorry to waste your time with this one, but I really appreciate the help and all the conan tips! Hope you have a great day :)

Happy to help and happy to know that the issue is gone with that 🙂

Don't hesitate to create new tickets for any further question or issue you might have. Cheers!