conan-io / conan

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

[bug] conanfile.txt not found when using Github Actions #8307

Closed noctera closed 3 years ago

noctera commented 3 years ago

I want to setup a workflow with Github Actions, but unfortunately conan is telling me that it didn't find my conanfile.txt although it is showing up when executing ls

Run ls && whereis conanfile.txt
CMakeLists.txt
CODE_OF_CONDUCT.md
Dockerfile
LICENSE
README.md
conanfile.txt
docker-compose.yml
images
serverSettings.json
src

Environment Details (include every applicable attribute)

Steps to reproduce (Include if Applicable)

I'm using this Github Action script

name: Catch2 Testing
on: push

jobs:
  build:
    name: Run Catch2 Testing
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v1
      - uses: BSFishy/pip-action@v1
        with:
            packages: conan
      - run: ls
      - run: mkdir build && cd build
      - run: conan install -s compiler.libcxx=libstdc++11 .. --build=missing 
      - run: cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -S . -B build && cmake --build build
      - run: cd build/bin && ./vocascan-server-testing

As you can see I'm installing conan with pip install, create a build folder, cd into it and call conan install as the introduction page in the Documentation tells. This works when running it on my lokal machine, but when executing these commands in Github Actions conanfile.txt can't be found

Logs (Executed commands with output) (Include/Attach if Applicable)

The output of - run: conan install -s compiler.libcxx=libstdc++11 .. --build=missing is:

Auto detecting your dev setup to initialize the default profile (/home/runner/.conan/profiles/default)
Found gcc 7
Found clang 9.0
gcc>=5, using the major as version

************************* WARNING: GCC OLD ABI COMPATIBILITY ***********************

Conan detected a GCC version > 5 but has adjusted the 'compiler.libcxx' setting to
'libstdc++' for backwards compatibility.
Your compiler is likely using the new CXX11 ABI by default (libstdc++11).

If you want Conan to use the new ABI for the default profile, run:

    $ conan profile update settings.compiler.libcxx=libstdc++11 default

Or edit '/home/runner/.conan/profiles/default' and set compiler.libcxx=libstdc++11

************************************************************************************

Default settings
    os=Linux
    os_build=Linux
    arch=x86_64
    arch_build=x86_64
    compiler=gcc
    compiler.version=7
    compiler.libcxx=libstdc++
    build_type=Release
*** You can change them in /home/runner/.conan/profiles/default ***
*** Or override with -s compiler='other' -s ...s***

ERROR: Conanfile not found at /home/runner/work/vocascan-server/conanfile.py or /home/runner/work/vocascan-server/conanfile.txt
Error: Process completed with exit code 1.

Or if you want to see the whole Github Actions Log see this I hope someone can help me with my problem. Thanks in advance :)

noctera commented 3 years ago

I found out that the conanfile is lying in /home/runner/work/vocascan-server/vocascan-server/conanfile.txt but Conan is searching it in /home/runner/work/vocascan-server/conanfile.txt Does anybody know how to specify the path of the file when executing the command?

memsharded commented 3 years ago

First a warning: read the warning. The default profile is using libstdc++, not libstdc++11 which is likely your default. You might want to run $ conan profile update settings.compiler.libcxx=libstdc++11 default, but the recommended way for production is to use your own profiles (maybe managed in a git repo and installed with conan config install )

The path when you execute the command

 conan install -s compiler.libcxx=libstdc++11 .. --build=missing 

Is the two dots .. , which means the parent folder of the current folder in which the command is being executed. That parent folder must contain either a conanfile.py or a conanfile.txt, otherwise it will error.

That is a path to the folder or conanfile, you can do things like:

conan install /absolute/path/to/folder  -s compiler.libcxx=libstdc++11 --build=missing
conan install /absolute/path/to/folder/conanfile.txt -s compiler.libcxx=libstdc++11 --build=missing
conan install /absolute/path/to/folder/myconanfile.txt -s compiler.libcxx=libstdc++11 --build=missing
conan install ../relative/to/folder -s compiler.libcxx=libstdc++11 --build=missing
conan install ../relative/to/folder/conanfile.txt  -s compiler.libcxx=libstdc++11 --build=missing

Please let me know if this helps, doesn't seem a bug, but a confusion with the folders and current working directory.

noctera commented 3 years ago

Sorry for labelling it as a bug, it was totally my fault. Github Actions is always returning to the root directory after every executed command. So I have to write cd build && conan install .....(together with &&) instead of separated.

Thanks for your help and the tipp with the profiles :)

memsharded commented 3 years ago

Oh, yes, I see, indeed, I didn't realize that Github actions don't keep the cwd, so yes, you would need to do that.

If that is solved, please close the issue, and don't hesitate to open new ones for further questions. Thanks!